Skip to content

Commit 1f09711

Browse files
committed
address review
1 parent 4f654ae commit 1f09711

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/controller/instaslice_controller.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controller
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"regexp"
2223
"strings"
2324

@@ -139,6 +140,11 @@ func (r *InstasliceReconciler) findDeviceForASlice(ctx context.Context, instasli
139140
instaslice.Spec.Allocations = make(map[string]inferencev1alpha1.AllocationDetails)
140141
}
141142
newStart := r.getStartIndexFromPreparedState(instaslice, gpuUUID, profileName)
143+
notValidIndex := uint32(8)
144+
if newStart == notValidIndex {
145+
//Move to next GPU
146+
continue
147+
}
142148
size, discoveredGiprofile, Ciprofileid, Ciengprofileid := r.extractGpuProfile(instaslice, profileName)
143149
allocDetails := policy.SetAllocationDetails(profileName, uint32(newStart), uint32(size),
144150
string(pod.UID), instaslice.Name, "no", discoveredGiprofile,
@@ -150,7 +156,7 @@ func (r *InstasliceReconciler) findDeviceForASlice(ctx context.Context, instasli
150156
}
151157
return gpuUUID, false, reconcile.Result{}, nil
152158
}
153-
return gpuUUID, false, reconcile.Result{}, nil
159+
return "", false, reconcile.Result{}, fmt.Errorf("No valid GPU found that can fit slice")
154160
}
155161

156162
// Extract profile name from the container limits spec
@@ -192,7 +198,7 @@ func (*InstasliceReconciler) extractGpuProfile(instaslice inferencev1alpha1.Inst
192198
}
193199

194200
func (*InstasliceReconciler) getStartIndexFromPreparedState(instaslice inferencev1alpha1.Instaslice, gpuUUID string, profileName string) uint32 {
195-
201+
//TODO: generalize, A100 and H100 have 7 profiles so it hardwired for now
196202
var gpuAllocatedIndex [7]uint32
197203
// Explicitly set the array to all zeros
198204
for i := range gpuAllocatedIndex {
@@ -218,7 +224,9 @@ func (*InstasliceReconciler) getStartIndexFromPreparedState(instaslice inference
218224
break
219225
}
220226
}
221-
var newStart uint32
227+
//TODO: generalize, no slices can be placed on 8th index
228+
//if we return 8 then assume no valid index is found.
229+
var newStart = uint32(8)
222230
for _, value := range possiblePlacements {
223231
if gpuAllocatedIndex[value] == 0 {
224232
if neededContinousSlot == 1 {

0 commit comments

Comments
 (0)