Module 5: Preemption Testing
Preemption is the mechanism that gives reserved workloads priority over unreserved ones. When a user with a reservation submits a workload and there aren’t enough free resources, Kueue evicts unreserved workloads to make room.
In this module, you’ll simulate a multi-user GPU contention scenario using the workload Helm chart and observe preemption in action.
Learning objectives
By the end of this module, you’ll be able to:
-
Deploy unreserved workloads that consume GPU resources
-
Trigger preemption by submitting a reserved workload
-
Observe the Kueue admission and eviction process
-
Test preemption with both full GPUs and MIG partitions
Kueue state after reservations
Once users have reserved GPUs through the booking app, the Kueue resource hierarchy includes per-user ClusterQueues with protected quota, and reserved LocalQueues in each namespace:
The red LocalQueues (user1, user2) point to per-user ClusterQueues with reclaimWithinCohort: Any. The unreserved ClusterQueue’s nominalQuota has been reduced from 8 to 5 GPUs to account for the 3 GPUs reserved.
How preemption works in this environment
The preemption model is based on Kueue’s Cohort borrowing rules:
1. Unreserved workloads run using shared Cohort quota
2. User makes a reservation → booking app creates ClusterQueue with nominalQuota
3. User submits workload → ClusterQueue has reclaimWithinCohort: Any
4. Kueue preempts unreserved workloads borrowing from the Cohort
5. Reserved workload gets resources
6. Unreserved workload re-queues, waits for resources
The unreserved ClusterQueue has no reclaim rights, so its workloads can always be preempted. User ClusterQueues have reclaimWithinCohort: Any, meaning they can preempt any workload borrowing from the same Cohort.
Exercise 1: Fill the cluster with unreserved workloads
|
Acting as:
|
First, let’s consume GPU resources with unreserved workloads.
-
Deploy an unreserved workload requesting 8 full GPUs (all available):
helm template gpu-deploy oci://quay.io/eformat/gpu-test-workloads -n user-user1 \ --set kind=Deployment \ --set name=gpu-fake-gpu \ --set replicas=1 \ --set gpuCount=8 \ --set gpuResourceType=nvidia.com/gpu \ --set reserved=false \ | oc -n user-user1 apply -f-Expected output:
deployment.apps/gpu-fake-gpu created -
Wait for the deployment to be ready:
oc -n user-user1 rollout status deployment/gpu-fake-gpu --timeout=60sExpected output:
deployment "gpu-fake-gpu" successfully rolled out -
Verify all GPUs are consumed:
oc get clusterqueue unreserved -o jsonpath='{.status.flavorsUsage}' | jq .Expected output:
{ "borrowed": "8", "name": "nvidia.com/gpu", "total": "8" } -
Verify nvidia-smi shows the GPUs:
oc -n user-user1 exec $(oc -n user-user1 get pod -l app=gpu-fake-gpu -o name | head -1) -- nvidia-smiYou should see 8 NVIDIA GB200 NVL GPUs listed in the
nvidia-smioutput table. Each row represents one simulated GPU with its memory usage and utilization. -
You can also check the workload status in the Booking App.
Exercise 2: Trigger preemption with a reserved workload
We are now going to trigger preemption with a reserved workload. We will create a reserved workload before we book a GPU for today. This gives us a chance to see the preemption happen in action.
|
Acting as:
|
Now deploy a reserved workload from a different user. This simulates a user with a GPU reservation claiming their resources.
-
Deploy a reserved workload requesting 1 GPU:
helm template gpu-deploy oci://quay.io/eformat/gpu-test-workloads -n user-user2 \ --set kind=Deployment \ --set name=gpu-fake-gpu \ --set replicas=1 \ --set gpuCount=1 \ --set gpuResourceType=nvidia.com/gpu \ --set reserved=true \ | oc -n user-user2 apply -f-Expected output:
deployment.apps/gpu-fake-gpu created -
The workload will be in a
SchedulingGatedstate as we have not yet booked a GPU for today.oc -n user-user2 get pods,workloadExpected output:
NAME READY STATUS RESTARTS AGE pod/gpu-fake-gpu-74868b8b79-4cxdw 0/1 SchedulingGated 0 38s NAME QUEUE RESERVED IN ADMITTED FINISHED AGE workload.kueue.x-k8s.io/pod-gpu-fake-gpu-74868b8b79-4cxdw-18555 reserved 38s
|
Acting as:
|
-
Watch the preemption happen in the terminal:
oc get events -A --sort-by='.lastTimestamp' --field-selector reason=Preempted -w
|
Acting as: |
-
Open the GPU Booking > Bookings page in the OpenShift Console and book 1 GPU for today.
-
The pod will be admitted by Kueue but scheduling now needs to re-run. Delete the pod to trigger scheduling. From the OpenShift Console, navigate to Workloads > Pods and delete the pod.
-
Back on the admin terminal - we now expected to see the preemption event:
NAMESPACE LAST SEEN TYPE REASON OBJECT MESSAGE user-user1 0s Normal Preempted workload/pod-gpu-fake-gpu-54959878d8-nclg6-a68ff Preempted to accommodate a workload (UID: 79cd54c4-2146-451a-96c8-5ca1609a451e, JobUID: 7e9fa1f0-3072-4e20-9d4d-54ae8007955f) due to reclamation within the cohort; preemptor path: /unreserved/user-user2; preemptee path: /unreserved/unreservedPress
Ctrl+Cafter you see preemption events. Kueue evicts the unreserved workload to free one GPU for the reserved request. -
Check the workload status:
oc get workloads -A -o custom-columns=\ NAMESPACE:.metadata.namespace,\ NAME:.metadata.name,\ QUEUE:.spec.queueName,\ ADMISSION:.status.admission.clusterQueue,\ ADMITTED:.status.conditions[0].statusExpected output - the unreserved workload is not admitted and the reserved workload is admitted:
NAMESPACE NAME QUEUE ADMISSION ADMITTED user-user1 pod-gpu-fake-gpu-54959878d8-m4zdc-84bd2 unreserved <none> False user-user2 pod-gpu-fake-gpu-74868b8b79-c8hlg-af2e1 reserved user-user2 True -
Verify the reserved workload is running:
oc -n user-user2 rollout status deployment/gpu-fake-gpu --timeout=60sExpected output:
deployment "gpu-fake-gpu" successfully rolled out -
Check nvidia-smi on the reserved workload:
oc -n user-user2 exec $(oc -n user-user2 get pod -l app=gpu-fake-gpu -o name | head -1) -- nvidia-smiYou should see the nvidia-smi output for the reserved workload.
-
We can also check the workload status in the Booking App.
You should see the reserved workload is running (red) and the preemption event is shown in the console as well.
Exercise 3: Test MIG partition preemption
Preemption also works with MIG partitions. Let’s test with MIG-1g.23gb devices. Lets quickly run through the steps to deploy a MIG workload and see the preemption in action.
|
Acting as:
|
-
Deploy an unreserved workload consuming 56 MIG-1g.23gb partitions:
helm template gpu-deploy oci://quay.io/eformat/gpu-test-workloads -n user-user1 \ --set kind=Deployment \ --set name=gpu-fake-23gb \ --set replicas=1 \ --set gpuCount=56 \ --set gpuResourceType=nvidia.com/mig-1g.23gb \ --set reserved=false \ | oc -n user-user1 apply -f- -
Wait for deployment:
oc -n user-user1 rollout status deployment/gpu-fake-23gb --timeout=60s -
Check the running pods:
oc -n user-user1 get podsExpected output:
oc get pods NAME READY STATUS RESTARTS AGE gpu-fake-23gb-5d687f5d44-gxncs 1/1 Running 0 7s gpu-fake-gpu-54959878d8-m4zdc 0/1 SchedulingGated 0 21mWe can see the full GPU is
SchedulingGated(it is still preempted) and the MIG workload isRunning. -
We can also check the workload status in the Booking App.
You should see the user2 reserved workload is running (red) and the user1 unreserved MIG workload in (green).
|
Acting as: |
-
Open the GPU Booking > Bookings page in the OpenShift Console and book 8 MIG-1g.23gb partitions for today.
|
Acting as:
|
-
Deploy a reserved workload requesting 8 MIG partitions:
helm template gpu-deploy oci://quay.io/eformat/gpu-test-workloads -n user-user2 \ --set kind=Deployment \ --set name=gpu-fake-23gb \ --set replicas=1 \ --set gpuCount=8 \ --set gpuResourceType=nvidia.com/mig-1g.23gb \ --set reserved=true \ | oc -n user-user2 apply -f- -
Watch preemption and verify both are running:
oc -n user-user2 rollout status deployment/gpu-fake-23gb --timeout=60s -
We should now see both user2 reserved workloads running and user1 unreserved workloads preempted in the Booking App.
-
Check nvidia-smi on the MIG workloads:
oc -n user-user2 exec $(oc -n user-user2 get pod -l app=gpu-fake-gpu -o name | head -1) -- nvidia-smi oc -n user-user2 exec $(oc -n user-user2 get pod -l app=gpu-fake-23gb -o name | head -1) -- nvidia-smiNotice the MIG partition size (23 GB) shown in nvidia-smi output.
Exercise 4: Clean up all workloads
user1: Delete workloads
|
Acting as:
|
-
Remove user1’s test deployments:
oc -n user-user1 delete deployment gpu-fake-gpu oc -n user-user1 delete deployment gpu-fake-23gb
user2: Delete workloads
|
Acting as:
|
-
Remove user2’s test deployments:
oc -n user-user2 delete deployment gpu-fake-gpu oc -n user-user2 delete deployment gpu-fake-23gb -
Verify all GPU resources are free:
oc get clusterqueues -o custom-columns=\ NAME:.metadata.name,\ ADMITTED:.status.admittedWorkloadsAll ClusterQueues should show 0 admitted workloads.
-
user2: Cancel booking
Acting as:
user2
Return to the OpenShift Console as user2. -
Navigate to GPU Booking > Bookings and click My Bookings.
-
Click Cancel All to remove the GPU reservation, then click Confirm.
Module summary
What you accomplished:
-
Filled the cluster with unreserved GPU workloads
-
Triggered preemption by submitting a reserved workload
-
Observed Kueue evicting unreserved workloads to honor reserved quotas
-
Tested preemption with both full GPUs and MIG partitions
Key takeaways:
-
Reserved workloads always win over unreserved ones through Kueue’s
reclaimWithinCohort: Anypolicy -
Preemption is automatic — Kueue handles eviction without manual intervention
-
MIG partitions follow the same preemption model as full GPUs
-
The booking app creates the Kueue resources that make preemption possible; users only interact with the calendar
-
Unreserved workloads are not lost — they re-queue and resume when resources become available
Next: Head to the Conclusion for a summary of what you learned and resources to continue your journey.







