-
Notifications
You must be signed in to change notification settings - Fork 28
Optimize for requesting 1 device #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,33 @@ func (p *bestEffortPolicy) Allocate(available []*Device, required []*Device, siz | |
| return []*Device{} | ||
| } | ||
|
|
||
| if len(required) > len(available) { | ||
| return []*Device{} | ||
| } | ||
|
|
||
| // Optimize for the case when we required is actually the `size`. | ||
| if size == len(required) { | ||
| if gpuPartitionContainsSetWithAll([][]*Device{available}, required) { | ||
| return required | ||
| } else { | ||
| return []*Device{} | ||
| } | ||
| } | ||
|
|
||
| // Optimize for the case when size == 1. | ||
| // We'll pick the device with the minimum sum of scores with available devices. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can discuss here, from my POV, since 1 device no longer needs the communication with other GPUs, so the lower score the better.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For requests with 1 device is the choice not irrellevant from the perspective of the application requesting the device? It may be that assigning the device with the lowest connectivity in this case provides some advantage since other more connected devices are available for future requests that require multple devices. Do you have benchmarks to show whether this change improves performance at all?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, exactly the case, benefit to the future request for multi-devices. I have no benchmark yet, but I can provide one if needed, generally, this is not quite aimed for the performance but for the application friendly and rational utilization as you described above. |
||
| if size == 1 { | ||
| var bestDevice *Device | ||
| var minScore int | ||
| iterateGPUSetScore(available, func(score int, index int) { | ||
| if score < minScore || bestDevice == nil { | ||
| minScore = score | ||
| bestDevice = available[index] | ||
| } | ||
| }) | ||
| return []*Device{bestDevice} | ||
| } | ||
|
|
||
| // Find the highest scoring GPU partition with sets of of size 'size'. | ||
| // Don't consider partitions that don't have at least one set that contains | ||
| // all of the GPUs 'required' by the allocation. | ||
|
|
@@ -217,14 +244,6 @@ func iterateGPUPartitions(devices []*Device, size int, callback func([][]*Device | |
| return | ||
| } | ||
|
|
||
| // Optimize for the case when size == 1. | ||
| if size == 1 { | ||
| for _, device := range devices { | ||
| callback([][]*Device{{device}}) | ||
| } | ||
| return | ||
| } | ||
|
|
||
| // Otherwise, pad the list of available GPUs on the node such that the list | ||
| // can be evenly partitioned into subsets of size 'size'. This is necessary | ||
| // to ensure that the recursive solution does not exit early and actually | ||
|
|
@@ -392,3 +411,16 @@ func calculateGPUPartitionScore(gpuPartition [][]*Device) int { | |
|
|
||
| return score | ||
| } | ||
|
|
||
| func iterateGPUSetScore(gpuSet []*Device, callback func(int, int)) { | ||
| for i := range gpuSet { | ||
| score := 0 | ||
| for j := range gpuSet { | ||
| if i == j { | ||
| continue | ||
| } | ||
| score += calculateGPUPairScore(gpuSet[i], gpuSet[j]) | ||
| } | ||
| callback(score, i) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.