RS

Ravi Singhalravisinghal.io

Back to Home
Platform Engineering

One 4 GB GPU, Two Models and a Training Job

Ravi Singhal

18 November 2026

11 min read

Kubernetes
GPU
DRA
vLLM
llm-d
Flow Control
Ollama
PyTorch
Training
OpenTelemetry
Platform Engineering
Open Source
Go

In September I wrote about putting vLLM on a kind cluster with a 4 GB card and nowhere to hide. That cluster had a GPU in name only for most of its life. The operator asked for a device, the tests checked the request was well formed, and nothing ever had to fight over one.

So I fixed that. The cluster is now one kind cluster on Kubernetes 1.37. nvkind passes the laptop's RTX 500 into the worker node, and NVIDIA's Dynamic Resource Allocation (DRA) driver publishes the card to the scheduler as gpu-0, with 4,094 MiB of memory. Then I put three things on it: a vLLM model, an Ollama model and a training job.

Four results came out of that. Each one changed the code.

The rollout that never finished

The first spec change after the GPU arrived never completed. The new pod sat in Pending. The old pod kept serving. The scheduler's message said no device was available, which was true.

A Deployment replaces pods by starting the new one first and removing the old one once the new one is ready. For ordinary software that is the right default, because capacity never drops. A device claimed through DRA is held by one pod at a time. With every device in use, the new pod waits for a device, and the only device belongs to a pod that will not be removed until the new pod is ready.

Neither side moves, and neither side is wrong.

None of my tests caught it. The controller tests run against a real API server with no scheduler, so a pod is never placed and never waits. The September cluster had no device to hold. It took a real card to see it.

The fix is two fields. When a service names a device class, the operator sets the rollout to maxSurge: 0 and maxUnavailable: 1: take one old pod down, free its device, then start the replacement.

That has a cost, and I would rather state it than hide it. A one-replica GPU service is down for as long as its weights take to load. The alternative was a rollout that never completes, so the trade is easy, but it is a trade.

It also exposed a status bug. Throughout the stuck rollout the InferenceService said Ready, because one old replica was serving. It now says Degraded, with a condition that gives the count and the reason: "1 of 2 replicas ready", followed by the scheduler's own words, or RolloutInProgress when that is all it is.

Sharing the card, and the 40% floor

One device per pod means the vLLM model held the whole card while the Ollama model ran on CPU at 18 tokens a second. Kubernetes lets several pods name the same ResourceClaim. The scheduler allocates its device once and lists every pod using it. So the operator grew a field, sharedDeviceClaim, that names an existing claim instead of making one per pod.

Two decisions came with it. The operator never creates or deletes the shared claim, because which services may share a card is a platform decision, and a claim owned by the first service to name it would be deleted with that service. And a Restricted service cannot use one, at admission and in the operator. Processes sharing a GPU have no wall between their memory.

vLLM reserves its share of the card up front, so the shares are sized by hand. I set it to 30%. vLLM loaded 0.93 GiB of weights, worked out that it had minus 0.24 GiB left for its cache, and stopped:

ValueError: No available memory for the cache blocks.

At 40% it started with 1,358 MiB and room in its cache for 10,864 tokens. That floor is not obvious from the model size. The weights are under a gigabyte, and about 0.4 GiB more goes to everything else the process needs before the cache gets a byte.

Then Ollama joined on the same claim and took 1,342 MiB of what was left. Both models answered requests sent at the same moment. It worked, and the second model was no faster.

Phi-4 mini needs 3.2 GB. With vLLM holding its share, Ollama fitted 42% of the model's layers on the GPU and ran the rest on the CPU. It generated 17 tokens a second, the same as before. Every token still waits on the layers the CPU runs.

A model gains from a shared card when it fits on it whole. Sharing is the right answer for a second small model and the wrong one for a model that needs most of the card anyway. I would not have guessed the result was that flat.

Training beside serving

Inference reads a model's weights. Training changes them, and the card behaves differently: it stays busy between requests, and memory holds gradients and optimiser state as well as weights.

The training job is a plain Kubernetes Job, not something the operator manages. It names the same shared claim and trains a 10.9-million-parameter transformer from scratch to predict the next byte of the Python standard library's own source, which is already in the container image.

Nothing fences one process's memory from another's on a shared card, and a job that grows past what is free does not fail alone. Whichever process next asks for memory fails, and that might be a model server in the middle of a request. So the job fences itself with torch.cuda.set_per_process_memory_fraction.

