@@ -1080,5 +1080,140 @@ var _ = Describe("NIMBuild Controller", func() {
1080
1080
Expect (customModelPathFound ).To (BeTrue (), "NIM_MODEL_PATH should be overridden in created pod" )
1081
1081
Expect (defaultCachePathFound ).To (BeTrue (), "Default NIM_CACHE_PATH should be preserved in created pod" )
1082
1082
})
1083
+
1084
+ It ("should set NIM_PEFT_SOURCE when LORA is enabled in profile" , func () {
1085
+ // Create a profile with LORA enabled
1086
+ loraProfile := appsv1alpha1.NIMProfile {
1087
+ Name : "lora-profile" ,
1088
+ Model : "test-model" ,
1089
+ Config : map [string ]string {"feat_lora" : "true" , "trtllm_buildable" : "true" },
1090
+ }
1091
+
1092
+ nimBuild := & appsv1alpha1.NIMBuild {
1093
+ ObjectMeta : metav1.ObjectMeta {
1094
+ Name : "test-nimbuild" ,
1095
+ Namespace : "default" ,
1096
+ },
1097
+ Spec : appsv1alpha1.NIMBuildSpec {
1098
+ NIMCache : appsv1alpha1.NIMCacheReference {
1099
+ Name : nimCache .Name ,
1100
+ },
1101
+ Image : appsv1alpha1.Image {
1102
+ Repository : "nvcr.io/nim/test" ,
1103
+ Tag : "latest" ,
1104
+ },
1105
+ Resources : & appsv1alpha1.ResourceRequirements {
1106
+ Requests : corev1.ResourceList {
1107
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1108
+ },
1109
+ Limits : corev1.ResourceList {
1110
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1111
+ },
1112
+ },
1113
+ },
1114
+ }
1115
+
1116
+ // Test pod construction with LORA-enabled profile
1117
+ pod , err := reconciler .constructEngineBuildPod (nimBuild , nimCache , k8sutil .K8s , loraProfile )
1118
+ Expect (err ).ToNot (HaveOccurred ())
1119
+
1120
+ // Check that NIM_PEFT_SOURCE environment variable is set
1121
+ envVars := pod .Spec .Containers [0 ].Env
1122
+ var nimPeftSourceFound bool
1123
+ for _ , env := range envVars {
1124
+ if env .Name == "NIM_PEFT_SOURCE" {
1125
+ Expect (env .Value ).To (Equal ("/tmp" ))
1126
+ nimPeftSourceFound = true
1127
+ break
1128
+ }
1129
+ }
1130
+ Expect (nimPeftSourceFound ).To (BeTrue (), "NIM_PEFT_SOURCE should be set when LORA is enabled" )
1131
+ })
1132
+
1133
+ It ("should not set NIM_PEFT_SOURCE when LORA is disabled in profile" , func () {
1134
+ // Create a profile with LORA disabled
1135
+ noLoraProfile := appsv1alpha1.NIMProfile {
1136
+ Name : "no-lora-profile" ,
1137
+ Model : "test-model" ,
1138
+ Config : map [string ]string {"feat_lora" : "false" , "trtllm_buildable" : "true" },
1139
+ }
1140
+
1141
+ nimBuild := & appsv1alpha1.NIMBuild {
1142
+ ObjectMeta : metav1.ObjectMeta {
1143
+ Name : "test-nimbuild" ,
1144
+ Namespace : "default" ,
1145
+ },
1146
+ Spec : appsv1alpha1.NIMBuildSpec {
1147
+ NIMCache : appsv1alpha1.NIMCacheReference {
1148
+ Name : nimCache .Name ,
1149
+ },
1150
+ Image : appsv1alpha1.Image {
1151
+ Repository : "nvcr.io/nim/test" ,
1152
+ Tag : "latest" ,
1153
+ },
1154
+ Resources : & appsv1alpha1.ResourceRequirements {
1155
+ Requests : corev1.ResourceList {
1156
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1157
+ },
1158
+ Limits : corev1.ResourceList {
1159
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1160
+ },
1161
+ },
1162
+ },
1163
+ }
1164
+
1165
+ // Test pod construction with LORA-disabled profile
1166
+ pod , err := reconciler .constructEngineBuildPod (nimBuild , nimCache , k8sutil .K8s , noLoraProfile )
1167
+ Expect (err ).ToNot (HaveOccurred ())
1168
+
1169
+ // Check that NIM_PEFT_SOURCE environment variable is NOT set
1170
+ envVars := pod .Spec .Containers [0 ].Env
1171
+ for _ , env := range envVars {
1172
+ Expect (env .Name ).NotTo (Equal ("NIM_PEFT_SOURCE" ), "NIM_PEFT_SOURCE should not be set when LORA is disabled" )
1173
+ }
1174
+ })
1175
+
1176
+ It ("should not set NIM_PEFT_SOURCE when LORA config is missing from profile" , func () {
1177
+ // Create a profile without LORA config
1178
+ noLoraConfigProfile := appsv1alpha1.NIMProfile {
1179
+ Name : "no-lora-config-profile" ,
1180
+ Model : "test-model" ,
1181
+ Config : map [string ]string {"trtllm_buildable" : "true" },
1182
+ }
1183
+
1184
+ nimBuild := & appsv1alpha1.NIMBuild {
1185
+ ObjectMeta : metav1.ObjectMeta {
1186
+ Name : "test-nimbuild" ,
1187
+ Namespace : "default" ,
1188
+ },
1189
+ Spec : appsv1alpha1.NIMBuildSpec {
1190
+ NIMCache : appsv1alpha1.NIMCacheReference {
1191
+ Name : nimCache .Name ,
1192
+ },
1193
+ Image : appsv1alpha1.Image {
1194
+ Repository : "nvcr.io/nim/test" ,
1195
+ Tag : "latest" ,
1196
+ },
1197
+ Resources : & appsv1alpha1.ResourceRequirements {
1198
+ Requests : corev1.ResourceList {
1199
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1200
+ },
1201
+ Limits : corev1.ResourceList {
1202
+ "nvidia.com/gpu" : resource .MustParse ("8" ),
1203
+ },
1204
+ },
1205
+ },
1206
+ }
1207
+
1208
+ // Test pod construction with profile missing LORA config
1209
+ pod , err := reconciler .constructEngineBuildPod (nimBuild , nimCache , k8sutil .K8s , noLoraConfigProfile )
1210
+ Expect (err ).ToNot (HaveOccurred ())
1211
+
1212
+ // Check that NIM_PEFT_SOURCE environment variable is NOT set
1213
+ envVars := pod .Spec .Containers [0 ].Env
1214
+ for _ , env := range envVars {
1215
+ Expect (env .Name ).NotTo (Equal ("NIM_PEFT_SOURCE" ), "NIM_PEFT_SOURCE should not be set when LORA config is missing" )
1216
+ }
1217
+ })
1083
1218
})
1084
1219
})
0 commit comments