@@ -25,8 +25,13 @@ type BindRequestSpec struct {
2525
2626 // SelectedGPUGroups is the name of the selected GPU groups for fractional GPU resources.
2727 // Only if the RecievedResourceType is "Fraction"
28+ // Deprecated: Use SelectedFractionalGpuGroups instead
2829 SelectedGPUGroups []string `json:"selectedGPUGroups,omitempty"`
2930
31+ // SelectedFractionalGpuGroups is the selected GPU groups for fractional GPU resources.
32+ // Only if the RecievedResourceType is "Fraction"
33+ SelectedFractionalGpuGroups []FractionalGpuGroup `json:"selectedFractionalGpuGroups,omitempty"`
34+
3035 // ResourceClaims is the list of resource claims that need to be bound for this pod
3136 ResourceClaimAllocations []ResourceClaimAllocation `json:"resourceClaimAllocations,omitempty"`
3237
@@ -42,6 +47,70 @@ type BindRequestSpec struct {
4247 BackoffLimit * int32 `json:"backoffLimit,omitempty"`
4348}
4449
50+ type GPUComputeSharingMode string
51+
52+ const (
53+ GPUComputeSharingModeTimeSlicing GPUComputeSharingMode = "time-slicing"
54+ GPUComputeSharingModeSMSharing GPUComputeSharingMode = "sm-sharing"
55+ )
56+
57+ type FractionalGpuGroup struct {
58+ ID string `json:"id,omitempty"`
59+ ComputeSharingMode GPUComputeSharingMode `json:"computeSharingMode,omitempty"`
60+ }
61+
62+ func (group FractionalGpuGroup ) WithDefaults () FractionalGpuGroup {
63+ if group .ComputeSharingMode == "" {
64+ group .ComputeSharingMode = GPUComputeSharingModeTimeSlicing
65+ }
66+ return group
67+ }
68+
69+ func NewFractionalGpuGroups (gpuGroups []string , mode GPUComputeSharingMode ) []FractionalGpuGroup {
70+ if len (gpuGroups ) == 0 {
71+ return nil
72+ }
73+ mode = DefaultGPUComputeSharingMode (mode )
74+ fractionalGpuGroups := make ([]FractionalGpuGroup , 0 , len (gpuGroups ))
75+ for _ , gpuGroup := range gpuGroups {
76+ fractionalGpuGroups = append (fractionalGpuGroups , FractionalGpuGroup {
77+ ID : gpuGroup ,
78+ ComputeSharingMode : mode ,
79+ })
80+ }
81+ return fractionalGpuGroups
82+ }
83+
84+ func DefaultGPUComputeSharingMode (mode GPUComputeSharingMode ) GPUComputeSharingMode {
85+ if mode == "" {
86+ return GPUComputeSharingModeTimeSlicing
87+ }
88+ return mode
89+ }
90+
91+ func (spec * BindRequestSpec ) SelectedFractionalGpuGroupsOrDefault () []FractionalGpuGroup {
92+ if len (spec .SelectedFractionalGpuGroups ) > 0 {
93+ fractionalGpuGroups := make ([]FractionalGpuGroup , 0 , len (spec .SelectedFractionalGpuGroups ))
94+ for _ , fractionalGpuGroup := range spec .SelectedFractionalGpuGroups {
95+ fractionalGpuGroups = append (fractionalGpuGroups , fractionalGpuGroup .WithDefaults ())
96+ }
97+ return fractionalGpuGroups
98+ }
99+ return NewFractionalGpuGroups (spec .SelectedGPUGroups , GPUComputeSharingModeTimeSlicing )
100+ }
101+
102+ func (spec * BindRequestSpec ) SelectedFractionalGpuGroupIDs () []string {
103+ fractionalGpuGroups := spec .SelectedFractionalGpuGroupsOrDefault ()
104+ if len (fractionalGpuGroups ) == 0 {
105+ return nil
106+ }
107+ gpuGroups := make ([]string , 0 , len (fractionalGpuGroups ))
108+ for _ , fractionalGpuGroup := range fractionalGpuGroups {
109+ gpuGroups = append (gpuGroups , fractionalGpuGroup .ID )
110+ }
111+ return gpuGroups
112+ }
113+
45114type ReceivedGPU struct {
46115 // Count is the amount of GPUs devices that were received
47116 Count int `json:"count,omitempty"`
0 commit comments