Skip to main content
This guide shows how to configure GPU sharing with KAI and Kubex Automation Engine. This guide was tested with KAI v0.17.0 and HAMi-core 1.1.0-chart.
[!IMPORTANT] GPU/KAI fields and related custom resources are experimental and subject to breaking changes. Set spec.experimental.gpuKaiContract: v1alpha1-2026-07 on GPU/KAI resources.

Prerequisites

  • KAI is already installed in the cluster. KAI installation instructions
    • Kubex has been tested with KAI version v0.17.0.
  • kubex-crds, kubex-automation-engine, and kubex-automation-stack are already installed.
    • The kubex-automation-engine release must enable webhook.podMutation.additionalWebhook.enabled as shown below.
    • When using ClusterGpuReactivePolicy or GpuReactivePolicy, Prometheus must be available for GPU metrics, typically via kubex-automation-stack.
    • If Prometheus runs at a different endpoint, set globalConfiguration.prometheus.url to the custom URL.
This guide works with either of the following:
  • A new KAI installation.
  • An existing KAI installation.
For existing KAI-managed workloads, Kubex Automation Engine can update the gpu-fraction annotation without replacing the existing kai.scheduler/queue label.

Required Kubex webhook values

KAI relies on resource information updated by Kubex when making admission decisions. Before deploying the KAI-managed workloads described in this guide, configure the kubex-automation-engine Helm release with the additional webhook enabled:
This setting is required for the KAI integration. It allows Kubex to apply the workload’s GPU allocation and scheduling settings during admission.

New KAI installation

Depending on your cloud provider and NVIDIA configuration, you may need to adjust KAI’s configuration. The following example shows a minimal KAI installation tested with the NVIDIA GPU Operator already running in the Kubernetes cluster. It also installs HAMi-core to enforce GPU memory limits for CUDA workloads. The kai-resource-isolator chart deploys HAMi-core’s GPU library synchronization components on selected GPU nodes. HAMi-core is optional but preferred: it enforces KAI fractions, while Kubex’s GPU Reactive Policies can only increase fractions on a best-effort basis as pods approach their limits. Create kai-resource-isolator.values.yaml:
Create kai-scheduler.values.yaml:
Install HAMi-core first:
Then install the KAI scheduler:

Verify HAMi-core

If HAMi-core is used, verify that GPU nodes run pods from the following DaemonSet:
The DaemonSet’s DESIRED, CURRENT, and READY counts should cover all eligible GPU nodes. If HAMi-core is unavailable or you do not want to use it, use GpuReactivePolicy or ClusterGpuReactivePolicy to monitor GPU memory utilization through Prometheus and upsize workloads when utilization crosses configured thresholds. Reactive policies resize GPU allocations; they do not enforce memory limits. Prefer HAMi-core when possible so memory is enforced instead of upsizing pods to accommodate higher usage. See GPU Reactive Policies.

Prometheus notes

By default, the kubex-automation-engine chart configures GPU reactive policies to query Prometheus at http://kubex-prometheus-server.kubex.svc. This matches the default Prometheus service name used by kubex-automation-stack. If your Prometheus endpoint is different, override the controller-wide setting through the Helm value globalConfiguration.prometheus.url.

Built-in KAI queues

If you want Kubex Automation Engine to create the built-in KAI queue resources used in this guide, enable them in your Helm values:
This creates the built-in Run:ai queue resources, including kubex-unlimited-gpu-queue.

Starter Example

This example creates the following resources:
  • A ClusterAutomationStrategy for KAI-enabled workloads across the cluster
  • A ClusterProactivePolicy that makes matching Deployment workloads managed by that strategy
  • A ClusterGpuReactivePolicy that adjusts the shared GPU request based on Prometheus GPU metrics
Both policies target Deployment workloads in all namespaces that carry nvidia.com/gpu.present: "true".
In that mode, Kubex stores recommendations and rollback state on the Model owner, then propagates effects to model-owned pods.

Automation Strategy Notes

GPU metric interpretation defaults to fullGPU, which means Prometheus values are treated as percentages of one whole GPU. Set prometheus.interpretation: currentAllocation when a metric reports utilization relative to the container’s current GPU allocation, such as KAI GPU memory utilization. Every strategy using overrideScheduler: "kai" should set spec.enablement.gpu.requests.ceiling: "1". The controller clamps larger recommendations to that ceiling before writing gpu-fraction. For KAI-enabled workloads, start with spec.inPlaceResize.enabled: false.
  • Eviction-based resize is the safer path today for KAI-enabled workloads.
  • In-place resizing for KAI-enabled workloads is experimental and currently unstable.

vLLM tuning with KAI gpu-fraction

If a pod runs vLLM, set spec.kai.vllm.gpuMemoryUtilizationBufferPercent to leave a safety buffer below its KAI GPU allocation. A value of 10 leaves 10% of the allocation unused by vLLM. This setting works whether or not HAMi-core is enabled. Kubex applies the setting to vLLM containers when it assigns a KAI GPU allocation. It updates an existing --gpu-memory-utilization argument or adds it when needed.

Existing KAI Installations

For workloads that are already scheduled through KAI, these policies will:
  • Keep the existing kai.scheduler/queue label on the workload template.
  • Allow Kubex Automation Engine to update gpu-fraction as policies are applied.
That allows Kubex Automation Engine to participate in GPU sharing without taking over queue assignment. If you want Kubex to overwrite an existing kai.scheduler/queue label, set spec.kai.setQueueWhenSpecified: true in your AutomationStrategy. For workloads that are not currently scheduled through KAI, these policies will:
  • Replace the nvidia.com/gpu resource allocation with KAI gpu-fraction annotations.
  • Apply the KAI queue kubex-unlimited-gpu-queue (the Kubex-built-in KAI queue that does not perform quota allocations).

KAI node consolidation

GpuConsolidationPolicy is cluster-scoped and works separately from AutomationStrategy. Use it to identify underutilized GPU nodes within a single compatible node pool and evict pods from a node only when the controller believes all gpu-fraction pods on that node can fit elsewhere in the same pool. Start with one narrowly scoped policy per compatibility pool:
If you have multiple GPU compatibility pools, create multiple policies instead of one broad selector. For example, keep nvidia-tesla-t4 nodes separate from nvidia-l4 nodes or from a different provider-specific GPU node class.

Node consolidation limitations

GPU node consolidation is experimental and has known limitations.
  • It assumes pods will be schedulable on other nodes if they fit by GPU fraction.
  • It does not yet fully model all other scheduler constraints.
  • That can lead to frequent evictions when the controller chooses a node that looks drainable from GPU capacity alone but cannot actually be rescheduled cleanly.
  • It may behave unpredictably with nodes that have multiple GPUs.
Use it carefully and start with a narrowly scoped worker pool.