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

The IBM watsonx.ai service must be installed. Make sure you have the necessary resources available to support the models that you want to use. For more information about the overall resources that are required for the service, see Hardware requirements. For details about the available foundation models and the extra resources needed to host them, see Foundation models in IBM watsonx.ai.
Important: Before you install a foundation model, make sure your cluster has at least one node with enough available GPUs to run that model.

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

To add foundation models, complete the following steps:
  1. 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.
  2. 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.

    See Sharding the foundation models.

    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.

    See Installing models on GPU partitions.

    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.

    See Installing models 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.

    See Installing embedding models on GPUs.

  3. Confirm that the spec section 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.
  4. Wait for the operator to finish reconciling the changes and show the Completed status. You can use the following command to check the status of the service:
    oc get watsonxaiifm -n ${PROJECT_CPD_INST_OPERANDS}
  5. 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

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

  1. 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_list array, 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"]}}'
    
  2. Text extraction models only:
    1. 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 the pixtral-12b model 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"]}}'
      
    2. 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: 1
      • wdu_page_deploy_distributed_replicas: 1
      • wdu_result_deploy_distributed_replicas: 1
      • wdu_watch_deploy_distributed_replicas: 1
      Medium
      • wdu_api_deploy_distributed_replicas: 2
      • wdu_page_deploy_distributed_replicas: 4
      • wdu_result_deploy_distributed_replicas: 2
      • wdu_watch_deploy_distributed_replicas: 2
      Large
      • wdu_api_deploy_distributed_replicas: 4
      • wdu_page_deploy_distributed_replicas: 8
      • wdu_result_deploy_distributed_replicas: 2
      • wdu_watch_deploy_distributed_replicas: 2
      Note: By default, text extraction runs on pods configured with Small capacity. For better performance, we recommend running text extraction on pods with Medium or Large capacity.
      Run the following command to set the text extraction pod capacity to 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
      }}'

Sharding the foundation models

You can choose to shard a model across multiple GPUs on any available node in the cluster or choose the specific cluster node you want to use for the model.
  1. Verify that the foundation model you want to shard supports sharding. See Foundation models in IBM watsonx.ai.
  2. Do one of the following things:
    Shard the foundation models
    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>}}}}'
    Make the following edits:
    • 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 the llama-3-1-8b-instruct model, 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 are 2, 4, or 8 only. 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.
    Shard the foundation models on specific nodes

    You can specify the node where you want the shards to run by specifying the hostname of the node in the nodeSelector object.

    1. Get a list of the nodes:
      oc get nodes
    2. Check the label for the node that you want to use:
      oc describe no <node-name> | grep kubernetes.io/hostname
    3. Verify that the node has a GPU by using the following command. Foundation models can be sharded on GPU nodes only.
      oc describe node <node-hostname> | grep nvidia.com/gpu.product
      A GPU node returns nvidia.com/gpu.product=true.
    4. Run the following command to patch the custom resource:
      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>"}}}}}'
      Make the following edits:
      • 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 the llama-3-1-8b-instruct model, 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 are 2, 4, or 8 only. 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 nodeSelector object. For example, "nodeSelector":{"kubernetes.io/hostname":"worker0.example.com"}
    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"}}}}}'

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.

Complete the following steps:
  1. 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.
  2. You can set the nodeSelector object in the following ways to select a specific cluster node to host your models:
    Use the MIG profile label
    1. Get a list of the nodes:
      oc get nodes
    2. Check the MIG profile label for the NVIDIA Multi-Instance GPU node that you want to use with the following command:
      oc describe node <node-name> | grep nvidia.com/mig.config
      For example:
      oc describe node worker10.wxai.example.com | grep nvidia.com/mig.config=
      nvidia.com/mig.config=all-3g.40gb
    3. Run the following command to patch the custom resource:
      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>"}}}}}'
      Make the following edits:
      • 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 nodeSelector object. For example, "nodeSelector":{"nvidia.com/mig.config":"all-3g.40gb"}
    Use the GPU type label
    1. 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
    2. Run the following command to patch the custom resource:
      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>"}}}}}'
      Make the following edits:
      • 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 nodeSelector object. For example, "nodeSelector":{"nvidia.com/gpu.product":"NVIDIA-A100-SXM4-80GB"}
  3. codestral-2501 model only: To configure the codestral-2501 to 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
  4. 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}
  5. 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-xxl
    • meta-llama-llama-2-13b-chat
    • mncai-llama2-13b-dpo-v7
    • bigscience-mt0-xxl
    Edit the following environment variables for each of these models that you install:
    • ESTIMATE_MEMORY_BATCH_SIZE=4
    • ESTIMATE_MEMORY=off
    You can use the following script to make the required environment variable changes per model. First specify the model ID to set in the $model_id variable.
    #!/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

To install models on Intel Gaudi 3 AI Accelerator, you will need to add the section for the specific model into the custom resource (CR) for watsonx.ai.
Attention: If you want to install the Intel Gaudi 3 AI Accelerator operator on Red Hat® OpenShift®, see Intel Gaudi - OpenShift Installation.
Based on the model you want to install, run the following commands on an Intel Gaudi 3 AI Accelerator cluster:
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

You can choose to run an embedding model on GPU nodes in the following ways:
Override the model resources and requests GPU
Run the following command to modify the custom resource:
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}}}}'
Make the following edits:
  • 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-rtrvr model ID, specify ibm_slate_30m_english_rtrvr.
Specify MIG nodes with the nodeSelector attribute
Run the following command to modify the custom resource:
oc patch watsonxaiifm watsonxaiifm-cr \
--namespace=${PROJECT_CPD_INST_OPERANDS} \
--type=merge \
--patch='{"spec": {"model_install_parameters": {"<model_id_with_underscore>":{"nodeSelector": <node-label>}}}}'
Make the following edits:
  • 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 the ibm-slate-30m-english-rtrvr model ID, specify ibm_slate_30m_english_rtrvr.
  • Specify the node label in the nodeSelector object. For example, "nodeSelector":{"kubernetes.io/hostname":"gpu-node-1"}

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.