// guide

GPU for coding agent: VRAM and speed on NVIDIA L4 and L40S

A 24 GB NVIDIA L4 runs Qwen3-8B with KV cache for one request of up to 20,080 tokens; a 48 GB NVIDIA L40S held 166,560 cache tokens and decoded 2.7 times faster, in our one-run tests on 2026-12-03.

Updated

Disclosure: 9owls publishes the Open WebUI + vLLM Launchable used for these tests; NVIDIA did not pay for or review this page. Every number below comes from one run per GPU on 2026-12-03 with Qwen/Qwen3-8B in 16-bit (bf16) weights on vLLM v0.33.0, or from arithmetic on those logs, and says so. For GPU specifications and model fit by size, see NVIDIA L4 vs L40S for LLM inference.

On this page

Why does a coding agent need more GPU memory than a chat?

A coding agent sends the task, the files it has read and the output of the tools it ran back to the model on every step, so its prompts grow long. vLLM keeps the attention state of every token in flight in the KV cache on the GPU, and the memory left after the model weights sets how many tokens fit there; our vLLM logs below show both numbers.

  • Context: the longest single request is capped by the KV cache left after the weights.

  • Concurrency: several agents, or one agent with parallel sub-tasks, share that same cache.

  • Speed: every step waits for generated tokens, so tokens per second sets how long a step takes.

  • Weights: Qwen3-8B in bf16 took 15.27 GiB on both GPUs in our logs.

How much context fits on 24 GB and on 48 GB?

The table is copied from the vLLM startup logs of our two runs, both at --gpu-memory-utilization 0.90.

Measured 2026-12-03NVIDIA L4 24 GB (GCP g2-standard-8)NVIDIA L40S 48 GB (AWS g6e.xlarge)
Total GPU memory, nvidia-smi23034 MiB46068 MiB
Qwen3-8B weights loaded15.27 GiB15.27 GiB
KV cache memory available2.76 GiB22.87 GiB
KV cache size20,096 tokens166,560 tokens
Concurrency vLLM reports for 16,384-token requests1.23x10.17x
GPU memory in use while serving19440 MiB40331 MiB

Derived from the same lines: both caches work out to about 0.14 MiB per token (2.76 GiB / 20,096 and 22.87 GiB / 166,560), so cache tokens grow with the memory left after the weights, not with the GPU model.

What happens on an NVIDIA L4 when the context is too long?

vLLM read Qwen3-8B's maximum length as 40,960 tokens. On the NVIDIA L4, vLLM refused it at startup with "5.62 GiB KV cache is needed, which is larger than the available KV cache memory (2.76 GiB)" and named 20,080 as the estimated maximum model length. With --max-model-len 20080 the server started. At --gpu-memory-utilization 0.5 the budget was below the weights and vLLM stopped with "No available memory for the cache blocks". The fixes are in vLLM No available memory for the cache blocks.

Setting on the NVIDIA L4, Qwen3-8B bf16Result on 2026-12-03
max-model-len 16384, utilization 0.90 (Launchable default)Started
max-model-len 20080, utilization 0.90Started, cache for 1.00x of one 20,080-token request
max-model-len 40960, utilization 0.90Refused: 5.62 GiB KV cache needed, 2.76 GiB available
max-model-len 16384, utilization 0.5Refused: no available memory for the cache blocks

On the NVIDIA L40S, the 22.87 GiB cache holds the full 40,960-token length about four times over by the same per-token arithmetic; we did not start the server at 40,960 on the NVIDIA L40S, so that setting is untested.

How fast is Qwen3-8B on an NVIDIA L4 and an NVIDIA L40S?

Our benchmark sent a fixed short prompt with 256 output tokens per request, temperature 0, at 1, 4 and 8 requests at once, two rounds each after one discarded warm-up; the table shows round 1. It runs on the instance against the local vLLM server.

Requests at onceNVIDIA L4: total tokens/sNVIDIA L4: tokens/s per requestL40S: total tokens/sL40S: tokens/s per request
116.6716.7545.5745.82
463.0215.90170.8043.12
8124.8615.76339.5142.90

Time to first token at 8 requests was a median 0.154 s on the NVIDIA L4 and 0.063 s on the NVIDIA L40S. Per-request speed barely fell from 1 to 8 requests on either GPU, because these prompts were short. Long agent prompts fill the cache and spend time on prefill, which this test did not measure.

