Skip to content

Commit 785fbd7

Browse files
authored
Perform GPU match only when we are going through the optimized profile (#107)
Signed-off-by: Shiva Krishna, Merla <[email protected]>
1 parent e43443b commit 785fbd7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

internal/nimparser/nimparser.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import (
2525
"gopkg.in/yaml.v2"
2626
)
2727

28+
const (
29+
// BackendTypeTensorRT indicates tensortt backend
30+
BackendTypeTensorRT = "tensorrt"
31+
)
32+
2833
// File represents the model files
2934
type File struct {
3035
Name string `yaml:"name" json:"name,omitempty"`
@@ -152,11 +157,17 @@ func MatchProfiles(modelSpec appsv1alpha1.ModelSpec, manifest NIMManifest, disco
152157
continue
153158
}
154159

155-
// GPU matching logic
156-
if len(modelSpec.GPUs) > 0 || len(discoveredGPUs) > 0 {
157-
if !matchGPUProfile(modelSpec, profile, discoveredGPUs) {
160+
// Perform GPU match only when optimized engine is selected or GPU filters are provided
161+
if isOptimizedEngine(modelSpec.Engine) || len(modelSpec.GPUs) > 0 {
162+
// Skip non optimized profiles
163+
if !isOptimizedEngine(backend) {
158164
continue
159165
}
166+
if len(modelSpec.GPUs) > 0 || len(discoveredGPUs) > 0 {
167+
if !matchGPUProfile(modelSpec, profile, discoveredGPUs) {
168+
continue
169+
}
170+
}
160171
}
161172

162173
// Profile matched the given model parameters, add hash to the selected profiles
@@ -166,6 +177,10 @@ func MatchProfiles(modelSpec appsv1alpha1.ModelSpec, manifest NIMManifest, disco
166177
return selectedProfiles, nil
167178
}
168179

180+
func isOptimizedEngine(engine string) bool {
181+
return engine != "" && strings.Contains(strings.ToLower(engine), BackendTypeTensorRT)
182+
}
183+
169184
func matchGPUProfile(modelSpec appsv1alpha1.ModelSpec, profile NIMProfile, discoveredGPUs []string) bool {
170185
foundGPU := false
171186

0 commit comments

Comments
 (0)