Skip to content
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

fix(api): Change default GPU Request value and prevent null values from being accepted #533

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions api/cluster/resource/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,26 @@ func (t *InferenceServiceTemplater) createPredictorSpec(modelService *models.Ser

nodeSelector := map[string]string{}
tolerations := []corev1.Toleration{}
if modelService.ResourceRequest.GPUName != "" && !modelService.ResourceRequest.GPURequest.IsZero() {
// Look up to the GPU resource type and quantity from DeploymentConfig
for _, gpuConfig := range t.deploymentConfig.GPUs {
if gpuConfig.Name == modelService.ResourceRequest.GPUName {
// Declare and initialize resourceType and resourceQuantity variables
resourceType := corev1.ResourceName(gpuConfig.ResourceType)
resourceQuantity := modelService.ResourceRequest.GPURequest

// Set the resourceType as the key in the maps, with resourceQuantity as the value
resources.Requests[resourceType] = resourceQuantity
resources.Limits[resourceType] = resourceQuantity

nodeSelector = gpuConfig.NodeSelector
tolerations = gpuConfig.Tolerations

if modelService.ResourceRequest.GPUName != "" {
if modelService.ResourceRequest.GPURequest.IsZero() {
// This should never be set as zero if a GPU name is specified
return kservev1beta1.PredictorSpec{}, fmt.Errorf("GPU request cannot set as be 0")
} else {
// Look up to the GPU resource type and quantity from DeploymentConfig
for _, gpuConfig := range t.deploymentConfig.GPUs {
if gpuConfig.Name == modelService.ResourceRequest.GPUName {
// Declare and initialize resourceType and resourceQuantity variables
resourceType := corev1.ResourceName(gpuConfig.ResourceType)
resourceQuantity := modelService.ResourceRequest.GPURequest

// Set the resourceType as the key in the maps, with resourceQuantity as the value
resources.Requests[resourceType] = resourceQuantity
resources.Limits[resourceType] = resourceQuantity

nodeSelector = gpuConfig.NodeSelector
tolerations = gpuConfig.Tolerations
}
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions api/cluster/resource/templater_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func TestCreateInferenceServiceSpecWithGPU(t *testing.T) {
},
}

invalidResourceRequest := &models.ResourceRequest{
MinReplica: 1,
MaxReplica: 2,
CPURequest: resource.MustParse("500m"),
MemoryRequest: resource.MustParse("500Mi"),
GPUName: "NVIDIA P4",
}

queueResourcePercentage := "2"
storageUri := fmt.Sprintf("%s/model", modelSvc.ArtifactURI)

Expand Down Expand Up @@ -1563,6 +1571,25 @@ func TestCreateInferenceServiceSpecWithGPU(t *testing.T) {
},
},
},
{
name: "invalid resource request with 0 GPU requested",
modelSvc: &models.Service{
Name: modelSvc.Name,
ModelName: modelSvc.ModelName,
ModelVersion: modelSvc.ModelVersion,
Namespace: project.Name,
ArtifactURI: modelSvc.ArtifactURI,
Type: models.ModelTypeTensorflow,
Options: &models.ModelOption{},
Metadata: modelSvc.Metadata,
Protocol: protocol.HttpJson,
ResourceRequest: invalidResourceRequest,
},
resourcePercentage: queueResourcePercentage,
deploymentScale: defaultDeploymentScale,
exp: &kservev1beta1.InferenceService{},
wantErr: true,
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const ResourcesPanel = ({
return;
}
onChange("gpu_name")(gpu_name);
onChange("gpu_request")(undefined);
onChange("gpu_request")(gpus[gpu_name].values[0]);
onChange("min_monthly_cost_per_gpu")(
gpus[gpu_name].min_monthly_cost_per_gpu
);
Expand Down
Loading