Chapter 6. Deploying Red Hat AI Inference Server on IBM Z with IBM Spyre accelerators
Deploy a language model on OpenShift Container Platform running on IBM Z with IBM Spyre AI accelerators. You configure secrets, persistent storage, and a deployment custom resource (CR) that pulls the model from Hugging Face and uses Red Hat AI Inference Server to inference serve the model.
For more information about installing the Spyre Operator, see the Spyre Operator for Z and LinuxONE User’s Guide.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in as a user with
cluster-adminprivileges. - Your cluster deployed on IBM Z has worker nodes with IBM Spyre AI accelerators installed.
- You have installed the IBM Spyre Operator in the cluster. For more information, see Installing the Spyre Operator.
- You have a Hugging Face account and have generated a Hugging Face access token.
-
You have access to
registry.redhat.ioand the cluster can pull images from this registry.
IBM Spyre AI accelerator cards support FP16 format model weights only. For compatible models, the Red Hat AI Inference Server inference engine automatically converts weights to FP16 at startup. No additional configuration is needed.
Procedure
Create the
Secretcustom resource (CR) for the Hugging Face token. The cluster uses theSecretCR to pull models from Hugging Face.Set the
HF_TOKENvariable using the token you set in Hugging Face:HF_TOKEN=<your_huggingface_token>
$ HF_TOKEN=<your_huggingface_token>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the cluster namespace to match where you deployed the Red Hat AI Inference Server image, for example:
NAMESPACE=rhaiis-namespace
$ NAMESPACE=rhaiis-namespaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
SecretCR in the cluster:oc create secret generic hf-secret --from-literal=HF_TOKEN=$HF_TOKEN -n $NAMESPACE
$ oc create secret generic hf-secret --from-literal=HF_TOKEN=$HF_TOKEN -n $NAMESPACECopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the Docker secret so that the cluster can download the Red Hat AI Inference Server image from the container registry. For example, to create a
SecretCR that contains the contents of your local~/.docker/config.jsonfile, run the following command:oc create secret generic docker-secret --from-file=.dockercfg=$HOME/.docker/config.json --type=kubernetes.io/dockercfg -n rhaiis-namespace
$ oc create secret generic docker-secret --from-file=.dockercfg=$HOME/.docker/config.json --type=kubernetes.io/dockercfg -n rhaiis-namespaceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
PersistentVolumeClaim(PVC) custom resource (CR) and apply it in the cluster. The following examplePVCCR uses a default IBM VPC Block persistence volume. You use thePVCas the location where you store the models that you download.Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteConfiguring cluster storage to meet your requirements is outside the scope of this procedure. For more detailed information, see Configuring persistent storage.
Create a
Deploymentcustom resource (CR) that pulls the model from Hugging Face and deploys the Red Hat AI Inference Server container. Reference the following exampleDeploymentCR, which uses AI Inference Server to serve a Granite model with IBM Spyre AI accelerators.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where:
namespace: rhaiis-namespace-
Specifies the deployment namespace. The value of
metadata.namespacemust match the namespace where you configured the Hugging FaceSecretCR. claimName: model-cache-
Specifies the persistent volume claim name. The value of
spec.template.spec.volumes.persistentVolumeClaim.claimNamemust match the name of thePVCthat you created. initContainers-
Defines a container that runs before the main application container to download the required model from Hugging Face by using the
huggingface_hubPython library. The model download step is skipped if the model directory has already been populated, for example, from a previous deployment. FLEX_DEVICE-
Specifies the device type for IBM Spyre accelerators. Set to
VFfor virtual function mode. TOKENIZERS_PARALLELISM- Disables tokenizer parallelism to prevent resource conflicts.
VLLM_SPYRE_USE_CB- Enables continuous batching for improved throughput on IBM Spyre accelerators.
VLLM_SPYRE_REQUIRE_PRECOMPILED_DECODERS- Requires precompiled decoders for optimal performance on Spyre accelerators.
TORCH_SENDNN_CACHE_ENABLE- Enables caching for the SendNN backend to improve model loading times.
ibm.com/spyre_vf- Requests IBM Spyre virtual function devices from the cluster. The number specifies how many Spyre AI accelerator devices to allocate.
mountPath: /dev/shm- Mounts the shared memory volume required for tensor parallel inference across multiple Spyre accelerators.
Increase the deployment replica count to the required number.
oc scale deployment granite-spyre -n rhaiis-namespace --replicas=1
$ oc scale deployment granite-spyre -n rhaiis-namespace --replicas=1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Watch the deployment and ensure that it succeeds, for example:
oc get deployment -n rhaiis-namespace --watch
$ oc get deployment -n rhaiis-namespace --watchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
NAME READY UP-TO-DATE AVAILABLE AGE granite-spyre 0/1 1 0 2s granite-spyre 1/1 1 1 5m
NAME READY UP-TO-DATE AVAILABLE AGE granite-spyre 0/1 1 0 2s granite-spyre 1/1 1 1 5mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
ServiceCR for the model inference. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Notespec.selector.appmust match the label in yourDeploymentpod.Optional: Create a
RouteCR to enable public access to the model with TLS encryption. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the URL for the exposed route. Run the following command:
oc get route granite-spyre -n rhaiis-namespace -o jsonpath='{.spec.host}'$ oc get route granite-spyre -n rhaiis-namespace -o jsonpath='{.spec.host}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
granite-spyre-rhaiis-namespace.apps.example.com
granite-spyre-rhaiis-namespace.apps.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Ensure that the deployment is successful by querying the model. Run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow