Skip to content

Commit 8ff29bb

Browse files
authored
Merge pull request #85 from JunAr7112/update_sm_loop
Ensure max number of SM are allocated by mig-parted
2 parents 68058ce + e85aa94 commit 8ff29bb

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

pkg/nvlib/device/device.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ func (d *device) VisitMigProfiles(visit func(MigProfile) error) error {
377377
return fmt.Errorf("error getting GPU Instance profile info: %v", ret)
378378
}
379379

380-
for j := 0; j < nvml.COMPUTE_INSTANCE_PROFILE_COUNT; j++ {
381-
for k := 0; k < nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT; k++ {
380+
for j := nvml.COMPUTE_INSTANCE_PROFILE_COUNT - 1; j >= 0; j-- {
381+
for k := nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT - 1; k >= 0; k-- {
382382
p, err := d.lib.NewMigProfile(i, j, k, giProfileInfo.MemorySizeMB, memory.Total)
383383
if err != nil {
384384
return fmt.Errorf("error creating MIG profile: %v", err)
@@ -400,6 +400,25 @@ func (d *device) VisitMigProfiles(visit func(MigProfile) error) error {
400400
if (pi.C < pi.G) && ((pi.C * 2) > (pi.G + 1)) {
401401
continue
402402
}
403+
// NOTE: As we iterate through the profiles by GPU instance count and Compute instance count, we will find revisions
404+
// of the COMPUTE_INSTANCE_PROFILE that have the same slice count. In these cases, we need to ensure that we pick the
405+
// COMPUTE_INSTANCE_PROFILE with the maximum multiprocessor (SM) count, that is still valid for the GPU instance profile.
406+
//
407+
// For example: On systems like the H100, the MIG profiles 1g.12gb and 1g.24gb are both supported and will have one cislice.
408+
// Given the higher memory capacity, the 1g.24gb profile would be compatible with both the COMPUTE_INSTANCE_PROFILE_1_SLICE
409+
// and the COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1. However, the 1g.12gb profile would only be compatible with the
410+
// COMPUTE_INSTANCE_PROFILE_1_SLICE. To ensure that we have the CI profile with the maximum compatible SM count, the 1g.12gb
411+
// should use the COMPUTE_INSTANCE_PROFILE_1_SLICE and 1g.24gb should use the COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1.
412+
//
413+
// While iterating through the GPU instance profiles (d.GetGpuInstanceProfileInfo(i)), we need to ensure that we pick the
414+
// correct CI profile/revision. For the above example, we will find that GPU_INSTANCE_PROFILE_1_SLICE is only compatible with
415+
// COMPUTE_INSTANCE_PROFILE_1_SLICE. The GPU_INSTANCE_PROFILE_1_SLICE_REV2 (when available for systems like the H100) can be
416+
// deployed with both COMPUTE_INSTANCE_PROFILE_1_SLICE and COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1, but to maximize performance,
417+
// we should pick the COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 profile. The following check is a temporary workaround to ensure
418+
// that we pick the correct COMPUTE_INSTANCE_PROFILE revision.
419+
if pi.CIProfileID == nvml.COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 && pi.GIProfileID != nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV2 {
420+
continue
421+
}
403422

404423
err = visit(p)
405424
if err != nil {

0 commit comments

Comments
 (0)