What does each GPU cost per hour on NVIDIA Brev?

Compute list prices from the Brev CLI GPU search for stoppable types, read 2026-12-03 around 07:25 UTC. They change; check the console before you deploy.

GPUInstance typeCompute price per hour
NVIDIA L4GCP g2-standard-4$0.845
NVIDIA L4AWS g6.xlarge$0.966
NVIDIA L4GCP g2-standard-8 (our NVIDIA L4 test)$1.024
NVIDIA L40SCrusoe l40s-48gb.1x$1.74
NVIDIA L40SAWS g6e.xlarge (our L40S test)$2.233

The console showed our running NVIDIA L4 instance at $1.16/hr with a 137 GB disk, and $0.03/hr while stopped. Derived from the 8-request rows and the compute prices of the two tested types: about $2.28 per million output tokens on the NVIDIA L4 and about $1.83 on the NVIDIA L40S, for short prompts only and before disk.

How long does it take to get a first answer?

Launch to first chat answer, 2026-12-03Time
NVIDIA L4, GCP g2-standard-823 min 27 s
NVIDIA L40S, AWS g6e.xlarge20 min 07 s

Most of that time is the first pull of the container images and the 16 GB model download. On the NVIDIA L40S run the vLLM image used 35.4 GB of disk and Open WebUI 6.46 GB, so size the disk for both images plus the model.

Which should I choose for a local coding agent?

  1. One developer, one agent, Qwen3-8B, prompts under about 20,000 tokens: the NVIDIA L4 runs it at about 16 tokens per second per request.

  2. Agent prompts that grow past 20,000 tokens, or the model's full 40,960 tokens: the NVIDIA L40S, which has the cache memory for it.

  3. Several agents or parallel sub-tasks at once: the NVIDIA L40S, which reported 10.17x concurrency for 16,384-token requests against 1.23x on the NVIDIA L4.

  4. A larger model, such as a 30B-class coding model in 4-bit or FP8: start from the 48 GB L40S and check the fit table in NVIDIA L4 vs L40S for LLM inference.

The OpenHands Coding Agent on Nemotron Launchable runs a coding agent next to vLLM on one L40S; Run OpenHands with a local Nemotron model shows how the agent is pointed at the local model.

What else do people ask about GPUs for coding agents?

How much VRAM does an 8B model need?

In our runs, Qwen3-8B in bf16 took 15.27 GiB for the weights alone. vLLM then needs memory for the KV cache on top: on a 24 GB NVIDIA L4 that left 2.76 GiB, enough for 20,096 tokens.

Can a 24 GB GPU run a coding agent?

Yes, for one request at a time with an 8B model in 16-bit weights and context up to 20,080 tokens, as measured on the NVIDIA L4 on 2026-12-03. Longer context or more parallel requests need more memory or a smaller weight format.

Does a GPU help with coding agents?

The GPU runs the model, not the agent. On 2026-12-03 Qwen3-8B generated 16.67 tokens per second for one request on the NVIDIA L4 and 45.57 on the NVIDIA L40S; a 256-token answer took about 15.4 s and 5.6 s.

Why do LLMs use a GPU instead of a CPU?

We did not test a CPU. vLLM's own error messages tie the limits to GPU memory: weights and KV cache must both fit in the share of GPU memory that --gpu-memory-utilization allows.

Is the NVIDIA L40S worth the higher price for one user?

For one short request at a time the NVIDIA L4 costs less per hour. The L40S was 2.7 times faster per request in our test and its cache holds the full model length, so it fits longer agent sessions.

Which sources does this page use?

  • 9owls measurement runs on NVIDIA Brev, 2026-12-03: NVIDIA L4 (GCP g2-standard-8) and NVIDIA L40S (AWS g6e.xlarge), Qwen/Qwen3-8B, vLLM v0.33.0, one run each

  • Brev CLI GPU search for stoppable types and the Brev console, read 2026-12-03

  • vLLM documentation, conserving memory (external site), the page vLLM v0.33.0 names in its cache-blocks error, 2026-12-03

How was this page made?

9owls published this page. The numbers come from our own vLLM logs and benchmark output on 2026-12-03, one run per GPU; per-token, ratio and cost-per-token figures are arithmetic on those values and are marked as derived. We did not test long-prompt prefill, a 40,960-token context on the NVIDIA L40S, or any other model. Found an error? Tell us on the company page.

All guides