Project: take a model from 35 to 80 tokens per second
A multi-week portfolio brief: roughly double single-stream decode speed for one model on one GPU, one change at a time. Start by working out the bandwidth ceiling, which decides whether the target is even possible at your precision. Then remove overhead, quantise weights, look at the KV cache and try speculative decoding, with a profile and a quality check for every step. Milestones, rubric and the questions reviewers ask.
By Sandip Maity, Applied AI Engineer
Key takeaways
- Single-stream decode is limited by memory bandwidth: the ceiling is bandwidth divided by the bytes read per token. Work it out before you start.
- If the target is above the ceiling at your precision, no amount of tuning reaches it. You must read fewer bytes per token or produce more than one token per read.
- A baseline far below the ceiling means overhead: kernel launches, Python and host work. CUDA graphs and compilation remove much of it.
- Every change that alters the numbers the model computes (quantisation, speculative decoding settings) needs a quality check, not only a speed check.
- The report is a ladder: one change per rung, each with a prediction, a measurement, a profile and an explanation.
Goal: make one model's single-stream decode roughly twice as fast on one GPU (the brief's example is 35 to 80 tokens per second), with every gain predicted, measured, profiled and explained. The deliverable is a report that reads like a ladder: one rung per change.
You need: one NVIDIA GPU you can use for a few days in total (rented is fine), Python, PyTorch, and three to five weeks part-time. Background: units and vocabulary, the roofline, kernel fusion and launch overhead, quantisation, speculative decoding, profiling with Nsight and how to build a portfolio project.
Honest limits. "35 to 80" is a shape, not a promise. Your starting number depends on the model, the GPU and the software you start from, and on some setups 80 is out of reach at full precision (the next section shows how to tell). Aim for a measured doubling from your own baseline and explain the rest. Single-stream speed is one metric among several: say what happens to throughput at higher concurrency too.
#The brief
Pick one model (an 8B instruct model is a good size) and one GPU. Fix one workload: for example a 512-token prompt and 256 generated tokens, batch size 1, greedy. Measure a baseline, then climb the ladder one change at a time until you reach about twice the baseline or run out of rungs. For each rung, write the prediction before you measure.
flowchart TD B[Baseline<br/>measure and profile] --> C[Ceiling<br/>bandwidth / bytes per token] C --> O[Remove overhead<br/>CUDA graphs, compiled engine] O --> Q[Read fewer bytes<br/>weight quantisation] Q --> K[KV cache<br/>precision, long context] K --> S[More tokens per read<br/>speculative decoding] S --> R[Report the ladder]
#Step one: is the target possible?
At batch size 1, each generated token reads every weight once, plus the KV cache for the tokens so far. Compute is far from the limit, so the time per token is about the bytes read divided by the memory bandwidth:
For an 8B model in bf16, the weights are about 16 GB. Approximate datasheet bandwidths give these ceilings, before the KV cache and before real kernels' inefficiency (they usually reach 70% to 90% of peak bandwidth):
| GPU | Bandwidth | Ceiling in bf16 | Ceiling with 4-bit weights (about 5 GB) |
|---|---|---|---|
| RTX 4090 | 1,008 GB/s | about 63 tok/s | about 200 tok/s |
| L40S | 864 GB/s | about 54 tok/s | about 170 tok/s |
| A100 80GB | 2,039 GB/s | about 127 tok/s | about 400 tok/s |
| H100 SXM | 3,350 GB/s | about 209 tok/s | about 670 tok/s |
Check your GPU's datasheet for the exact bandwidth. The 4-bit column assumes about 5 GB read per token: 4 GB of quantised weights plus their scales and an output layer often left in 16-bit; check what your quantised model actually contains.
Two very different projects hide behind "35 to 80":
- On an RTX 4090 or L40S, 80 is above the bf16 ceiling. Tuning cannot get there; you have to read fewer bytes (quantisation) or produce more than one token per weight read (speculative decoding).
- On an H100, 35 is under a fifth of the bf16 ceiling. The GPU is mostly idle between kernels. Removing overhead is the main project, and 80 should be reachable without changing the model's numbers at all.
Work out which one you are in and write it at the top of the report.
#The KV cache term
For a model with layers, KV heads and head dimension in 16-bit, each token of context adds bytes read per step. For a Llama-3-style 8B model (32 layers, 8 KV heads, head dimension 128; check your model's config.json) that is 131,072 bytes, 128 KiB per token. At 4,096 tokens of context, each step reads 512 MiB of KV cache: about 3% of the bf16 weights, but more than 10% of 4-bit weights. At long context it becomes a rung of its own.
GPU
Model
Weight precision
Weights read
16.0 GB
KV read
0.07 GB
Verdict
Impossible
No tuning reaches this at this precision: read fewer bytes per token (quantise) or produce several tokens per read (speculative decoding).
At batch 1 every token reads all the weights plus the KV cache so far: tokens/s ≤ bandwidth ÷ bytes per token. Datasheet bandwidths; 8-bit and 4-bit include a small allowance for scales and a 16-bit output layer. Real kernels reach 70% to 90% of peak bandwidth.
The rest is Pro
Keep reading this full lab
Pro unlocks this full lab, including 1 animated diagram, every advanced lesson, the hands-on labs and completion certificates.
One year
$25
365 days, no auto-renewal
Lifetime Best value
$75
pay once, keep it forever
7-day refund, no questions asked. One payment, no auto-renewal.Compare plansHave a licence key?
Not ready? Keep learning free
Free lessons from Portfolio Projects, no sign-up. Or follow the free roadmap →
Not ready? Take the free 5-day email course
One short email a day for five days, each built on a free lesson, then the occasional new lesson or offer. Unsubscribe in one click.
Still to come in this lab
- The ladder
- Measuring each rung
- Milestones
- The ladder table
- Rubric
- What a reviewer will ask you
- Checklist
- Where to go next
You will be able to answer
- An 8B model in bf16 runs on a GPU with about 1,000 GB/s of memory bandwidth. Roughly what is the single-stream decode ceiling?
- Your baseline is 35 tokens per second on a GPU whose ceiling for this model is 200. What is the most likely first fix?
- Speculative decoding makes your benchmark prompt 1.8 times faster but your chat prompts only 1.1 times faster. Why?
- After 4-bit quantisation the speed doubles. What else must the report show?