That fence earned its place on the first run. At a quarter of the card with batches of 32, the job stopped with PyTorch's own message, "934.52 MiB allowed". vLLM kept serving and never noticed. At a third of the card with batches of 24 it peaks at 758 MiB.

Over 1,500 steps, about two minutes, the loss on text it had never seen fell from 2.487 to 1.290. Guessing a byte at random scores 5.545. Asked to continue def , it wrote something that looks like Python and means nothing, which is about right for ten million parameters and two minutes.

The more useful number was throughput. Alone, the job trained on 84,000 tokens a second. During the hundred steps in which vLLM answered one chat request, it fell to 40,700. The card takes turns, and the dashboard row I added for the job shows the dip lining up with the request.

The fence is the job's own good manners. A job that does not set it is stopped by nothing, and two jobs started together both get the card. Kueue is the usual answer to that. It is not installed.

Priority, measured instead of stored

The operator already wrote an llm-d InferenceObjective for any service that sets a priority. Nothing read it. Requests went straight to vLLM, which serves them in the order they arrive.

llm-d 1.0 ships its endpoint picker as a Helm chart with Envoy beside it, and flow control is a feature gate in the picker's configuration, off by default. I installed the chart for the vLLM pool with the gate on and hit one snag. The chart renders an InferencePool named after the release, and the operator already owns that pool. Two owners of one object overwrite each other, so the install drops the chart's copy and points the picker at the operator's.

I told the picker the pool was full at four requests in flight, against the sixteen vLLM would take, so the queue would be easy to see on one card. Then I sent 20 batch requests at priority -10, and a second later 8 interactive requests at priority 10.

Sent Answered Median wait in the queue Last answered at
Batch, priority -10 20 20 4.5 s 8.0 s
Interactive, priority 10 8 8 0.7 s 3.4 s

In the order the answers came back, b for batch and I for interactive:

bbbbIIIIIIIIbbbbbbbbbbbbbbbb

The first four batch requests were already running. Every interactive request went ahead of the sixteen batch requests that had arrived before it. Nothing was refused: the batch work waited, then ran.

A caller can also say how long it is willing to wait, with the x-llm-d-inference-ttl header. With each batch request allowing two seconds, 15 of the 20 were turned away with HTTP 429 and the reason rejected-ttl-expired. All 8 interactive requests were still answered.

I want to be clear about what that does not show. Both classes differed in priority, so fairness between two teams at the same priority was not tested. With one replica the picker had nothing to choose between, so its scoring on queue depth and cache use did nothing. And the limit of four is a number I typed in. The right figure depends on the model and the card, like every throughput figure in this project.

One request, one trace

This one is a smaller change, and the one I use most. The gateway traced its own work and vLLM traced its own, and they arrived as two unrelated traces. Finding the vLLM side of a slow request meant matching timestamps and hoping.

The W3C traceparent header exists for exactly this. The gateway now sends it with every backend call, and vLLM files its spans under the gateway's. One request in Tempo is now one trace: the gateway's routing decision, then vLLM's llm_request beneath it, with the queue time and token counts. The header carries two random ids and a flag and nothing about the request.

What I would tell myself in September

The deadlock is the one worth remembering. Every default in it is reasonable on its own, and the failure only exists once a device is scarce. A test suite with no scheduler cannot find it. A cluster with spare devices cannot find it either. A small card made it show up on the first spec change.

The shared card taught me that "it fits" and "it helps" are different questions. The training job taught me that on a shared GPU every process is responsible for its neighbours, because nothing else is. And the priority queue taught me to measure the behaviour instead of trusting the object that configures it, which in hindsight is what the September post was about too.

Four things are still open. Two tenants at the same priority have not shared the queue. Scale to zero through the picker's queue is untried. Training jobs have no queue of their own. And NVIDIA's Multi-Process Service, which can cap each process's GPU memory instead of trusting it to cap itself, has not been tried on this card.

The whole cluster rebuilds from the repository with make up, and each result above has a decision record with the measurements. Code's at github.com/lake-of-dreams/llm-inference-platform.

Ravi Singhal

Principal Engineer (Executive Director)

Agentic AI systems and the LLM infrastructure under them.

Quick Links
Resources

About Ravi SinghalProjectsOracle Verrazzanollm-inference-platformagentic-adjudication-platformRSS

© 2026 Ravi Singhal. All rights reserved.

Built withAstro • React • TypeScript • Material UI