Kubernetes AI Toolchain Operator (KAITO)
| Coming soon: KAITO v0.5.0. Retrieval-augmented generation (RAG) - RagEngine support with LlamaIndex orchestration and Faiss as the default vectorDB, learn about recent updates here! |
| Latest Release: May 14th, 2025. KAITO v0.4.6. |
| First Release: Nov 15th, 2023. KAITO v0.1.0. |
KAITO is an operator that automates the AI/ML model inference or tuning workload in a Kubernetes cluster.
The target models are popular open-sourced large models such as falcon and phi-3.
KAITO has the following key differentiations compared to most of the mainstream model deployment methodologies built on top of virtual machine infrastructures:
- Manage large model files using container images. An OpenAI-compatible server is provided to perform inference calls.
- Provide preset configurations to avoid adjusting workload parameters based on GPU hardware.
- Provide support for popular open-sourced inference runtimes: vLLM and transformers.
- Auto-provision GPU nodes based on model requirements.
- Host large model images in the public Microsoft Container Registry (MCR) if the license allows.
Using KAITO, the workflow of onboarding large AI inference models in Kubernetes is largely simplified.
Architecture
KAITO follows the classic Kubernetes Custom Resource Definition(CRD)/controller design pattern. User manages a workspace custom resource which describes the GPU requirements and the inference or tuning specification. KAITO controllers will automate the deployment by reconciling the workspace custom resource.
The above figure presents the KAITO architecture overview. Its major components consist of:
- Workspace controller: It reconciles the
workspacecustom resource, createsNodeClaim(explained below) custom resources to trigger node auto provisioning, and creates the inference or tuning workload (deployment,statefulsetorjob) based on the model preset configurations. - Node provisioner controller: The controller's name is gpu-provisioner in gpu-provisioner helm chart. It uses the
NodeClaimCRD originated from Karpenter to interact with the workspace controller. It integrates with Azure Resource Manager REST APIs to add new GPU nodes to the AKS or AKS Arc cluster.
Note: The gpu-provisioner is an open sourced component. It can be replaced by other controllers if they support Karpenter-core APIs.
The above figure presents the RAGEngine architecture overview consisting of:
- RAGEngine controller: It reconciles the
ragenginecustom resource, creating theRAG Service. - RAG Service: This is the service that offer Retrieval Augmented Generation support with LlamaIndex orchestration and leveraging FAISS as the vector DB.
- Local Embedding: An embedding model running locally to embed queries and documents within the vector db.
- Remote Embedding: An optional embedding model running remotely used to embed queries and documents within the vector db.
- FAISS: Facebook AI Similarity Search
For more information on RAGEngine installation and usage, check the docs here.
Installation
Please check the installation guidance here for deployment using Azure CLI and here for deployment using Terraform.
Quick start
After installing KAITO, one can try following commands to start a phi-3.5-mini-instruct inference service.
$ cat examples/inference/kaito_workspace_phi_3.5-instruct.yaml
apiVersion: kaito.sh/v1beta1
kind: Workspace
metadata:
name: workspace-phi-3-5-mini
resource:
instanceType: "Standard_NC24ads_A100_v4"
labelSelector:
matchLabels:
apps: phi-3-5
inference:
preset:
name: phi-3.5-mini-instruct
$ kubectl apply -f examples/inference/kaito_workspace_phi_3.5-instruct.yamlThe workspace status can be tracked by running the following command. When the WORKSPACEREADY column becomes True, the model has been deployed successfully.
$ kubectl get workspace workspace-phi-3-5-mini
NAME INSTANCE RESOURCEREADY INFERENCEREADY JOBSTARTED WORKSPACESUCCEEDED AGE
workspace-phi-3-5-mini Standard_NC24ads_A100_v4 True True True 4h15mNext, one can find the inference service's cluster ip and use a temporal curl pod to test the service endpoint in the cluster.
# find service endpoint
$ kubectl get svc workspace-phi-3-5-mini
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
workspace-phi-3-5-mini ClusterIP <CLUSTERIP> <none> 80/TCP,29500/TCP 10m
$ export CLUSTERIP=$(kubectl get svc workspace-phi-3-5-mini -o jsonpath="{.spec.clusterIPs[0]}")
# find available models
$ kubectl run -it --rm --restart=Never curl --image=curlimages/curl -- curl -s http://$CLUSTERIP/v1/models | jq
{
"object": "list",
"data": [
{
"id": "phi-3.5-mini-instruct",
"object": "model",
"created": 1733370094,
"owned_by": "vllm",
"root": "/workspace/vllm/weights",
"parent": null,
"max_model_len": 16384
}
]
}
# make an inference call using the model id (phi-3.5-mini-instruct) from previous step
$ kubectl run -it --rm --restart=Never curl --image=curlimages/curl -- curl -X POST http://$CLUSTERIP/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "phi-3.5-mini-instruct",
"prompt": "What is kubernetes?",
"max_tokens": 7,
"temperature": 0
}'Usage
The detailed usage for Kaito supported models can be found in HERE. In case users want to deploy their own containerized models, they can provide the pod template in the inference field of the workspace custom resource (please see API definitions for details). The controller will create a deployment workload using all provisioned GPU nodes. Note that currently the controller does NOT handle automatic model upgrade. It only creates inference workloads based on the preset configurations if the workloads do not exist.
The number of the supported models in Kaito is growing! Please check this document to see how to add a new supported model.
Starting with version v0.3.0, Kaito supports model fine-tuning and using fine-tuned adapters in the inference service. Refer to the tuning document and inference document for more information.
FAQ
How do I ensure preferred nodes are correctly labeled for use in my workspace?
For using preferred nodes, make sure the node has the label specified in the labelSelector
under matchLabels. For example, if your labelSelector is:
labelSelector:
matchLabels:
apps: falcon-7b
Then the node should have the label: apps=falcon-7b.
How to upgrade the existing deployment to use the latest model configuration?
When using hosted public models, a user can delete the existing inference workload (Deployment of StatefulSet) manually, and the workspace controller will create a new one with the latest preset configuration (e.g., the image version) defined in the current release. For private models, it is recommended to create a new workspace with a new image version in the Spec.
How to update model/inference parameters to override the KAITO Preset Configuration?
KAITO provides a limited capability to override preset configurations for models that use transformer runtime manually.
To update parameters for a deployed model, perform kubectl edit against the workload, which could be either a StatefulSet or Deployment.
For example, to enable 4-bit quantization on a falcon-7b-instruct deployment, you would execute:
kubectl edit deployment workspace-falcon-7b-instructWithin the deployment specification, locate and modify the command field.
Original
accelerate launch --num_processes 1 --num_machines 1 --machine_rank 0 --gpu_ids all inference_api.py --pipeline text-generation --torch_dtype bfloat16Modify to enable 4-bit Quantization
accelerate launch --num_processes 1 --num_machines 1 --machine_rank 0 --gpu_ids all inference_api.py --pipeline text-generation --torch_dtype bfloat16 --load_in_4bitCurrently, we allow users to change the following paramenters manually:
pipeline: For text-generation models this can be eithertext-generationorconversational.load_in_4bitorload_in_8bit: Model quantization resolution.
Should you need to customize other parameters, kindly file an issue for potential future inclusion.
What is the difference between instruct and non-instruct models?
The main distinction lies in their intended use cases. Instruct models are fine-tuned versions optimized
for interactive chat applications. They are typically the preferred choice for most implementations due to their enhanced performance in
conversational contexts.
On the other hand, non-instruct, or raw models, are designed for further fine-tuning.
Contributing
This project welcomes contributions and suggestions. The contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit CLAs for CNCF.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the CLAs for CNCF, please electronically sign the CLA via
https://easycla.lfx.linuxfoundation.org. If you encounter issues, you can submit a ticket with the
Linux Foundation ID group through the Linux Foundation Support website.
License
See MIT License.
Code of Conduct
KAITO has adopted the Cloud Native Compute Foundation Code of Conduct. For more information see the KAITO Code of Conduct.
Contact
"KAITO devs" kaito-dev@microsoft.com
