Adding foundation models to IBM watsonx.ai
To submit input to a foundation model or text embedding model from IBM watsonx.ai, you must deploy the models that you want to use in your cluster.
Before you begin
If you are upgrading the software and foundation models are already installed that you want to
continue to use, you can do so even when the installed models are deprecated or withdrawn in the new
release. For more information, see Foundation model lifecycle. When you list the new models that you
want to add to the install_model_list field, be sure to include the model IDs for
any existing models that you want to continue to use.
To complete this task the first time, you must be the instance administrator who installed the IBM watsonx.ai service.
You can add foundation models that are curated by IBM to a full installation or lightweight engine installation.
Procedure
- Decide which models you want to use, and then make a note of their model IDs.Tip: Due to the large resource demands of foundation models, install only the models that you want to use right away at the time that the service is installed. You can add more models later.5.2.1 and later To access the ibm-defense-3-3-8b-instruct model, you must re-create the required OLM objects for IBM watsonx.ai in the operators project for the instance after 15 September 2025. For details, see step 2 in the Installing IBM watsonx.ai procedure.
- Choose how you want to install the foundation models from the following options:
- Install with default configuration
- Simplest installation option where models are installed on available resources. Some foundation
models are sharded as part of their standard configuration. The number of GPUs specified per model
in the table in Foundation models in IBM
watsonx.ai
indicates the number of shards used.
See Installing models with the default configuration.
Note: Use this method for adding embedding and reranker models. You cannot shard embedding or reranker models. Use this method for adding the models that support text extraction also. - Shard the foundation models during installation
- You can use sharding to partition large models into smaller units, known as shards, that can be processed across multiple GPU processors in parallel. Sharding foundation models can improve performance and also reduces the amount of memory needed for each GPU.
- Install foundation models on preconfigured GPU partitions
- Partitioning GPU processors lets you install more than one smaller model on a single GPU to use
resources more efficiently.Important: Not all foundation models can be sharded or installed on partitioned GPU processors. See Foundation models in IBM watsonx.ai for details.
- Install foundation models on Intel Gaudi 3 AI Accelerator GPUs
- A subset of foundation models provided in IBM watsonx.ai can be installed on Intel Gaudi 3 AI Accelerator GPUs.
- Install embedding models on GPUs
- For better performance while vectorizing text, you can configure embedding models to run on GPUs for better performance.
- Confirm that the
specsection of the watsonxaiifm custom resource is updated by running the following command:oc describe watsonxaiifm watsonxaiifm-cr -n ${PROJECT_CPD_INST_OPERANDS}Important: Do not edit the custom resource directly because it is easy to introduce errors. - Wait for the operator to finish reconciling the changes and show the
Completedstatus. You can use the following command to check the status of the service:oc get watsonxaiifm -n ${PROJECT_CPD_INST_OPERANDS} - Use the following commands to check whether your changes were applied successfully.
- To check whether the model predictor pod is
running:
oc get po -n ${PROJECT_CPD_INST_OPERANDS} | grep predictor - To check whether the predictor pod shows the correct number of GPU processors. If you specified
a node selector, you can also check the value of the Node-Selectors
field.
oc describe po <model-predictor-pod> -n ${PROJECT_CPD_INST_OPERANDS} - To check which node a foundation model is
using:
oc get po -n ${PROJECT_CPD_INST_OPERANDS} -o wide | grep predictor
- To check whether the model predictor pod is
running:
You can add additional models as required at any point after the initial service setup. You can also remove or change the sharding settings later. For more information, see Changing model sharding configuration in IBM watsonx.ai.
Installing models with the default configuration
- Run the following command to modify the custom
resource:
oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec":{"install_model_list": ["<model-id1>","<model-id2>"]}}'In the
install_model_listarray, list the IDs for the models that you want to use. Separate the model IDs with commas as follows:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec":{"install_model_list": ["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2"]}}' - Text extraction models only:
- To use the text extraction API, run the following command to install a set of machine learning
models that do the natural language understanding processing during the text extraction
process:
oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec":{"install_model_list": ["wdu"]}}'To use the text extraction API to extract key-value pair data from your documents, install thepixtral-12bmodel in addition to the set of machine learning models with the following command:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec":{"install_model_list": ["wdu", "pixtral-12b"]}}' - The text extraction models are installed on a separate pod on the cluster. Choose from the
following pod configuration options based on your usage:
Text extraction pod capacity Custom resource settings Small wdu_api_deploy_distributed_replicas: 1wdu_page_deploy_distributed_replicas: 1wdu_result_deploy_distributed_replicas: 1wdu_watch_deploy_distributed_replicas: 1
Medium wdu_api_deploy_distributed_replicas: 2wdu_page_deploy_distributed_replicas: 4wdu_result_deploy_distributed_replicas: 2wdu_watch_deploy_distributed_replicas: 2
Large wdu_api_deploy_distributed_replicas: 4wdu_page_deploy_distributed_replicas: 8wdu_result_deploy_distributed_replicas: 2wdu_watch_deploy_distributed_replicas: 2
Note: By default, text extraction runs on pods configured withRun the following command to set the text extraction pod capacity toSmallcapacity. For better performance, we recommend running text extraction on pods withMediumorLargecapacity.Medium:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ -p '{"spec": {"wdu_api_deploy_distributed_replicas": 2, "wdu_page_deploy_distributed_replicas": 4, "wdu_result_deploy_distributed_replicas": 2, "wdu_watch_deploy_distributed_replicas": 2 }}'
- To use the text extraction API, run the following command to install a set of machine learning
models that do the natural language understanding processing during the text extraction
process:
Sharding the foundation models
- Verify that the foundation model you want to shard supports sharding. See Foundation models in IBM watsonx.ai.
- Do one of the following things:
- Shard the foundation models
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["<model-id>"], "model_install_parameters": {"<model_id_with_underscore>":{"shard": <shard-value>}}}}'- Specify the models that you want to use in a comma-separated list in
install_model_list. For example,["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2"]. - Specify each model that you want to shard by specifying the model ID, but
use underscores instead of hyphens in the model ID in
model_install_parameters. For example, for thellama-3-1-8b-instructmodel, specify"llama_3_1_8b_instruct". - Assign a shard value to each model in
model_install_parameters. The shard value specifies the number of units in which to split the model. Accepted shard values are2,4, or8only. If you specify a value other than one of these accepted values, the default shard value (number of GPUs) for the model is used. No message is shown to inform you that your configuration change is not applied.
For example, the following patch adds the llama-3-1-8b-instruct and granite-13b-chat-v2 foundation models along with the models that are required for the text extraction feature:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2","wdu"], "model_install_parameters": {"ibm_granite_13b_chat_v2":{"shard": 2}}}}'Important: Do not edit the custom resource directly because it is easy to introduce errors.- Specify the models that you want to use in a comma-separated list in
- Shard the foundation models on specific nodes
-
You can specify the node where you want the shards to run by specifying the
hostnameof the node in thenodeSelectorobject.- Get a list of the nodes:
oc get nodes - Check the label for the node that you want to
use:
oc describe no <node-name> | grep kubernetes.io/hostname - Verify that the node has a GPU by using the following command. Foundation models can be sharded
on GPU nodes
only.
A GPU node returnsoc describe node <node-hostname> | grep nvidia.com/gpu.productnvidia.com/gpu.product=true. - Run the following command to patch the custom
resource:
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["<model-id>"], "model_install_parameters": {"<model_id_with_underscore>":{"shard": <shard-value>, "nodeSelector":{"kubernetes.io/hostname": "<hostname-value>"}}}}}'- Specify the models that you want to use in a comma-separated list in
install_model_list. For example,["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2"]. - Specify each model that you want to shard by specifying the model ID, but
use underscores instead of hyphens in the model ID in
model_install_parameters. For example, for thellama-3-1-8b-instructmodel, specify"llama_3_1_8b_instruct". - Assign a shard value to each model in
model_install_parameters. The shard value specifies the number of units in which to split the model. Accepted shard values are2,4, or8only. If you specify a value other than one of these accepted values, the default shard value (number of GPUs) for the model is used. No message is shown to inform you that your configuration change is not applied. - For each shard that you want to host on a specific node, specify the node hostname value in the
nodeSelectorobject. For example,"nodeSelector":{"kubernetes.io/hostname":"worker0.example.com"}
- Specify the models that you want to use in a comma-separated list in
For example:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["meta-llama-llama-3-8b-instruct","ibm-granite-13b-chat-v2"], "model_install_parameters": {"ibm_granite_13b_chat_v2":{"shard": 2, "nodeSelector":{"kubernetes.io/hostname": "worker0.example.com"}}}}}' - Get a list of the nodes:
Installing models on GPU partitions
You can specify the NVIDIA Multi-Instance GPU (MIG) node where you want the foundation models to
run by specifying the hostname of the node where MIG is configured in the
nodeSelector object.
- Verify that the foundation model you want to install supports being installed on an NVIDIA Multi-Instance GPU. See Foundation models in IBM watsonx.ai.
- You can set the
nodeSelectorobject in the following ways to select a specific cluster node to host your models:- Use the MIG profile label
-
- Get a list of the nodes:
oc get nodes - Check the MIG profile label for the
NVIDIA Multi-Instance GPU node that you want to use with the
following
command:
For example:oc describe node <node-name> | grep nvidia.com/mig.configoc describe node worker10.wxai.example.com | grep nvidia.com/mig.config= nvidia.com/mig.config=all-3g.40gb - Run the following command to patch the custom
resource:
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["<model-id>"], "model_install_parameters": {"<model_id_with_underscore>":{"nodeSelector":{"nvidia.com/mig.config": "<mig-label>"}}}}}'- Specify the models that you want to use in a comma-separated list in
install_model_list. For example,["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2"]. - Specify the node label in the
nodeSelectorobject. For example,"nodeSelector":{"nvidia.com/mig.config":"all-3g.40gb"}
- Specify the models that you want to use in a comma-separated list in
- Get a list of the nodes:
- Use the GPU type label
-
- Get a list of product labels for the different types of NVIDIA Multi-Instance GPU nodes in your
cluster:
oc get nodes -L nvidia.com/gpu.product - Run the following command to patch the custom
resource:
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type merge \ --patch '{"spec": {"install_model_list":["<model-id>"], "model_install_parameters": {"<model_id_with_underscore>":{"nodeSelector":{"nvidia.com/gpu.product": "<product-label>"}}}}}'- Specify the models that you want to use in a comma-separated list in
install_model_list. For example,["llama-3-1-8b-instruct","ibm-granite-13b-chat-v2"]. - Specify the node label in the
nodeSelectorobject. For example,"nodeSelector":{"nvidia.com/gpu.product":"NVIDIA-A100-SXM4-80GB"}
- Specify the models that you want to use in a comma-separated list in
- Get a list of product labels for the different types of NVIDIA Multi-Instance GPU nodes in your
cluster:
codestral-2501model only: To configure thecodestral-2501to run on a MIG node you must set the context window length to 28,672 tokens.- Set the SERVICE_VERSION environment variable to the watsonx.ai™ service operand
version.
export SERVICE_VERSION=<watsonxai-service-operand-version> - Use the following command to patch the custom
resource:
cat <<EOF | oc apply -f - apiVersion: watsonxaiifm.cpd.ibm.com/v1beta1 kind: Watsonxaiifm metadata: name: watsonxaiifm-cr namespace: ${PROJECT_CPD_INST_OPERANDS} spec: blockStorageClass: ocs-storagecluster-ceph-rbd install_model_list: - codestral-2501 fileStorageClass: ocs-storagecluster-cephfs license: accept: true version: ${SERVICE_VERSION} model_install_parameters: codestral_2501: env: - name: MODEL_NAME value: /mnt/models/codestral-2501 - name: SERVED_MODEL_NAME value: mistralai/codestral-2501 - name: MAX_NUM_SEQS value: "8" - name: MAX_NEW_TOKENS value: "8192" - name: MAX_SEQUENCE_LENGTH value: "28672" - name: DISABLE_PROMPT_LOGPROBS value: "true" - name: TOKENIZER_MODE value: mistral - name: LOAD_FORMAT value: mistral - name: CONFIG_FORMAT value: mistral - name: ENABLE_PREFIX_CACHING value: "1" - name: NUM_GPUS value: "1" - name: CUDA_VISIBLE_DEVICES value: "0" - name: HUGGINGFACE_HUB_CACHE value: /mnt/models/ - name: HF_MODULES_CACHE value: /tmp/huggingface/modules - name: PORT value: "3000" - name: MAX_LOG_LEN value: "100" - name: GPRC_PORT value: "8033" - name: ENABLE_VLLM_LOG_REQUESTS value: "TRUE" EOF
- Set the SERVICE_VERSION environment variable to the watsonx.ai™ service operand
version.
- Wait for the patch to be applied. You can check the status by using the following
command:
oc get watsonxaiifm watsonxaiifm-cr -n ${PROJECT_CPD_INST_OPERANDS} - If you are installing any of the following foundation models, which are listed by model ID, you
must take an additional step.
google-flan-t5-xxlmeta-llama-llama-2-13b-chatmncai-llama2-13b-dpo-v7bigscience-mt0-xxl
- ESTIMATE_MEMORY_BATCH_SIZE=4
- ESTIMATE_MEMORY=off
$model_idvariable.#!/bin/bash export model_id=<replace with model ID> export PROJECT_CPD_INST_OPERANDS=<replace with instance-namespace> export current_envs=$(oc get isvc $model_id -n $PROJECT_CPD_INST_OPERANDS -ojsonpath='{.spec.predictor.model.env}') memory_batch_check=$(echo $current_envs | jq 'map(select(.name == "ESTIMATE_MEMORY_BATCH_SIZE" and .value == "4")) | length > 0') estimate_memory_check=$(echo $current_envs | jq 'map(select(.name == "ESTIMATE_MEMORY" and .value == "off")) | length > 0') if [ "$memory_batch_check" = "false" ]; then oc patch InferenceService $model_id -n $PROJECT_CPD_INST_OPERANDS \ --type=json \ -p='[{"op": "add", "path": "/spec/predictor/model/env/-", "value": {"name":"ESTIMATE_MEMORY_BATCH_SIZE","value":"4"}}]' ; fi if [ "$estimate_memory_check" = "false" ]; then oc patch InferenceService $model_id -n $PROJECT_CPD_INST_OPERANDS \ --type=json \ -p='[{"op": "add", "path": "/spec/predictor/model/env/-", "value": {"name":"ESTIMATE_MEMORY","value":"off"}}]' ; fi
Installing models on Intel Gaudi 3 AI Accelerator GPUs
- codestral-22b
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"codestral_22b": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-3-2-8b-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_3_2_8b_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-34b-code-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_34b_code_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-20b-code-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_20b_code_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-8b-code-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_8b_code_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-3b-code-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_3b_code_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-3-8b-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_3_8b_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - granite-guardian-3-2b
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"granite_guardian_3_2b": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - llama-3-2-3b-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"llama_3_2_3b_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - llama-3-2-1b-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"llama_3_2_1b_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}} - llama-3-1-8b-instruct
-
oc patch watsonxaiifm watsonxaiifm-cr --type merge -p '{"spec":{"model_install_parameters": {"llama_3_1_8b_instruct": {"image": "quay.io/modh/vllm:rhoai-2.21-gaudi", "accelerator_vendor": "gaudi"}}}}
Installing embedding models on GPUs
- Override the model resources and requests GPU
- Run the following command to modify the custom
resource:
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec":{"<model_id_with_underscore>_replicas": 1, "<model_id_with_underscore>_resources": {"limits": {"cpu": "2", "memory": "4Gi", "nvidia.com/gpu": 1}, "requests": {"cpu": "1", "memory": "4Gi", "nvidia.com/gpu": 1}}}}'- Specify each embedding model for which you want to override resources by specifying the model
ID, but use underscores instead of hyphens in the model ID. For example, for the
ibm-slate-30m-english-rtrvrmodel ID, specifyibm_slate_30m_english_rtrvr.
- Specify each embedding model for which you want to override resources by specifying the model
ID, but use underscores instead of hyphens in the model ID. For example, for the
- Specify MIG nodes with the
nodeSelectorattribute - Run the following command to modify the custom
resource:
Make the following edits:oc patch watsonxaiifm watsonxaiifm-cr \ --namespace=${PROJECT_CPD_INST_OPERANDS} \ --type=merge \ --patch='{"spec": {"model_install_parameters": {"<model_id_with_underscore>":{"nodeSelector": <node-label>}}}}'- Specify each embedding model that you want to configure to run on GPUs by specifying the model
ID, but use underscores instead of hyphens in the model ID in
model_install_parameters. For example, for theibm-slate-30m-english-rtrvrmodel ID, specifyibm_slate_30m_english_rtrvr. - Specify the node label in the
nodeSelectorobject. For example,"nodeSelector":{"kubernetes.io/hostname":"gpu-node-1"}
- Specify each embedding model that you want to configure to run on GPUs by specifying the model
ID, but use underscores instead of hyphens in the model ID in
What to do next
IBM watsonx.ai is ready to use. To start working with the various foundation models and tools, see Getting started with IBM watsonx.ai.