Skip to content

Commit

Permalink
feat: add NIM flag in Operator (#1420)
Browse files Browse the repository at this point in the history
* feat: add NIM flag in Operator

- API change
- add function in modelcontroller
- only when kserve is managed and its nim is managed, we set nim-state to managed
- use newer branch of serving which has the new params.env

---------

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Dec 5, 2024
1 parent d4f72fa commit 6f59682
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ spec:
managementState: Managed
kserve:
managementState: Managed
nim:
managementState: Managed
serving:
ingressGateway:
certificate:
Expand Down
10 changes: 10 additions & 0 deletions apis/components/v1alpha1/kserve_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/opendatahub-io/opendatahub-operator/v2/apis/common"
Expand Down Expand Up @@ -52,6 +53,15 @@ type KserveCommonSpec struct {
// This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode.
// +kubebuilder:validation:Enum=Serverless;RawDeployment
DefaultDeploymentMode DefaultDeploymentMode `json:"defaultDeploymentMode,omitempty"`
// Configures and enables NVIDIA NIM integration
NIM NimSpec `json:"nim,omitempty"`
}

// nimSpec enables NVIDIA NIM integration
type NimSpec struct {
// +kubebuilder:validation:Enum=Managed;Removed
// +kubebuilder:default=Managed
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
}

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
Expand Down
1 change: 1 addition & 0 deletions apis/components/v1alpha1/modelcontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type ModelControllerSpec struct {
// a mini version of the DSCKserve only keep devflags and management spec
type ModelControllerKerveSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
NIM NimSpec `json:"nim,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

Expand Down
17 changes: 17 additions & 0 deletions apis/components/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bundle/manifests/components.platform.opendatahub.io_kserves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ spec:
type: object
type: array
type: object
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ spec:
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: nimSpec enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
type: object
modelMeshServing:
description: a mini version of the DSCModelMeshServing only keep devflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ spec:
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ metadata:
},
"kserve": {
"managementState": "Managed",
"nim": {
"managementState": "Managed"
},
"serving": {
"ingressGateway": {
"certificate": {
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/components.platform.opendatahub.io_kserves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ spec:
type: object
type: array
type: object
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ spec:
managementState:
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: nimSpec enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
type: object
modelMeshServing:
description: a mini version of the DSCModelMeshServing only keep devflags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ spec:
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
nim:
description: Configures and enables NVIDIA NIM integration
properties:
managementState:
default: Managed
enum:
- Managed
- Removed
pattern: ^(Managed|Unmanaged|Force|Removed)$
type: string
type: object
serving:
description: |-
Serving configures the KNative-Serving stack used for model serving. A Service
Expand Down
3 changes: 3 additions & 0 deletions config/samples/datasciencecluster_v1_datasciencecluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
managementState: "Managed"
kserve: {
managementState: "Managed",
nim: {
managementState: "Managed"
},
serving: {
ingressGateway: {
certificate: {
Expand Down
1 change: 1 addition & 0 deletions controllers/components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() { //nolint:gochecknoinits
cr.Add(&componentHandler{})
}

// Init for set images.
func (s *componentHandler) Init(platform cluster.Platform) error {
return nil
}
Expand Down
7 changes: 3 additions & 4 deletions controllers/components/modelcontroller/modelcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const (
ComponentName = componentApi.ModelControllerComponentName
)

var DefaultPath = odhdeploy.DefaultManifestPath + "/" + ComponentName + "/base"

type componentHandler struct{}

func init() { //nolint:gochecknoinits
Expand Down Expand Up @@ -61,24 +63,21 @@ func (s *componentHandler) NewCRObject(dsc *dscv1.DataScienceCluster) client.Obj
Annotations: mcAnnotations,
},
Spec: componentApi.ModelControllerSpec{
// ModelMeshServing: &componentsv1.DSCModelMeshServing {
// dsc.Spec.Components.ModelMeshServing,
// },
ModelMeshServing: &componentApi.ModelControllerMMSpec{
ManagementState: mState,
DevFlagsSpec: dsc.Spec.Components.ModelMeshServing.DevFlagsSpec,
},
Kserve: &componentApi.ModelControllerKerveSpec{
ManagementState: kState,
DevFlagsSpec: dsc.Spec.Components.Kserve.DevFlagsSpec,
NIM: dsc.Spec.Components.Kserve.NIM,
},
},
})
}

// Init for set images.
func (s *componentHandler) Init(platform cluster.Platform) error {
DefaultPath := odhdeploy.DefaultManifestPath + "/" + ComponentName + "/base"
var imageParamMap = map[string]string{
"odh-model-controller": "RELATED_IMAGE_ODH_MODEL_CONTROLLER_IMAGE",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

func initialize(ctx context.Context, rr *odhtypes.ReconciliationRequest) error {
// early exist
_, ok := rr.Instance.(*componentApi.ModelController)
mc, ok := rr.Instance.(*componentApi.ModelController)
if !ok {
return fmt.Errorf("resource instance %v is not a componentApi.ModelController)", rr.Instance)
}
Expand All @@ -41,6 +41,18 @@ func initialize(ctx context.Context, rr *odhtypes.ReconciliationRequest) error {
ContextDir: ComponentName,
SourcePath: "base",
})

nimState := operatorv1.Removed
if mc.Spec.Kserve.ManagementState == operatorv1.Managed {
nimState = mc.Spec.Kserve.NIM.ManagementState
}
extraParamsMap := map[string]string{
"nim-state": strings.ToLower(string(nimState)),
}
if err := odhdeploy.ApplyParams(rr.Manifests[0].String(), nil, extraParamsMap); err != nil {
return fmt.Errorf("failed to update images on path %s: %w", rr.Manifests[0].String(), err)
}

return nil
}

Expand Down
23 changes: 23 additions & 0 deletions docs/api-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ _Appears in:_
| `devFlags` _[DevFlags](#devflags)_ | Add developer fields | | |
| `serving` _[ServingSpec](#servingspec)_ | Serving configures the KNative-Serving stack used for model serving. A Service<br />Mesh (Istio) is prerequisite, since it is used as networking layer. | | |
| `defaultDeploymentMode` _[DefaultDeploymentMode](#defaultdeploymentmode)_ | Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.<br />The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.<br />This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode. | | Enum: [Serverless RawDeployment] <br />Pattern: `^(Serverless\|RawDeployment)$` <br /> |
| `nim` _[NimSpec](#nimspec)_ | Configures and enables NVIDIA NIM integration | | |


#### DSCKueue
Expand Down Expand Up @@ -585,6 +586,7 @@ _Appears in:_
| `devFlags` _[DevFlags](#devflags)_ | Add developer fields | | |
| `serving` _[ServingSpec](#servingspec)_ | Serving configures the KNative-Serving stack used for model serving. A Service<br />Mesh (Istio) is prerequisite, since it is used as networking layer. | | |
| `defaultDeploymentMode` _[DefaultDeploymentMode](#defaultdeploymentmode)_ | Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.<br />The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.<br />This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode. | | Enum: [Serverless RawDeployment] <br />Pattern: `^(Serverless\|RawDeployment)$` <br /> |
| `nim` _[NimSpec](#nimspec)_ | Configures and enables NVIDIA NIM integration | | |


#### KserveList
Expand Down Expand Up @@ -623,6 +625,7 @@ _Appears in:_
| `devFlags` _[DevFlags](#devflags)_ | Add developer fields | | |
| `serving` _[ServingSpec](#servingspec)_ | Serving configures the KNative-Serving stack used for model serving. A Service<br />Mesh (Istio) is prerequisite, since it is used as networking layer. | | |
| `defaultDeploymentMode` _[DefaultDeploymentMode](#defaultdeploymentmode)_ | Configures the default deployment mode for Kserve. This can be set to 'Serverless' or 'RawDeployment'.<br />The value specified in this field will be used to set the default deployment mode in the 'inferenceservice-config' configmap for Kserve.<br />This field is optional. If no default deployment mode is specified, Kserve will use Serverless mode. | | Enum: [Serverless RawDeployment] <br />Pattern: `^(Serverless\|RawDeployment)$` <br /> |
| `nim` _[NimSpec](#nimspec)_ | Configures and enables NVIDIA NIM integration | | |


#### KserveStatus
Expand Down Expand Up @@ -772,6 +775,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `managementState` _[ManagementState](#managementstate)_ | | | |
| `nim` _[NimSpec](#nimspec)_ | | | |
| `devFlags` _[DevFlags](#devflags)_ | Add developer fields | | |


Expand Down Expand Up @@ -1037,6 +1041,25 @@ _Appears in:_
| `registriesNamespace` _string_ | | | |


#### NimSpec



nimSpec enables NVIDIA NIM integration



_Appears in:_
- [DSCKserve](#dsckserve)
- [KserveCommonSpec](#kservecommonspec)
- [KserveSpec](#kservespec)
- [ModelControllerKerveSpec](#modelcontrollerkervespec)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `managementState` _[ManagementState](#managementstate)_ | | Managed | Enum: [Managed Removed] <br /> |


#### Ray


Expand Down
4 changes: 2 additions & 2 deletions get_all_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ declare -A COMPONENT_MANIFESTS=(
["notebooks"]="opendatahub-io:notebooks:main:manifests:notebooks"
["trustyai"]="trustyai-explainability:trustyai-service-operator:main:config:trustyai-service-operator"
["model-mesh"]="opendatahub-io:modelmesh-serving:release-0.12.0-rc0:config:model-mesh"
["odh-model-controller"]="opendatahub-io:odh-model-controller:release-0.12.0:config:odh-model-controller"
["kserve"]="opendatahub-io:kserve:release-v0.12.1:config:kserve"
["odh-model-controller"]="opendatahub-io:odh-model-controller:incubating:config:odh-model-controller"
["kserve"]="opendatahub-io:kserve:release-v0.14:config:kserve"
["modelregistry"]="opendatahub-io:model-registry-operator:main:config:model-registry-operator"
["trainingoperator"]="opendatahub-io:training-operator:dev:manifests:trainingoperator"
)
Expand Down

0 comments on commit 6f59682

Please sign in to comment.