Skip to content

Commit 6d0ef93

Browse files
authored
add support for caching HF revisions (#568)
* add support for caching HF revisions Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com> * deprecate hostpath nimcache storage Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com> * use consistent mount paths in nimcache Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com> * add unittests for nimsource Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com> * fix lint errors Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com> --------- Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com>
1 parent 4121ddc commit 6d0ef93

9 files changed

Lines changed: 310 additions & 67 deletions

File tree

api/apps/v1alpha1/nimcache_types.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,22 @@ type NIMSource struct {
7272

7373
// +kubebuilder:validation:XValidation:rule="(has(self.modelName) ? 1 : 0) + (has(self.datasetName) ? 1 : 0) == 1",message="Exactly one of modelName or datasetName must be defined"
7474
type DSHFCommonFields struct {
75-
// modelName is the name of the model
75+
// ModelName is the name of the model
7676
ModelName *string `json:"modelName,omitempty"`
77-
// datasetName is the name of the dataset
77+
// DatasetName is the name of the dataset
7878
DatasetName *string `json:"datasetName,omitempty"`
79-
// authSecret is the name of the secret containing the "HF_TOKEN" token
79+
// AuthSecret is the name of the secret containing the "HF_TOKEN" token
8080
// +kubebuilder:validation:MinLength=1
8181
AuthSecret string `json:"authSecret"`
82-
// modelPuller is the containerized huggingface-cli image to pull the data
82+
// ModelPuller is the containerized huggingface-cli image to pull the data
8383
// +kubebuilder:validation:MinLength=1
8484
ModelPuller string `json:"modelPuller"`
85-
// pullSecret is the name of the image pull secret for the modelPuller image
85+
// PullSecret is the name of the image pull secret for the modelPuller image
8686
// +kubebuilder:validation:MinLength=1
8787
PullSecret string `json:"pullSecret"`
88+
// Revision is the revision of the object to be cached. This is either a commit hash, branch name or tag.
89+
// +kubebuilder:validation:MinLength=1
90+
Revision *string `json:"revision,omitempty"`
8891
}
8992

9093
type NemoDataStoreSource struct {
@@ -156,6 +159,8 @@ type NIMCacheStorage struct {
156159
// PersistentVolumeClaim is the pvc volume used for caching NIM
157160
PVC PersistentVolumeClaim `json:"pvc,omitempty"`
158161
// HostPath is the host path volume for caching NIM
162+
//
163+
// Deprecated: use PVC instead.
159164
HostPath *string `json:"hostPath,omitempty"`
160165
}
161166

@@ -423,6 +428,13 @@ func (d *DSHFCommonFields) GetPullSecret() string {
423428
return d.PullSecret
424429
}
425430

431+
func (d *DSHFCommonFields) GetRevision() string {
432+
if d.Revision == nil {
433+
return ""
434+
}
435+
return *d.Revision
436+
}
437+
426438
func (d *HuggingFaceHubSource) GetEndpoint() string {
427439
return d.Endpoint
428440
}

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/apps.nvidia.com_nimcaches.yaml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,23 @@ spec:
243243
DataStore service
244244
properties:
245245
authSecret:
246-
description: authSecret is the name of the secret containing
246+
description: AuthSecret is the name of the secret containing
247247
the "HF_TOKEN" token
248248
minLength: 1
249249
type: string
250250
datasetName:
251-
description: datasetName is the name of the dataset
251+
description: DatasetName is the name of the dataset
252252
type: string
253253
endpoint:
254254
description: Endpoint is the HuggingFace endpoint from NeMo
255255
DataStore
256256
pattern: ^https?://.*/v1/hf/?$
257257
type: string
258258
modelName:
259-
description: modelName is the name of the model
259+
description: ModelName is the name of the model
260260
type: string
261261
modelPuller:
262-
description: modelPuller is the containerized huggingface-cli
262+
description: ModelPuller is the containerized huggingface-cli
263263
image to pull the data
264264
minLength: 1
265265
type: string
@@ -268,10 +268,15 @@ spec:
268268
description: Namespace is the namespace within NeMo DataStore
269269
type: string
270270
pullSecret:
271-
description: pullSecret is the name of the image pull secret
271+
description: PullSecret is the name of the image pull secret
272272
for the modelPuller image
273273
minLength: 1
274274
type: string
275+
revision:
276+
description: Revision is the revision of the object to be
277+
cached. This is either a commit hash, branch name or tag.
278+
minLength: 1
279+
type: string
275280
required:
276281
- authSecret
277282
- endpoint
@@ -288,22 +293,22 @@ spec:
288293
Hub
289294
properties:
290295
authSecret:
291-
description: authSecret is the name of the secret containing
296+
description: AuthSecret is the name of the secret containing
292297
the "HF_TOKEN" token
293298
minLength: 1
294299
type: string
295300
datasetName:
296-
description: datasetName is the name of the dataset
301+
description: DatasetName is the name of the dataset
297302
type: string
298303
endpoint:
299304
description: Endpoint is the HuggingFace endpoint
300305
pattern: ^https?://.*$
301306
type: string
302307
modelName:
303-
description: modelName is the name of the model
308+
description: ModelName is the name of the model
304309
type: string
305310
modelPuller:
306-
description: modelPuller is the containerized huggingface-cli
311+
description: ModelPuller is the containerized huggingface-cli
307312
image to pull the data
308313
minLength: 1
309314
type: string
@@ -313,10 +318,15 @@ spec:
313318
minLength: 1
314319
type: string
315320
pullSecret:
316-
description: pullSecret is the name of the image pull secret
321+
description: PullSecret is the name of the image pull secret
317322
for the modelPuller image
318323
minLength: 1
319324
type: string
325+
revision:
326+
description: Revision is the revision of the object to be
327+
cached. This is either a commit hash, branch name or tag.
328+
minLength: 1
329+
type: string
320330
required:
321331
- authSecret
322332
- endpoint
@@ -421,7 +431,10 @@ spec:
421431
description: Storage is the target storage for caching NIM model
422432
properties:
423433
hostPath:
424-
description: HostPath is the host path volume for caching NIM
434+
description: |-
435+
HostPath is the host path volume for caching NIM
436+
437+
Deprecated: use PVC instead.
425438
type: string
426439
pvc:
427440
description: PersistentVolumeClaim is the pvc volume used for

config/crd/bases/apps.nvidia.com_nimcaches.yaml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,23 @@ spec:
243243
DataStore service
244244
properties:
245245
authSecret:
246-
description: authSecret is the name of the secret containing
246+
description: AuthSecret is the name of the secret containing
247247
the "HF_TOKEN" token
248248
minLength: 1
249249
type: string
250250
datasetName:
251-
description: datasetName is the name of the dataset
251+
description: DatasetName is the name of the dataset
252252
type: string
253253
endpoint:
254254
description: Endpoint is the HuggingFace endpoint from NeMo
255255
DataStore
256256
pattern: ^https?://.*/v1/hf/?$
257257
type: string
258258
modelName:
259-
description: modelName is the name of the model
259+
description: ModelName is the name of the model
260260
type: string
261261
modelPuller:
262-
description: modelPuller is the containerized huggingface-cli
262+
description: ModelPuller is the containerized huggingface-cli
263263
image to pull the data
264264
minLength: 1
265265
type: string
@@ -268,10 +268,15 @@ spec:
268268
description: Namespace is the namespace within NeMo DataStore
269269
type: string
270270
pullSecret:
271-
description: pullSecret is the name of the image pull secret
271+
description: PullSecret is the name of the image pull secret
272272
for the modelPuller image
273273
minLength: 1
274274
type: string
275+
revision:
276+
description: Revision is the revision of the object to be
277+
cached. This is either a commit hash, branch name or tag.
278+
minLength: 1
279+
type: string
275280
required:
276281
- authSecret
277282
- endpoint
@@ -288,22 +293,22 @@ spec:
288293
Hub
289294
properties:
290295
authSecret:
291-
description: authSecret is the name of the secret containing
296+
description: AuthSecret is the name of the secret containing
292297
the "HF_TOKEN" token
293298
minLength: 1
294299
type: string
295300
datasetName:
296-
description: datasetName is the name of the dataset
301+
description: DatasetName is the name of the dataset
297302
type: string
298303
endpoint:
299304
description: Endpoint is the HuggingFace endpoint
300305
pattern: ^https?://.*$
301306
type: string
302307
modelName:
303-
description: modelName is the name of the model
308+
description: ModelName is the name of the model
304309
type: string
305310
modelPuller:
306-
description: modelPuller is the containerized huggingface-cli
311+
description: ModelPuller is the containerized huggingface-cli
307312
image to pull the data
308313
minLength: 1
309314
type: string
@@ -313,10 +318,15 @@ spec:
313318
minLength: 1
314319
type: string
315320
pullSecret:
316-
description: pullSecret is the name of the image pull secret
321+
description: PullSecret is the name of the image pull secret
317322
for the modelPuller image
318323
minLength: 1
319324
type: string
325+
revision:
326+
description: Revision is the revision of the object to be
327+
cached. This is either a commit hash, branch name or tag.
328+
minLength: 1
329+
type: string
320330
required:
321331
- authSecret
322332
- endpoint
@@ -421,7 +431,10 @@ spec:
421431
description: Storage is the target storage for caching NIM model
422432
properties:
423433
hostPath:
424-
description: HostPath is the host path volume for caching NIM
434+
description: |-
435+
HostPath is the host path volume for caching NIM
436+
437+
Deprecated: use PVC instead.
425438
type: string
426439
pvc:
427440
description: PersistentVolumeClaim is the pvc volume used for

deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nimcaches.yaml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,23 @@ spec:
243243
DataStore service
244244
properties:
245245
authSecret:
246-
description: authSecret is the name of the secret containing
246+
description: AuthSecret is the name of the secret containing
247247
the "HF_TOKEN" token
248248
minLength: 1
249249
type: string
250250
datasetName:
251-
description: datasetName is the name of the dataset
251+
description: DatasetName is the name of the dataset
252252
type: string
253253
endpoint:
254254
description: Endpoint is the HuggingFace endpoint from NeMo
255255
DataStore
256256
pattern: ^https?://.*/v1/hf/?$
257257
type: string
258258
modelName:
259-
description: modelName is the name of the model
259+
description: ModelName is the name of the model
260260
type: string
261261
modelPuller:
262-
description: modelPuller is the containerized huggingface-cli
262+
description: ModelPuller is the containerized huggingface-cli
263263
image to pull the data
264264
minLength: 1
265265
type: string
@@ -268,10 +268,15 @@ spec:
268268
description: Namespace is the namespace within NeMo DataStore
269269
type: string
270270
pullSecret:
271-
description: pullSecret is the name of the image pull secret
271+
description: PullSecret is the name of the image pull secret
272272
for the modelPuller image
273273
minLength: 1
274274
type: string
275+
revision:
276+
description: Revision is the revision of the object to be
277+
cached. This is either a commit hash, branch name or tag.
278+
minLength: 1
279+
type: string
275280
required:
276281
- authSecret
277282
- endpoint
@@ -288,22 +293,22 @@ spec:
288293
Hub
289294
properties:
290295
authSecret:
291-
description: authSecret is the name of the secret containing
296+
description: AuthSecret is the name of the secret containing
292297
the "HF_TOKEN" token
293298
minLength: 1
294299
type: string
295300
datasetName:
296-
description: datasetName is the name of the dataset
301+
description: DatasetName is the name of the dataset
297302
type: string
298303
endpoint:
299304
description: Endpoint is the HuggingFace endpoint
300305
pattern: ^https?://.*$
301306
type: string
302307
modelName:
303-
description: modelName is the name of the model
308+
description: ModelName is the name of the model
304309
type: string
305310
modelPuller:
306-
description: modelPuller is the containerized huggingface-cli
311+
description: ModelPuller is the containerized huggingface-cli
307312
image to pull the data
308313
minLength: 1
309314
type: string
@@ -313,10 +318,15 @@ spec:
313318
minLength: 1
314319
type: string
315320
pullSecret:
316-
description: pullSecret is the name of the image pull secret
321+
description: PullSecret is the name of the image pull secret
317322
for the modelPuller image
318323
minLength: 1
319324
type: string
325+
revision:
326+
description: Revision is the revision of the object to be
327+
cached. This is either a commit hash, branch name or tag.
328+
minLength: 1
329+
type: string
320330
required:
321331
- authSecret
322332
- endpoint
@@ -421,7 +431,10 @@ spec:
421431
description: Storage is the target storage for caching NIM model
422432
properties:
423433
hostPath:
424-
description: HostPath is the host path volume for caching NIM
434+
description: |-
435+
HostPath is the host path volume for caching NIM
436+
437+
Deprecated: use PVC instead.
425438
type: string
426439
pvc:
427440
description: PersistentVolumeClaim is the pvc volume used for

0 commit comments

Comments
 (0)