fix: Dynamic GPU partitioning lacks single-GPU-level granularity. (#1… - #1061
Conversation
|
/assign @ouyangluwei163 |
|
|
||
| if len(migConfigs["current"]) == 1 && len(migConfigs["current"][0].Devices) == 0 { | ||
| for i := 0; i < deviceCount; i++ { | ||
| config := migConfigs["current"][0] |
There was a problem hiding this comment.
migConfigs["current"][idx].MigDevices is Map, Map types are reference types. https://github.com/Project-HAMi/HAMi/blob/master/pkg/device-plugin/nvidiadevice/nvinternal/plugin/util.go#L255C8-L255C73
There was a problem hiding this comment.
Is the intention here to perform a deep copy of the map type instead of using a reference?
There was a problem hiding this comment.
yes, if multiple cards in the machine are one flavor.
version: v1
mig-configs:
current:
- devices: [0, 1, 2]
mig-enabled: true
mig-devices:
1g.5gb: 1
2g.10gb: 3
and if not deep copy, when device 0 is modified, devices 1/2 will also be modified
There was a problem hiding this comment.
done.the deepCopyMigConfig function has been used to perform a deep copy
There was a problem hiding this comment.
great, I will test it later
| return result, nil | ||
| } | ||
|
|
||
| for i := 0; i < deviceCount; i++ { |
There was a problem hiding this comment.
Here you can simplify, 692-715
for i := 0; i < deviceCount; i++ {
var found bool
for idx, config := range migConfigs["current"] {
if len(config.Devices) == 0 || containsDevice(i, config.Devices) {
newConfig := migConfigs["current"][idx]
newConfig.MigDevices = make(map[string]int32)
for k, v := range migConfigs["current"][idx].MigDevices {
newConfig.MigDevices[k] = v
}
newConfig.Devices = []int32{int32(i)}
result = append(result, newConfig)
found = true
break
}
}
if !found {
return nil, fmt.Errorf("device %d does not match any MIG configuration", i)
}
}
There was a problem hiding this comment.
done,use additional auxiliary structures
deviceToConfig := make(map[int32]*nvidia.MigConfigSpec)
to reduce the number of for loop layers
…oject-HAMi#1054) Signed-off-by: Goend <jian.mei@easystack.cn>
| deviceIndex := int32(i) | ||
| config, exists := deviceToConfig[deviceIndex] | ||
| if !exists { | ||
| return nil, fmt.Errorf("device %d does not match any MIG configuration", i) |
There was a problem hiding this comment.
The error here does not need to be handled. If the corresponding device configuration is not found, simply continue and issue a warning. There is no need for
return nil, fmt.Errorf("device %d does not match any MIG configuration", i)
instead, just use continue. and return other config
such as return config,fmt.Errorf("device %d does not match any MIG configuration", i)
|
@ouyangluwei163 ready to integrate? |
|
when signal gpu in node,the generate config is ok |
|
/lgtm |
|
/lgtm |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Flags with carried forward coverage won't be shown. Click here to find out more. see 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
…054)
What type of PR is this?
What this PR does / why we need it:
fix: Dynamic GPU partitioning lacks single-GPU-level granularity. (#1…
Which issue(s) this PR fixes:
Fixes #1054
Special notes for your reviewer:
Does this PR introduce a user-facing change?: