Skip to content

Commit e85aa94

Browse files
committed
Ensure max number of SM are allocated by mig-parted
Signed-off-by: Arjun <agadiyar@nvidia.com>
1 parent 182c9a1 commit e85aa94

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
@@ -373,8 +373,8 @@ func (d *device) VisitMigProfiles(visit func(MigProfile) error) error {
373373
return fmt.Errorf("error getting GPU Instance profile info: %v", ret)
374374
}
375375

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

400419
err = visit(p)
401420
if err != nil {

0 commit comments

Comments
 (0)