Notes / Performance
System Performance Workbench
Qwen3.8-Flash-Next, "A Preview of the Qwen4 Architecture", on a Lenovo ThinkStation P920 announced in 2017: two Xeon Gold 6138 with 40 cores, 754 GiB of RAM, an RTX 3090 and an RTX 3060. We run 6-bit experts on 16 of the 40 cores, where our Strata build ran 4-bit on 36. Against llama.cpp --fit on the same weights, one stream of our q6-dual profile (6-bit, up to two streams) decodes 3.87x faster, with MTP drafts on our side only, energy per output token is 2.17x to 7.38x lower with the prompt read included, and the top next token matches at 97.75 % of positions.
Against llama.cpp, same weights, q6-dual profile
- 97.75 %same top next token as llama.cpp --fit, same weights, teacher-forcedits own two placements: 98.21 %; no skipped expertsMore
- 3.87xone-stream decode against llama.cpp--fit, the faster setup that loaded; we draft with MTP, llama.cpp without: --fit with MTP did not load; same weights and cores; up to 4.73xMore
- 2.17x to 7.38xless energy per output token than llama.cpp --fitprompt read included; MTP drafts on our side only; the gap grows with prompt lengthMore
Our tuning
- Q4 to Q6precision up on 16 cores in q6-dual and q6-quad; our Strata build ran Q4 on 36expert gate and up 4.5 to 6.56 bits, down 6.0 to 8.5, from our files' tensor types; Unsloth's KL for its own files 0.047 to 0.027More
- +85 %two-stream throughput on 60 % fewer coresq6-dual, 6-bit both times, 16 cores against our first 40; +15 % over our best 40-core runMore
- 12.2-17.3 %of decode speed from the hardware prefetchers, which we keep onq6-dual, measured by switching them off on the engine coresMore
Strata, the engine family we build on, has turned answer-changing speed settings on by default on some GPUs, and has since turned its expert tail skip back off. Our production skips no experts. Our engine's next-token probabilities sit about twice as far from llama.cpp's, 0.0038 nats of mean KL divergence, as llama.cpp's own two placements of the file sit from each other, 0.0020, both by one lower-bound estimator.
We have been waiting a long time for Qwen4. Qwen3.8-Flash-Next calls itself "A Preview of the Qwen4 Architecture" in its model file. We expect the next generation of MoE models to look like it, so we tuned for it now.
Each token picks 10 of 512 routed experts per layer. The GPUs hold the experts named in the serving profile, and the CPU pool streams the rest out of DRAM: in a two-stream window it reads within 5 % of the 82 GB/s that 15 synchronized threads reach in a microbenchmark here. That is a Linux and memory problem, and we tuned it on an older dual-socket workstation with two unequal consumer GPUs, capped at 460 of their stock 520 W.
Energy per output token is 2.17x to 7.38x lower than llama.cpp --fit, prompt read included, and 2.42x to 7.05x lower than stock llama.cpp, which used less energy per token than --fit in the 32K case.
The 4-bit profile runs faster on this box, 122.2 and 127.7 tok/s on the same two-stream test. We serve 6-bit anyway and took our 85 % from the engine and the system.
Results
-
Precision up, 4-bit to 6-bit. Against the 4-bit model on the same box, three weight groups moved up and none moved down:
- routed expert gate and up: 4.5 to 6.56 bits per weight in 47 of 48 layers, the 48th up to 8.5;
- routed expert down: 6.0 to 8.5 bits per weight in 43 of 48 layers, the other 5 already 8.5;
- per-layer token embeddings: 4.5 to 8.5 bits per weight.
Every other tensor is the same 8-bit or wider type in both files. The weights grow from 103.68 to 157.54 GiB, +52 %. The 4-bit profile is faster on this box: 122.2 and 127.7 tok/s against 102.5 and 103.6 at 6-bit, two-stream total on the test collector, short prompts, temperature 0. We run Unsloth's UD-Q6_K_XL quantization. The bit widths above we read from our own model files; the fidelity gain we did not measure. For it we take Unsloth's reference table, measured on the UD-Q4_K_XL and UD-Q6_K_XL files it publishes for this model, not on ours: mean KL divergence 0.046893 and 0.027091, top-1 92.255 and 94.089; their Q6's mean KL divergence sits 0.0005 above their Q8_0's. In decode, Lamina's exact expert path is built to give a routed expert the same bits on either GPU and on the CPU, and the engine's 34 bitwise GPU parity tests pass; the rotary angles come from a table computed in float64.
-
No measurable accuracy change. Over 4,791 items both files answered, in seven suites, the pooled score difference Q6 minus Q4 is +0.1 points, 95 % CI -0.45 to +0.63 points, half-width 0.54: no measurable accuracy difference, by the rule we fixed before the last run. Of the items scored differently, Q6 wins 91 and Q4 wins 87, and no suite's own 95 % interval excludes zero. With that half-width, this sample cannot tell a pooled difference smaller than about half a point from zero.
-
+85 % two-stream throughput on 60 % fewer cores, at 6-bit. Two runs, +84 % and +86 %: 102.5 and 103.6 tok/s against 55.6 tok/s for our first 40-core configuration, and +15.0 % over our best 40-core result. Cores 40 to 16. Test collector, short prompts, temperature 0.
-
Four streams at 1.41x Strata's one stream, on 16 cores instead of 36. 126.8 tok/s together, mean of three runs from 112.3 to 136.3, against 90 tok/s on our custom Strata build. Conditions: our wall clock on cached second turns of four 32K conversations at temperature 0. The first turns of the same conversations read their prompts one after another and run at 18.2 tok/s. Strata, our custom build: decode only, one stream, sampled, 4-bit weights, 36 cores. A cross-instrument comparison.
-
One stream against llama.cpp: 3.87x to 4.73x decode. Against llama.cpp's own --fit placement, the faster of the two configurations that loaded, on the same weights, CPUs and power caps, Lamina decodes one stream 3.87x to 4.73x faster. The lowest is a short temperature-0 prompt on which llama.cpp writes a count and Lamina reasons; on the like-for-like 4K prompt it is 4.70x and 4.73x. Both configurations that loaded, stock and --fit, passed our output-validity rule first; --fit with its MTP draft did not load, so llama.cpp decoded without drafts and Lamina with its MTP draft layer, which sits beside the model file; every drafted token is checked by the full model. MTP is multi-token prediction: a layer trained with the model to predict the token after the next, which an engine can use to draft tokens for the full model to check.
-
Energy per output token against llama.cpp --fit: 2.17x to 7.38x less. On short prompts llama.cpp --fit spends 2.17x and 2.82x the energy per output token, the first with a cold prompt read; the gap widens with prompt length, to 7.38x at 32K. Stock llama.cpp used less energy per token than --fit in the 32K case; against it the range is 2.42x to 7.05x.
-
0 skipped experts. Our production profiles skip no experts and truncate no routing, and decode runs Lamina's exact expert path, not its fast default. Twelve GPU source files and the matrix library for prompt experts and verify projections are built with fast math, as llama.cpp's CUDA code is. On the same model file, teacher-forced, our top next token matches llama.cpp --fit at 97.75 % of positions, against 98.21 % between llama.cpp's own two placements. KL divergence, in nats, measures how far the next-token probabilities move; 0 means they did not move. Two roundings we chose are measured as mean KL lower bounds over the tokens before each pair of outputs first parts: the int8 KV cache, which halves the cache, 0.00125 nats against fp16 over 481 positions; the BF16 read of the mixing matrices, 0.00112 nats against the file's 8-bit codes over 223. 101 small convolution values move by at most 3e-8. Not measured one by one: the BF16 read of the per-layer embedding values, and the prompt path's FP16 and BF16 activations, which follow llama.cpp's CUDA code. 797 temperature-0 answers compared at different numbers of requests in flight, from 1 to 5: all 797 byte-identical, 750 of them also on both production profiles.
How close we are to llama.cpp
Does Strata, the engine family Lamina forks, buy its speed with accuracy? Its own release notes show where the question comes from: speed settings that change answers, turned on by default.
- v0.1.41: faster short-prompt reads on one NVIDIA GPU, on by default, which the notes say "changes bits"; first-token KL against the old path averages 0.004.
- v0.1.42: two NVIDIA defaults, a route tail skip and a measured PCIe share. By Lamina's description, the tail skip leaves out, in a verify window, an expert that misses the GPU cache and that every token ranks 7th or lower. The notes give the tail skip 12.9-15.6 % faster decode on one GPU, report a mean KL of 0.0032 and 0.0058 in their own greedy tests, and say the new defaults "change answers a little".
- v0.2.17: the tail skip off by default again; with it on, KL against exact routing measures 0.0126 on an RTX 5090 with UD-Q4_K_XL.
- v0.2.23: a fast mode on by default on the RTX 5090 and other recent cards that "can change the exact words of an answer slightly".
Strata states each change in its own notes. Those KL values compare Strata with and without its new settings, on Strata's own test files and GPUs, so read them as sizes, not as a ranking against our engine-against-engine numbers below.
An independent test of Strata 0.2.12 against a BF16 reference, with Strata's adaptation and drafting off, found no distributional degradation against llama.cpp on the same three 3- and 4-bit files; its author wrote that quantization, not the engine, dominates the divergence. The test does not name its model and predates the v0.2.23 fast mode. We did not test an upstream Strata build.
What we run: our engine source has no tail skip and no prompt CPU share switch, and Lamina's docs call Strata's tail skip an approximation: Lamina computes every routed expert. Our production also runs Lamina's exact expert path instead of its fast default, built so that in decode a routed expert gives the same bits on either GPU and on the CPU; the engine's bitwise GPU parity tests pass. Twelve GPU source files and the matrix library for prompt experts and verify projections are built with fast math, to match llama.cpp's CUDA arithmetic. Two roundings we chose are measured, as mean KL lower bounds over the tokens before the outputs first part: the int8 KV cache, 0.00125 nats against fp16, and the BF16 read of the mixing matrices, 0.00112 nats against the file's 8-bit codes. Others are not measured one by one, among them the BF16 read of the per-layer embedding values and the prompt path's FP16 and BF16 activations, which follow llama.cpp's CUDA code. Strata's opt-in decode kernels include rounding-changing paths; when we tuned Strata, we tested only its exact paths and kept its expert-tail skip out.
What we measured: KL divergence, in nats, shows how far the next-token probabilities move; 0 means no move. This shows closeness to llama.cpp, not a benchmark score: no BF16 reference is in our data. Same UD-Q6_K_XL file, llama.cpp scored along our tokens (teacher-forced), six items of 512 positions each, one estimator for every row. Our side is the debug build with the logit dump on, at production settings; its temperature-0 reference checks matched production.
| Pair | Mean KL divergence, top-256 lower bound | Top-1 agreement |
|---|---|---|
| Lamina against llama.cpp --fit | 0.003836 nats | 97.75 % |
| Lamina against stock llama.cpp | 0.003994 nats | 97.56 % |
| Stock llama.cpp against llama.cpp --fit | 0.002007 nats | 98.21 % |
By the same lower-bound estimator, our engine sits about twice as far from llama.cpp as llama.cpp's two placements of the same file sit from each other, 1.91x and 1.99x. The top token matches 97.75 % of the time, against 98.21 % between llama.cpp's two placements. All three means are under the 0.01 gate we set before the Lamina runs; we computed the llama.cpp row afterwards from the same dumps.
The box we tuned
We tune for the hardware we have. That is the point of performance tuning.
- A Lenovo ThinkStation P920: two Xeon Gold 6138 CPUs with 40 cores and 754 GiB of RAM, in two NUMA nodes: each socket is a node with its own memory, and reading the other node's memory is slower. The box ran both Q6 qualification windows with no memory-error deltas. Before them, one memory page had logged corrected errors.
- An RTX 3090 (24 GB) and an RTX 3060 (12 GB): consumer cards, and not equal. With the open-source gpu-unlock module the 3090 runs BF16 tensor math at 124.75 TOPS and the 3060 at 50.3, measured in a GEMM benchmark at 320 W and 160 W caps; in production the 3060 runs at 140 W.
- The engine gets 16 cores, 8 per socket. In the current layout no guest is pinned to their SMT siblings, the second hardware thread of each core. The +85 %, the window counters and both qualification windows (live rate, first token, steady-decode energy, and Railway, our graded agent task) predate that layout change, when one guest was pinned to 4 of the siblings and another had no CPU affinity. The GPUs are capped at 460 of their 520 W. The rest of the server serves other guests.
The model is Qwen3.8-Flash-Next in Unsloth's UD-Q6_K_XL quantization, which its file calls "A Preview of the Qwen4 Architecture". It is a mixture-of-experts (MoE) model: 512 routed experts per layer, 10 used per token, and 125 billion parameters besides its per-layer embedding tables. The GPUs hold the experts in each card's profile; a pool of CPU threads computes the rest.
Why Lamina: we moved from Strata to Lamina because Lamina is built for an asymmetric GPU workload like this one, one fast card, one smaller card and the CPU pool. We take it forward in our fork, Lomina.
The method
One loop produced every tuning result on this page.
- Measure. Start with the workload and the byte arithmetic. Bytes per token against memory bandwidth tells you what kind of problem you have, before any profile.
- Find the limit. A USE pass checks utilization, saturation and errors for every resource and names the one everything waits on.
- Change one thing, behind a switch that is off by default.
- Prove the output did not change. The temperature-0 output must hash equal to the reference before speed counts.
- Repeat on the next limit.
Each A/B in the Linux tables runs interleaved in one session, against a pass rule written before the run. Thread pinning did not run that way, so we print it as a range; where another comparison is not interleaved (the step chart, the spare core, the profile energy comparison), we say so. An effect counts only past its noise floor, max(2 x base spread, 1.5 %). Every number goes into a registry with its instrument and conditions, and a ratio mixes two instruments only where the page labels it, as against Strata.
| Instrument | What the number is |
|---|---|
| test collector | two or four 512-token streams from short prompts, temperature 0, the streams' engine rates summed |
| driver, wall clock | all output tokens of a case over the time from first request to last token |
| live rate | the engine's own 2 s rate over all decoding streams, under agent load |
| window counters | per decode step: CPU pool time, host wait for the GPU, CPU experts |
| energy | RAPL, the CPU's own energy counters, for each socket's package and DRAM, plus both GPUs' board power, per output token |
| perf, smaps, vmstat | flame graphs, page walks, page backing per mapping |
| output hashes | SHA-256 of every temperature-0 output, against a reference |
Linux tuning, measured
Decode on this box is the CPU pool streaming expert weights out of DRAM, so old-school Linux and memory settings show up directly in decode speed. Each A/B row except pinning ran interleaved against its base in one session and is graded against its noise floor; pinning ran A then B once per server start and is reported as a range. Every variant gave the reference output hashes.
| Technique | What it is worth on the current build | Why |
|---|---|---|
| Hardware prefetchers | switched off: one stream -12.2 %, two streams sampled -17.3 %, 32K decode -13.3 % | expert math is a long sequential read, the pattern the streamers are built for |
| KQ software prefetch with NUMA placement (KQ: the engine's CPU expert kernels) | both off: decode -16.2 to -18.9 % | more cache lines in flight per core |
| NUMA placement | arena interleaved instead: -3.4 % one stream, -4.3 % two streams, temperature 0 | each layer's experts sit half on each node, instead of one interleaved mapping |
| Huge pages on the expert arena | 32K prompt read 18.6 % faster; decode unchanged | physically contiguous 2 MiB chunks for the GPU copies (our hypothesis) |
| CUDA host registration of the arena | without it, decode 21 to 27 % slower and the 32K prompt read 60 % slower | the GPU copies by DMA only from registered pages |
| Thread pinning | a range, one run per server start: unpinned, 4 of 12 decode cases lost 6-18 %, the rest ran close to pinned speed | pinning buys predictable speed |
| Interrupt placement | a count, not an A/B: 0 GPU interrupts on the engine cores in about 75 s of load | handlers run on other cores |
The hardware-prefetcher and pinning rows ran on the production engine; the NUMA, KQ-prefetch, huge-page and registration rows on a debug build with its switches off, which gives outputs equal to production's. The debug build is our engine with extra GPU checks behind switches; where a check was on, we say so. Effects do not add up.
The huge-page row started with a counter. The process rollup showed 0 huge pages in the arena, while the kernel counted 52,129 huge-page faults and as many page-table splits at every start. One A/B answered it. CUDA registration splits the CPU's 2 MiB entries of an arena that faulted in on 2 MiB pages, and production already has the prompt-read gain. Keeping 2 MiB entries for the CPU would win under 1 % of cycles, so there was nothing to fix.
Where the time goes
Decode runs in verify windows: one step over every stream's last token and its draft. In each layer the RTX 3090, the RTX 3060 and the CPU pool compute their experts at once, and the layer waits for the slowest.
| Profile | Window | CPU pool | Waiting for the GPU | Experts served by a GPU |
|---|---|---|---|---|
| q6-dual, two streams | 33.02 ms | 28.7 ms, 87 % | 2.61 ms | 70.9-71.0 % |
| q6-quad, four streams | 50.27 ms | 45.82 ms, 91 % | 1.77 ms | 73.5-73.7 % |
The byte arithmetic says why the pool is the limit. One Q6 expert is 4,428,800 bytes, so a two-stream window streams about 2.24 GB of expert weights from DRAM. In a microbenchmark on this box, 15 synchronized threads read 82 GB/s. At that rate the window's expert bytes take 27.36 ms. The pool takes 28.7 ms, 1.05x that, so it runs close to the rate DRAM gives it. On q6-quad the pool reads at about that rate: 867.8 experts in 45.82 ms per window, a little above 82 GB/s in that run and a little below it in the other.
That is why the Linux work moves this number. With the hardware prefetchers off, each CPU expert takes 32.8 % longer. A faster GPU would not help much: the host waits only 2.61 ms of the window for it.
Two streams and four
Production traffic picks the default. In the engine's own records over 1,220 requests, our own checks and, on the newest build, mostly synthetic two-agent load included, one request was active for 74.2 % of busy time and two for 25.7 %; a third request had to wait for a free stream 0.3 % of busy time.
| Measure | q6-dual, the default | q6-quad |
|---|---|---|
| test collector, short prompts, temperature 0 | 102.5 / 103.6 tok/s | 130.3 / 136.8 tok/s |
| median total, every stream decoding, live rate under agent load | 96.7 tok/s | 103.6 tok/s |
| per stream, same samples | 48.4 tok/s | 25.9 tok/s |
| first token, median / p90, each at its own load | 5.2 s / 8.6 s | 7.0 s / 41.3 s |
| full context, prompts of about 254K tokens | two at once | four at once |
| qualification on Railway, 60 automatic points per agent client | agent clients Claude Code and Pi, 60 each | agent clients Claude Code and Pi (gating), DSH and Open WebUI (reported), at once, 60 each |
- Pick q6-dual for traffic like ours. With every stream decoding, a q6-dual stream runs almost twice as fast as a q6-quad one, 48.4 against 25.9 tok/s. At equal streams decoding it is still ahead: 69.1 and 96.7 tok/s with one and two, against 62.2 and 90.0. Its first-token tail is short.
- Pick q6-quad for planned multi-agent work. It serves the third and fourth agent instead of queueing them. With every stream decoding it gives 1.07x the total: 1.24x below 32K of context, about 0.95x at 96-128K from 29 q6-dual samples. With four streams decoding against q6-dual's two, it uses 11 % less energy per token in steady decode. Its cost is the prompt read: while one stream reads a prompt, the others nearly stop: -88 to -92 % in the live rate under agent load, and its first-token tail is longer.
Agents resend the whole conversation every turn. Turn reuse resumes a held conversation and reads only what is new, so turns 2 and 3 of a 100,000-token conversation reach their first token after 5.69 s and 2.93 s, against 34.52 s for the cold first read. On an earlier build, long follow-up turns resumed from saved state differed from a cold re-read of the same conversation in 7 of 8 conversations. The two sides also differed in build and settings, and the cause is not isolated. A Q4 profile, q4-dual, passed the same qualification and can be selected.
Same output, measured quality
No speed-up skips experts or truncates routing, and decode runs Lamina's exact expert path. Twelve GPU source files and the matrix library for prompt experts and verify projections are built with fast math, to match llama.cpp's CUDA arithmetic. The int8 KV cache does round. We keep it because it halves the cache; against fp16 it costs 0.00125 nats, a mean KL lower bound over the 481 tokens before the outputs first part, and with fp16 all seven test answers at temperature 0 changed, 2 to 116 tokens in. The BF16 read of the mixing matrices rounds too: 0.00112 nats against the file's 8-bit codes. Exact means: on the checked cases, at temperature 0, the engine gives its reference output byte for byte. We hash every checked output with SHA-256 and compare.
- Every Linux variant above and all nine prompt-read yield settings we measured (ten runs) gave the reference hashes. 102 seeded two-stream sampled cases gave the same outputs across the Linux variants.
- In the Linux measurement window, temperature-0 checks matched the reference 29 of 29 times on the production engine, 48 of 48 on the debug build and 12 of 12 on the four-stream profile.
- Across stream counts: 797 benchmark answers compared at different measured numbers of requests in flight were all byte-identical, 0 different.
- Against stock llama.cpp on the same weights, teacher-forced over 3,072 positions, the mean KL divergence lower bound is 0.003994 nats, under our pre-registered 0.01 gate.
- The CPU tests ran under AddressSanitizer, ThreadSanitizer and UBSan with 0 reports in our code. On the GPU tests the compute sanitizer still has open flags, one of them uninitialized reads in a hyper-connection kernel.
Two accuracy runs on the production profile: first the standard suites, then the long-context and tool-call suites (RULER and BFCL). Temperature 0, up to 16,384 output tokens per answer, scores as the tools print them:
| Suite | Items | Score |
|---|---|---|
| GSM8K | first 500 of 1,319 | 0.98 strict match, stderr 0.0063 |
| IFEval | all 541 | 0.915 prompt-level strict, stderr 0.0120 |
| MMLU-Pro | first 30 of each of 14 subjects | 0.843, stderr 0.0173 |
| HumanEval+ | all 164 tasks | 152 pass the plus tests |
| MBPP+ | all 378 tasks | 308 pass the plus tests |
| RULER (long context) | 13 tasks, first 5 items each at 4K to 128K tokens and 3 at 240K | the 9 retrieval tasks at 100 up to 240K tokens, with one partial miss at 64K and one at 128K; mean task score 81.54 to 84.62 per length |
| BFCL (tool calls) | first 50 of each of 7 categories | 302 of 350 correct, 0.863 |
| Q4 against Q6 | every item both files answered in these two runs and in a third, larger run: GSM8K 1,319, IFEval 541, MMLU-Pro 1,260, HumanEval+ 164, MBPP+ 378, BFCL 700, RULER 429 | pooled Q6 minus Q4 +0.1 points, 95 % CI -0.45 to +0.63, half-width 0.54: no measurable accuracy difference; per suite Q6 minus Q4 from -0.28 to +0.48 points, every 95 % interval includes zero |
On Railway, our exactly graded agent task, all eight final agent answers scored 60 of 60 on the automatic checks, across the three profiles. Claude Code and Pi are the gating clients; DSH and Open WebUI are reported, not gating, and their runs were not blind. The reviewed proof points are in the technical notes.
An eight-hour soak under four-stream load, on the debug build with its weight audit and launch ledger on, held every check: 1,828 cases with 0 errors, all 115 temperature-0 checks equal to the reference, 33 audit passes over the resident weights with 0 mismatches, 7,058 launch windows with 0 unordered overlaps, and engine memory flat at 106.55 to 106.57 GiB after the first 30 minutes.
Energy
In every driver case the measured draw, both CPU packages with their DRAM plus both GPU boards, other guests' CPU draw included, was about the same whatever the stream count: 490-541 W. So there, energy per token follows throughput. The way to spend less energy is to serve more tokens per second.
We use two measures and never mix them:
- Driver cases, prompt read included. Four streams on q6-quad use 6.8-13.1 % less energy per token than q6-dual at its best, two streams. The range spans four case means of three runs each, 4K and 32K prompts at temperature 0 and sampled; the runs were not interleaved. At 4K and temperature 0 that is 10.13 against 11.45 J/token.
- Steady decode under agent load. 5.97 J/token on q6-quad with four streams, 6.73 on q6-dual with two, 11 % less.
Long prompts cost the most: one stream with a 32K prompt takes 19.5 J/token, against 13.56 with a 4K prompt. The GPUs run under their power caps, about 12 % below stock.
Against llama.cpp
Same box, the same UD-Q6_K_XL file, the same 16 CPUs and power caps. Before any speed number counts, llama.cpp must pass a pre-registered output-validity rule in the same server process: a known answer, a byte-identical temperature-0 repeat, different text for the two natural 4K prompts, sampling that differs from temperature 0, and coherent text. Stock llama.cpp and llama.cpp --fit both passed it, and their output distributions are close to ours (the KL checks above and below).
In the Linux measurement window, three runs per case, our first token grew slowly with prompt length: 7.3 s at 4K, 8.0 s at 8K and 11.8 s at 32K. Over that range it fits a fixed cost of about 6.6 s, one pass of the experts through the GPU, plus about 6,100 tok/s at the margin.
Against llama.cpp's --fit placement, the faster valid configuration that loaded, under the pre-registered rules:
- One stream decodes 3.87x faster on a short temperature-0 prompt, 4.15x sampled, and 4.70x and 4.73x on a natural 4K prompt; we draft with MTP, llama.cpp ran without drafts.
- On the short prompts the two engines write different text: llama.cpp honors a zero reasoning budget and counts, Lamina reasons. The natural 4K prompt is the like-for-like case.
- Energy per output token is 2.17x to 7.38x lower, and the gap widens with prompt length.
- The outputs stay close: teacher-forced, the mean KL(Lamina || llama.cpp --fit) lower bound is 0.003836 nats over 3,072 positions, inside the 0.01 gate, with top-1 agreement 0.9775.
- llama.cpp with its MTP draft did not load in the two configurations we tried: it could not create the draft context.
- First token, in a later run of all three engines: on a short cold prompt llama.cpp --fit answers first, 1.71-2.11 s over five runs against our 3.8 s. From 4K up we do, and the gap grows with the prompt: at 31,356 tokens, one run each, 11.857 s against 152.088 s with --fit and 153.242 s stock.
What the method caught
- A silent race between our two GPU lanes. Output hashes caught answers that looked normal and left no log line. We gave the second lane its own buffer: 338 answers with both lanes on, 0 wrong (391 checked in all), while the unfixed control build still faulted in the same window.
- Detectors that see what hashes miss. With that race put back, the debug build caught it with one check switched on at a time: the launch ledger flagged it while the output still matched, and lane jitter turned it into a fault within two pairs.
- A queue that admitted requests out of order, in 3 of 3 trials. After the fix, arrival order in 8 of 8.
- An end-marker loop of 64 marker copies. The marker hold ended it, with no change in speed and the same output hashes on the reference prompts.
Your workload
The loop does not depend on this model or this box. On yours it looks like this:
- Read your own logs first: prompt sizes, prompt reuse, how many requests run at once.
- Do the byte arithmetic before you profile.
- Measure the noise first and write the pass rule before the run.
- Gate every speed change on an output hash.
- Size your profiles from measured concurrency.
On your box the limit may sit somewhere else. With one large GPU it may be VRAM or the GPU itself; with more memory channels the CPU pool may scale further. The Linux work comes first, because it costs no hardware. On this box switching off the hardware prefetchers alone costs 12.2-17.3 % of decode speed, and no Linux setting we tested changed an output byte on the checked cases.
Working with us
We are lomo.dev. We do performance analysis and tuning of Linux systems and LLM inference, and we start from the hardware you have.
See our projects at lomo.dev and get in touch through the contact form.
Technical notes
The depth behind the main page, for readers who want to check our numbers or repeat them on their own box.
Method
Instruments
The main page lists the instruments. Three more sit behind these notes: the driver's summed rate (the streams' engine-reported rates in one case), perf stat for TLB misses, IPC and memory-controller traffic per socket, and /proc/interrupts with nvidia-smi dmon for interrupts per core and GPU busy, power and PCIe traffic.
Four streams against two read differently on each instrument, which is why a ratio mixes two instruments only in the one labeled exception, the Strata comparison:
| Instrument | Load | Four streams against two |
|---|---|---|
| test collector | short prompts, temperature 0, earlier four-stream builds | 1.31x and 1.33x |
| live rate | agent load, all contexts, median over samples with every stream decoding and none reading, current profiles | 1.07x |
| live rate by context | the same windows, below 32K and at 96-128K | 1.24x and about 0.95x |
On the four-stream driver wall clock, on an older build, temperature 0 read 6.1 % above sampled in the same window. On the three runs behind the Strata comparison (four cached 32K second turns, temperature 0, current build), the wall clock reads 126.8 tok/s and the decode span 131.5.
Rules
- Interleave A and B in one session. Over one window our production drift control moved about 1 % on decode, while the 32K prompt read ran at 2,622 tok/s at the start and 2,366 at the end. Only interleaved runs survive that.
- Grade against a noise floor. An effect counts only past max(2 x the spread of the base runs, 1.5 %). Below it we print "no measurable effect".
- Same warm-up before every A and every B. A toggle inside a running server must be bracketed the same way on both sides, or a stream's held state leaks into the A rows.
- Wall clock for staggered starts. A sum of per-stream rates is not a wall rate when streams start apart.
- Matched pairs. Two runs with the same output hashes did the same work, so they compare cleanly.
- Write the pass rule before the run, and print what it says.
The base and the floor of each case in the paging and NUMA series, on a debug build with its switches off (outputs equal to production), 512 tokens per stream. T0 is temperature 0:
| Case | What runs | Base, range of four A runs | Noise floor |
|---|---|---|---|
| one stream T0 | short prompt, temperature 0 | 73.8-74.2 tok/s | 1.5 % |
| two streams T0 | short prompts, temperature 0 | 103.0-104.1 tok/s | 2.1 % |
| two streams sampled | seeded sampling | 93.2-95.5 tok/s | 5.0 % |
| 32K prompt read | prompt tokens over prompt time | 2,499-2,633 tok/s | 10.5 % |
| 32K decode | the answer to that prompt | 66.4-67.4 tok/s | 2.9 % |
| ms per CPU expert | window counters, two streams sampled | per arm | 7.1 % |
The prefetcher series on the production engine had its own floors: one stream 4.0 %, two sampled 9.9 %, 32K prompt read and decode 1.9 %, ms per CPU expert 13.8 %.
The USE pass on this box
| Resource | Utilization | Saturation | Errors |
|---|---|---|---|
| 16 engine CPU cores | busy median 36 %, p90 100 % over the q6-dual qualification window, idle time included | not measured | not counted |
| CPU pool | 87 % of the two-stream verify window, test collector, short prompts, temperature 0 | host wait for the GPU 2.61 ms of 33.02 ms | 0 non-finite events in the q6-dual window's 295 requests |
| DRAM, both sockets | pool at an implied 78.16 GB/s, bytes over pool time; peak 230.4 GB/s | not measured | 0 corrected-error deltas in the production window |
| RTX 3090 | SM busy median 98 %; power median 235 W, cap 320 W | not measured | not counted |
| RTX 3090 VRAM | room for 1,934 cached experts with two streams | minimum free 1,120 MiB | not counted |
| PCIe to the 3090 | host reads fitted at 12.6-12.8 GB/s | on q6-quad, long prompts wait on far K/V reads | not counted |
| TLB | page walks 0.9 % of cycles in an earlier capture, events multiplexed; 0.80-0.82 % in the paging series | - | - |
Decode points at the CPU pool and DRAM, the prompt read at the 3090, far K/V reads at PCIe. "SM busy" from nvidia-smi dmon means a kernel ran in the sample, not occupancy.
Linux tuning, full results
Current build. Each cell is the change against its base, production settings, with the technique off or changed, mean of three cycles; * marks an effect past the floor. The prefetcher row ran on the production engine and is graded on its own floors; every other row ran on the debug build. Effects do not add up.
| Change | One stream T0 | Two streams T0 | Two sampled | 32K prompt read | 32K decode | ms per CPU expert |
|---|---|---|---|---|---|---|
| hardware prefetchers off | -12.2 % * | not graded | -17.3 % * | -2.6 % * | -13.3 % * | +32.8 % * |
| NUMA split and KQ prefetch off | -16.3 % * | -18.2 % * | -16.2 % * | +1.9 % | -18.9 % * | +29.4 % * |
| NUMA split off, KQ prefetch on | -3.4 % * | -4.3 % * | -2.7 % | +1.6 % | -2.4 % | +3.4 % |
| huge-page advice off | +0.3 % | -1.9 % | -1.0 % | -15.7 % * | -0.7 % | -0.5 % |
| no host registration | -22.9 % * | -23.8 % * | -20.9 % * | -59.5 % * | -27.3 % * | -2.3 % |
| no registration, arena locked with mlock | -24.1 % * | -24.1 % * | -21.3 % * | -59.1 % * | -27.9 % * | -1.2 % |
| hugetlb arena, as placed | -12.0 % * | -12.1 % * | -12.0 % * | +1.9 % | -10.5 % * | +20.4 % * |
- Hardware prefetchers. MSR 0x1A4 bits 0-3 switch off the L2 streamer, the L2 adjacent-line prefetcher, the L1 data streamer and the L1 IP-stride prefetcher, here on the 16 engine CPUs and their siblings, in blocks A B A B A B A. CPU expert math is a long sequential read, so the streamers matter even with our software prefetch on. Leave them on.
- NUMA placement. Production places each layer's experts half on each node. Both arms hold half the arena on each node; one is split per layer, the other is one interleaved mapping.
- KQ software prefetch. KQ is the engine's name for its exact CPU expert kernels. With prefetch they ask for each expert's next weight blocks while the current ones are computed. On an older build, in the engine, they streamed 1.48-1.51x faster on one thread, and time per CPU expert fell 19.8 %. The 1.65x and 1.69x in the older-build table are a separate one-core microbenchmark. Also on an older build, four streams on the driver wall clock, prefetch distances of 2K, 8K and 16K gave 121.0, 120.1 and 120.1 tok/s against 120.4 at the default 4K.
- Host registration.
cudaHostRegisterpins the arena so the GPUs copy by DMA. Without it, GPU refills and prompt reads fall back to pageable copies.mlockdoes not replace it: it keeps pages in RAM, but the driver does not see them as registered. - hugetlb. The arena landed almost all on node 0: 103.1 of 104.4 GiB counted per node, against 52.2 / 52.2 in production, so this row measures NUMA placement, not pages.
Thread pinning, production engine, unpinned against pinned, once per server start:
| Case | Start 1 | Start 2 |
|---|---|---|
| one stream T0 | 74.09 to 67.95 tok/s, -8.3 % | +0.7 % |
| two streams T0 | -1.2 % | 103.06 to 92.46 tok/s, -10.3 % |
| two streams sampled, three runs | -3.4 %, -1.6 %, -1.8 % | -6.0 %, -17.5 %, +2.3 % |
| 32K prompt read | +0.2 % | +1.1 % |
| 32K decode | +0.4 % | -1.9 % |
In the worst unpinned run the pool took 34.1 ms per window, against 25.7-28.4 ms pinned.
Huge pages and the expert arena
How each arm backed the 101.8 GiB arena on the debug build. THP is transparent huge pages: the kernel backs memory with huge pages on its own. A PMD split breaks one huge-page entry into small-page entries.
| Arm | CPU page-table entries | Huge pages in RSS | THP faults / PMD splits at start | Model load | Decode page-walk cycles |
|---|---|---|---|---|---|
| production: advice on, registered layer by layer | 4 KiB | 0 | 52,129 / 52,129 | 151-156 s | 0.80-0.82 % |
| advice off, registered | 4 KiB | 0 | 0 / 0 | 105 s | 0.80-0.82 % |
| no registration | 2 MiB | 101.8 GiB | 52,129 / 0 | 25 s | 0.10 % |
| hugetlb | 2 MiB hugetlb | 101.8 GiB | 0 / 0 | 45 s | 0.10 % |
- Production faults the arena on physical 2 MiB pages, then CUDA registration splits every PMD. A 64 MiB CPU-only probe that maps, advises and touches memory the same way kept its huge pages, which pointed at registration.
- The page walks are the same in both registered arms, so the prompt-read gain is not CPU TLB reach. Our explanation, a hypothesis: physically contiguous 2 MiB chunks help the GPU's copies during the prompt read.
- With 2 MiB entries the walks fall to 0.10 % of decode cycles, so any TLB fix wins under 1 % of cycles.
- Registering hugetlb pages is fast: the model loads in 45 s instead of 155 s. A hugetlb arena with correct NUMA placement could make restarts about 110 s shorter, if it loads as fast as the misplaced one did. It needs per-node reservation and is not built.
Older-build results
These ran on earlier builds. They are correct for their build and are not the current number.
| Technique | Result |
|---|---|
| core sweep, one stream, 32K | 40 / 24 / 16 / 10 cores: 64.91 / 61.1 / 54.02 / 41.59 tok/s; prompt read flat |
| the spare core joins the pool | time per CPU expert -4.4 % and -5.4 %, two streams +3.2 % and +4.2 % across sessions, not interleaved |
| one core, a Q6_K weight row | 19-21 GB/s from L2, 4.8-6.4 GB/s from DRAM, 25 % slower from the other node |
| bandwidth, 15 synchronized threads, microbenchmark | 82 GB/s, 36 % of the 230.4 GB/s peak |
| software prefetch, one-core microbenchmark, 4 KiB ahead into L1 | 1.69x with local memory, 1.65x interleaved |
| AVX-512 exact Q6_K dot | bit-exact on 20,000 rows, 0.86-0.91x of AVX2: the loop waits on memory |
| SMT siblings, microbenchmark only | 84 GB/s without, 91 GB/s with; not run in the engine |
Other system settings
-
CPU profile. A flame graph of the current build under a two-stream temperature-0 test load on the production engine (eight test runs), 240,288 samples at 499 Hz over 75 s: 61.2 % of the samples end in our exact dot kernel, and 32.6 % end in frames without symbols.
Current build, production engine, two-stream temperature-0 test load: 240,288 samples at 499 Hz over 75 s; 61.2 % end in our exact dot kernel. -
Interrupts. On the 16 engine cores in about 75 s of two-stream load: NVIDIA 0, NVMe 7, local timer 541,193, function-call IPIs 11,801, TLB shootdowns 2,697.
-
CPU layout. No other guest runs on the engine's physical cores, and their sibling threads stay idle. Applied live, not measured as an A/B.
-
Governor.
powersavewith thebalance_powerpreference, left on purpose for efficiency. Not measured. -
Memory. DDR4-2400 in all channels.
-
Power caps. 320 W and 140 W against stock 350 W and 170 W.
Dense matrix multiply, TOPS, stock and with the gpu-unlock module, three repetitions per cell, at caps of 320 W (RTX 3090) and 160 W (RTX 3060; production uses 140 W):
| Precision | RTX 3090 | RTX 3060 |
|---|---|---|
| FP16 | 78.08 / 119.56 | 27.03 / 48.94 |
| BF16 | 77.52 / 124.75 | 27.03 / 50.3 |
| TF32 | 40.44 / 71.46 | 13.53 / 26.22 |
| INT8 | 62.1 / 64.2 | 24.5 / 24.56 |
Engine work
-
Per-card expert caches. Each GPU's cache is sized from its own free VRAM minus its own reserve. On q6-dual the 3090 caches 1,934 experts in 7.99 GiB and the 3060 holds 2,438 in 10.1 GiB; the 3090 also carries the dense layers, the K/V caches and the drafts.
-
Split windows. The CPU pool works on one group of streams while the GPU runs the other group's mixer and router. With four streams on an older build: 107.9 to 125.2 tok/s, and the GPU wait fell from 12.9 to 3.8 ms per window.
-
GPU lanes. Two CUDA streams run both groups at once: 3-4 % for two Q6 streams, about 11 % for Q4, older builds.
-
Exact dp4a kernels. dp4a is the GPU instruction that adds four 8-bit products to a 32-bit integer sum. Integer sums are the same in any order, so the GPU reorders integer work and keeps every float step in the CPU's order. Word loads cut the grouped Q6 kernel from 148.6 to 99.5 us, older build, kernel microbenchmark, 11 experts.
-
Two-tier K/V. On q6-quad the first 32,768 cells of each stream stay in VRAM, the rest in host RAM, read over PCIe. Fewer near cells leave room for more cached experts: 2,106 at 65,536 near cells, 2,468 at 32,768.
-
Far stage. Long prompt chunks run each attention layer on a VRAM copy of the earlier cells. We predicted 32 s and 76 s to first token for two long prompts and measured 32.3 s and 78.5 s.
-
Prompt-read yield. Decoding streams get windows at safe points inside a prompt read; every setting gave the reference hashes. Across nine settings (ten runs, production's twice), more yielding lifts the other streams during the read, but the read grows more than they gain. No setting finished the case faster than production's 500 ms with one window, 98.0 and 98.6 s; the nearest, 500/2, took 99.3 s, one run each.
Nine yield settings on q6-quad, one run each, the production setting twice: more yielding lifts the other three streams during the read but lengthens the read more. -
FIFO queue. Waiting requests take a free stream in arrival order: 3 of 3 trials were out of order before, 8 of 8 in order after. With cached prompts the first token came after 0.5 s with one stream and 1.4-1.5 s with four, on an older build.
Every request of each qualification window: median first token 5.2 s, p90 8.6 s on q6-dual; 7.0 s and 41.3 s on q6-quad. Most resumed requests start within seconds at any prompt size.
Patches
Lomina is upstream Lamina plus our patches: 67 in the build this page covers. Each effect is the patch's own, on the build named; they do not add up. Every patch is one commit in Lomina's repository, listed by area with links in its patch list.
| Patch | Change | Measured effect |
|---|---|---|
| 0018 | huge-page advice on the expert arena | 32K prompt read 18.6 % faster, debug build |
| 0019 | per-request window counters | the time-division instrument |
| 0020 | the spare core joins the pool | two streams +3.2 % and +4.2 %, older build, across sessions, not interleaved |
| 0021, 0022 | prefetching exact pool kernels | time per CPU expert -19.8 %, older build |
| 0023 | NUMA-split expert arena, each layer's experts half on each node | without it, -3.4 % one stream and -4.3 % two streams, temperature 0, debug build |
| 0025 | one shared copy of the draft weights | two streams 89.0 against 84.8 tok/s, ranges overlap, older build |
| 0026 | slot resume (a slot is the engine's name for one stream's state) | second stream's first token at full context after 174 s instead of 261 s, older build |
| - | turn reuse | turns 2 and 3 of a 100,000-token conversation after 5.69 s and 2.93 s, against 34.52 s for the cold first read; see Limits for resumed long turns |
| 0031 | split two-stream windows | two streams 86.9 to 91.0 tok/s, three interleaved pairs, older build |
| 0032 | exact dp4a GPU kernels with word loads | grouped Q6 kernel 148.6 to 99.5 us, older build, kernel microbenchmark, 11 experts |
| 0033 | two entries per weight load | two-entry Q6 kernel 156.3 to 112.5 us, older build, kernel microbenchmark |
| 0034 | two concurrent GPU lanes in split windows | Q6 3-4 %, Q4 about 11 %, older builds |
| lane fix | the second lane gets its own expert-input buffer | 338 answers with both lanes on, 0 wrong (391 checked) |
| 0067 | marker hold | no speed change, reference hashes unchanged |
Switches
Every switch is off unless set.
| Switch | What it does | Where |
|---|---|---|
--expert-math exact | every routed expert in ggml's CPU accumulation order, on any device | always |
--spec 2 | MTP drafts: each stream verifies its last token plus one draft per window | production |
--pcie-frac 0 | no PCIe reads of missed experts during decode | always |
--batch 4 | four isolated streams in one engine | q6-quad |
LAMINA_BATCH_CONCURRENT=1 | two GPU lanes in split windows, with the lane fix | production |
LAMINA_KV_NEAR_CELLS=32768 | first cells of each stream in VRAM, the rest in host RAM | q6-quad |
LAMINA_KV_FAR_STAGE=1 | far prompt chunks run on a VRAM copy | q6-quad |
LAMINA_BATCH_SPLIT_MULTI=1 | three- and four-stream windows in two groups | q6-quad |
LAMINA_PREFILL_YIELD_MS=500 | decode windows at safe points inside a prompt read, one per safe point | q6-quad |
LAMINA_QUEUE_FIFO=1 | waiting requests take a free stream in arrival order | q6-quad |
LAMINA_KV_ZERO_BOUNDED=1 | a reset zeroes only the used part of the host tier | q6-quad |
LAMINA_BATCH_NAN_RECOVER=1 | replay, isolate or fail closed after a non-finite window | q6-quad |
LAMINA_MARKER_HOLD=1 | a named marker's text waits for the next token | current profiles |
| debug build switches | weight audit, launch ledger, lane jitter, logit records | qualification only |
Exactness and accuracy detail
Precision through the pipeline
The model file sets the weights, and the engine sets everything after them. We read both: the file's tensor headers and bytes, and the engine source behind the production flags.
| Stage | In production | Engine default |
|---|---|---|
| Routed expert weights | 6-bit gate and up (Q6_K) in 47 of 48 layers, 8-bit (Q8_0) in one; 8-bit down (Q8_0) | as the file |
| Other weights | 8-bit (Q8_0); router and norms F32; indexer BF16 | as the file |
| Expert math, decode | exact: the CPU's ggml arithmetic on both GPUs and the CPU, 8-bit activations, FP32 sums in a fixed order | fast: llama.cpp's CUDA arithmetic |
| Hidden state and recurrent state | FP32 | same |
| Rotary angles | FP32 values from a float64 table | a fast-math angle |
| Fast math | 12 GPU source files and the matrix library built with fast math, to match llama.cpp's CUDA arithmetic: fast exponentials in the router and attention softmax, approximate divides in the MoE combine, flush to zero | same |
| KV cache | int8 with one FP16 scale per 64 values | fp16, twice the memory |
| Attention | integer dot products on the int8 keys, FP32 softmax | |
| Logits | FP32 | same |
| Prompt path | FP16 and BF16 tensor-core math, as in llama.cpp CUDA | same |
Exact expert math is about sameness: in decode, the exact path is built so that an expert gives the same bits on either GPU and on the CPU, and the engine's 34 bitwise GPU parity tests pass. On the checked cases, 797 of 797 temperature-0 answers were the same at different numbers of requests in flight, 750 of them also on both production profiles. The draft model only proposes tokens; the full model checks every one, so a draft cannot put a token in the output that the full model did not choose.
The engine also rounds a few tensors on load. The file's bytes show what that costs:
- The F32 tensors it reads as BF16 (router, shared-expert gate, two recurrent-layer gates, hyper-connection inject) are already BF16-exact: 75,816,960 of 75,816,960 values, so the read loses nothing.
- The 8-bit hyper-connection and output mixing matrices are re-rounded to BF16: 31,409,509 of 32,768,000 sampled values change, by 0.141 % on average and at most 0.389 %.
- 101 of 40,960 per-layer convolution values, each at most 7.6e-6 in size, round in F16 by at most 3e-8.
The KV cache is the one stage below the engine default. int8 halves the cache, and on the RTX 3090 memory is the tight resource. We measured what it costs. Against an fp16 cache, the KL lower bound averages 0.00125 nats (largest 0.028; the top 256 cover at least 0.990 of the mass) over 481 positions, up to where the two runs first pick a different token, 2 to 116 tokens in. For scale, our engine against stock llama.cpp, teacher-forced over 3,072 positions with both caches 8-bit, is 0.003994 nats. Reading the mixing matrices as the file's 8-bit codes, with no BF16 step, moves the distribution by a similar 0.00112 nats over 223 positions.
The debug build's GPU checks
The debug build carries four checks behind switches:
| Check | Result |
|---|---|
| all switches off, and all four on together | temperature-0 output equal to the reference |
| weight audit | 5 passes, 0 mismatches, about 4,340 experts and 1,078 dense regions per pass |
| lane jitter | 2,000 windows, no hang; soaked alone, 17,000 windows, 0 errors |
| launch ledger | 6 window shapes, 0 unordered overlaps |
| logit records | 8,192 records for 8,192 tokens |
| cost with everything on | about 2x slower: 26 against 53 tok/s per stream |
The controls, on the debug build with the old lane race put back and one check switched on at a time: without any check, 6 of 6 two-stream temperature-0 pairs still equal the reference. The ledger flags 3 two-lane windows while the output still matches, and jitter turns the race into a fault within two pairs.
The lane race itself: the second lane shared the expert-input buffer with the first. Rows are 2,920 bytes in most layers and 2,720 in the one Q8_0 layer, so a lane one layer ahead overlapped the other's rows by 200 bytes. After the fix: 338 lanes-on answers among 391, 0 wrong, over 160,508 lanes-on windows.
Test tiers
-
CPU tests under sanitizers. 31 tests pass under AddressSanitizer with UBSan and under ThreadSanitizer. Reports: ASan 0, LSan 0, TSan 0, UBSan 2, both in vendored llama.cpp code for a weight format neither model file uses.
-
GPU parity under the compute sanitizer. In plain runs, 34 GPU parity tests pass bitwise. memcheck found one bug, in test code, and passes on the fixed test. initcheck passes 28 of the 34 tests (4 flagged, 2 timed out) and synccheck 31. Three flags matter for the engine, all open: an uninitialized read inside one hyper-connection kernel, a barrier pattern in the attention kernel, and an initcheck flag in the two-tier K/V test, a feature q6-quad uses. That kernel's warps sync on named barriers with thread counts, which PTX allows and synccheck may misread; we have not proven it either way. Production temperature-0 output matched the reference in every check of the Linux measurement window. The other flags: a test copying a partly written buffer, and the draft model's proxy head, whose proposals the full model checks. racecheck has finished on 19 of the 34 GPU tests: in the last run one more finished clean, with 0 hazards, and two hit a 10-minute cap. The other 15 are not covered, because under racecheck they run far longer than their plain runs.
-
Same answers across stream counts. The matrix paired the same temperature-0 items between q6-quad at nominal 1, 2 and 4 streams and q6-dual at 2: 0 different in all six label pairs. The same-answers count includes an item only when its hash was compared across at least two distinct measured in-flight counts: 797 counted, 797 identical, 750 of them also answered on both profiles. By measured in-flight set: 627 items at 2 and 4, 90 at 1 and 2, 69 at 1, 2 and 4, and 11 in sets with 3 or 5; 5 in flight is a request waiting in the queue beside four running. The rule is pre-registered for the four-stream core and post hoc for the subset rows, which were graded before it was written. The long-context and tool-call run is not in the count. A pilot gave 47 of 47 identical answers at 1 and 2 streams.
-
Standard suites. The first of three accuracy runs. Every planned item answered once: 2,003 requests, 0 screened out, 0 retries; 44 answers hit the 16,384-token cap and are scored as model results. lm-eval takes the first N items of each task in dataset order; evalplus runs every task. GSM8K strict 0.98 (stderr 0.0063), IFEval prompt strict 0.9150 (0.0120), MMLU-Pro 0.8429 (0.0173); HumanEval+ 156 base / 152 plus of 164, MBPP+ 356 base / 308 plus of 378. Each MMLU-Pro subject has 30 items, so we do not rank subjects. We do not compare these scores with scores published for other builds of the model. Q4 against Q6 on every item of the first two accuracy runs and of a third run with 2,009 new items (GSM8K items 500 to 1,318, MMLU-Pro items 30 to 89 of each subject, BFCL items 50 to 99 of each category), 4,791 pairs: Q6 minus Q4 per suite from -0.28 to +0.48 points, and no suite's 95 % paired-bootstrap interval excludes zero. Pooled, Q6 minus Q4 is +0.1 points, 95 % CI -0.45 to +0.63, half-width 0.54: no measurable accuracy difference, by the rule fixed before that run. In that run the Q6 BFCL answers and the last Q4 BFCL answer were capped at 32,768 tokens; the other 349 Q4 answers ran uncapped, the longest 23,222 tokens, so the cap changed none of them. That last Q4 answer repeated one line until the cap; on Q6 the same item ran 25,999 tokens and stopped. Neither made a function call, so BFCL scores both correct and the item adds nothing to the difference. The four-stream profile is checked by its answers, not by scores: the same-answers counts above.
-
Long context and tool calls. The second accuracy run sent 779 requests, all answered, 0 screened out. RULER runs its own prompts at 4K, 8K, 16K, 32K, 64K, 128K and 240K tokens. The retrieval tasks score 100 at every length except niah_multivalue at 64K (80) and vt at 128K (96); qa_1 scores 100 at every length and qa_2 60 to 100. The two aggregation tasks, cwe and fwe, mostly reason until the 16,384-token cap without a final answer and score 0 to 20. BFCL: simple_python 49, multiple 45, parallel 43, parallel_multiple 43, irrelevance 40, live_simple 44, live_multiple 38, each of 50.
-
KL against stock llama.cpp. Teacher-forced, our top 256 logits; a token llama.cpp did not keep gets its 256th log-probability, which can only lower each term, and tokens outside the top 256 are left out, so each value is a lower bound up to that small tail. Per item the mean ranges from 0.002262 to 0.005312 nats; the top 256 cover at least 0.972464 of the mass. Two positions are above 0.1 nats, next to each other in one item. Against the --fit configuration: 0.003836 nats over 3,072 positions, per item 0.002223 to 0.005157, top-1 agreement 0.9775. llama.cpp against itself, stock against --fit on the same positions and the same estimator, over stock's top 256: 0.002007 nats, per item 0.000892 to 0.003014, top-1 agreement 0.9821, no position above 0.1 nats. The two llama.cpp arms are the same release and file, both with an 8-bit (q8_0) KV cache; stock keeps every expert layer's weights in CPU memory with one GPU and --fit off, --fit lets llama.cpp place them. We computed this row afterwards; it was not pre-registered. Our side is the debug build with the logit dump on, at production settings; its temperature-0 reference checks matched production.
Teacher-forced, 512 positions per item, temperature 0: the overall mean lower bound, and every item's, sits under the 0.01-nat gate set for the overall mean. -
Soak. 29,145 s under four-stream load (three sampled rounds of four bodies per block, a temperature-0 canary between blocks) on the debug build, the q6-quad configuration, with the weight audit every 15 minutes and the launch ledger on. 1,828 cases, 0 errors; 457 canaries; 115 checks against the reference, all equal; 33 audit passes, 0 mismatches; 7,058 windows checked by the ledger, 0 unordered overlaps, 0 cycles. Engine memory 106.55 to 106.57 GiB after the first 30 minutes; CPU packages at most 76 C, GPUs at most 79 and 76 C; at least 1,370 and 1,272 MiB of VRAM free; no new corrected memory error and 0 uncorrected. The soak's speed is the debug build with its checks on, not production speed.
Railway reviewed points. Each final answer has 60 automatic points from the grader and 40 reviewed points for its proof and semantics. Two LLM-assisted reviewer passes score each answer, two contexts of one model, not independent reviewers, and the range is the two pass totals out of 40. It is a fallible assessment, not a proof certificate. Fields, counts and optima were right in every reviewed answer; the points were lost on supporting formulas and derivations. Claude Code and Pi are the gating clients; DSH and Open WebUI are reported clients, and their runs were not blind:
| Profile | Claude Code | Pi | DSH | Open WebUI |
|---|---|---|---|---|
| q6-dual | 21-22 | 38 | - | - |
| q6-quad | 26-30 | 30-31 | 33-37 | 28-30 |
| q4-dual | 27-30 | 33 | - | - |
Energy detail
Driver cases, J per output token, prompts read uncached, three runs each:
| Case | q6-dual | q6-quad |
|---|---|---|
| 1 stream, 4K, T0 | 13.56 | 13.02 |
| 1 stream, 32K, T0 | 19.5 | 19.13 |
| 2 streams, 4K, T0 | 11.45 | 11.25 |
| 2 streams, 32K, T0 | 17.35 | 16.86 |
| 4 streams, 4K, T0 | - | 10.13 |
| 4 streams, 32K, T0 | - | 16.04 |
- Every case's runs lie within -2.1 % and +2.4 % of their mean.
- Of the 18.6 s span of the one-stream 32K case, about 12 s is the prompt read.
- In the one-stream 4K case on q6-dual the GPUs take 8.18 J/token and CPU plus DRAM 5.38.
- Idle with the model loaded: 263 W on q6-dual, of which the RTX 3090 125 W, the RTX 3060 41 W and CPU plus DRAM 97 W; 266 W on q6-quad.
- Steady decode under agent load: q6-quad 9.52, 7.24, 6.83 and 5.97 J/token with one to four streams decoding; q6-dual 8.90 and 6.73 with one and two.
Measure it yourself
You need numactl, perf (linux-tools for your kernel), msr-tools and the NVIDIA utilities. Profiling another user's process needs root, and perf may need a lower kernel.perf_event_paranoid; do not lower it for good on a shared host. Set PID=$(pgrep -n <name>) and CPUS=<the engine's CPU list>. Event names vary by CPU; perf list shows yours.
Topology, placement and bandwidth
lscpu -e=CPU,NODE,SOCKET,CORE,ONLINE # siblings repeat a CORE value
numactl --hardware # nodes, CPUs, memory, distances
numastat -p $PID # one process's memory per node
taskset -acp $PID # affinity of every thread
ps -L -o tid,psr,comm -p $PID # psr: the CPU each thread last ran on
# STREAM: size each array at least four times the combined last-level caches
gcc -O3 -fopenmp -mcmodel=medium -DSTREAM_ARRAY_SIZE=100000000 stream.c -o stream
numactl --physcpubind=0 --membind=0 ./stream # one thread, local memory
OMP_NUM_THREADS=16 OMP_PLACES=cores OMP_PROC_BIND=spread numactl --interleave=all ./stream
# memory-controller traffic per socket (event names for this CPU family)
perf stat -a --per-socket -e uncore_imc/cas_count_read/,uncore_imc/cas_count_write/ -- sleep 20
Pages, THP and the TLB
Read the page backing per mapping. The process rollup sums everything and hides which mapping holds what.
cat /sys/kernel/mm/transparent_hugepage/enabled /sys/kernel/mm/transparent_hugepage/defrag
# THP faults and PMD splits: read before and after the engine starts, then take the delta
grep -E '^(thp_fault_alloc|thp_fault_fallback|thp_split_pmd) ' /proc/vmstat
# per mapping: size, huge pages and flags (hg = MADV_HUGEPAGE applied) of every mapping of 1 GiB or more
awk '/^[0-9a-f]+-[0-9a-f]+ /{m=$0} /^Size:/{s=$2} /^AnonHugePages:/{a=$2}
/^VmFlags:/{if (s >= 1048576) print s" kB", a" kB huge", $0, m}' /proc/$PID/smaps
# page-walk cycles on the engine CPUs: walk share = walk_active / cycles
perf stat -C $CPUS -e cycles,instructions,dtlb_load_misses.walk_active,dTLB-loads,dTLB-load-misses -- sleep 30
If the THP fault count equals the PMD split count at every start, something splits your huge pages after they fault in. On our box it was CUDA host registration.
Hardware prefetchers: save, toggle, restore
On our CPU family MSR 0x1A4 bits 0-3 turn the four prefetchers off. Check your CPU's documentation first, and toggle a core and its sibling thread together.
modprobe msr
cat /proc/sys/kernel/tainted # note the value before you start
expand() { echo "$1" | tr ',' '\n' | while IFS=- read a b; do seq "$a" "${b:-$a}"; done; }
ALL=$(for c in $(expand "$CPUS"); do
expand "$(cat /sys/devices/system/cpu/cpu$c/topology/thread_siblings_list)"; done | sort -nu)
for c in $ALL; do echo "$c $(rdmsr -p $c -c 0x1a4)"; done > msr-1a4.save # save
for c in $ALL; do v=$(rdmsr -p $c -c 0x1a4); wrmsr -p $c 0x1a4 $(printf '0x%x' $(( v | 0xf ))); done # off
while read c v; do wrmsr -p $c 0x1a4 $v; done < msr-1a4.save # restore
for c in $ALL; do echo "$c $(rdmsr -p $c -c 0x1a4)"; done | diff - msr-1a4.save && echo restored
Writing an MSR sets the kernel taint flag S until the next reboot. If a watcher on your host reads the taint flags, tell its owner first.
Interrupts, CPU profiles and GPUs
cat /proc/interrupts > irq.before; sleep 75; cat /proc/interrupts > irq.after
diff irq.before irq.after | less # per-CPU deltas; check the engine's columns
perf record -F 499 --call-graph lbr --no-buildid-cache -p $PID -- sleep 75
perf script > out.perf
stackcollapse-perf.pl out.perf > out.folded && flamegraph.pl out.folded > out.svg
nvidia-smi topo -m # NV# is NVLink; PHB, NODE or SYS go through the CPU
nvidia-smi dmon -s pucm # power, utilization, clocks, memory, once a second
nvidia-smi -i <gpu> -pl <watts> # set a power limit (root)
--no-buildid-cache keeps perf from hard-linking your binaries into its cache. Check that hot frames have names before you read shares.
Energy and exactness
# RAPL: read energy_uj at the start and the end of a case; handle wrap with max_energy_range_uj
for z in /sys/class/powercap/intel-rapl:*; do echo "$z $(cat $z/name) $(cat $z/energy_uj)"; done
perf stat -a -e power/energy-pkg/,power/energy-ram/ -- sleep 20
nvidia-smi --query-gpu=index,power.draw --format=csv,noheader,nounits -lms 1000 > gpu-power.csv
# a temperature-0 request; hash the content and compare with your reference
curl -s -H 'Content-Type: application/json' -d @request-t0.json \
http://localhost:<port>/v1/chat/completions | jq -r '.choices[0].message.content' > out.txt
sha256sum out.txt reference.txt
RAPL covers whole sockets, including any other guest's draw, so the CPU side is an upper bound.
Limits
-
Exactness covers the checked cases, at temperature 0 and with seeded sampling. Unseeded traffic, such as production requests and Railway agents, cannot be hash-checked.
-
The GPU sanitizer flags on the engine are open. One is uninitialized 4-byte reads in a hyper-connection kernel, and we have not shown whether they can change an output. Production temperature-0 output matched the reference in all 29 checks of the Linux measurement window, and 797 of 797 temperature-0 answers were identical across stream counts.
-
On an earlier build, long follow-up turns resumed from saved state differed from a cold re-read of the same conversation in 7 of 8 conversations. The two sides also differed in build and settings. The cause is not isolated.
-
Pinning is a range, n = 1 per server start. The hardware prefetchers at two-stream temperature 0 are not graded.
-
Not run: KQ prefetch alone with the NUMA split on,
mlockon top of registration, a hugetlb arena with correct NUMA placement, SMT siblings in the engine, a governor change, our engine with the gpu-unlock module off. -
The paging and NUMA series ran on the debug build; the prefetchers, pinning, energy and the four-stream Strata comparison on the production engine. Effects are compared inside one series, never absolute rates across the two.
-
On q6-quad a prompt read stalls the other streams. Nine yield settings were measured in ten runs and none removes it; that needs a scheduler change.
-
On q6-quad, 26 big misses read 2,111,478 prompt tokens again; 21 of them came after a probe or a DSH side request took a slot that held an agent conversation. The slot-choice fix comes after this report.
Share of each client's prompt tokens resumed or restored by turn reuse, engine admission records: 88.7-96.1 % on q6-dual, 60.0-88.6 % on q6-quad, where small requests evicted held conversations. -
In the driver cases, at equal stream counts q6-quad measured 0.8-4.9 % less energy per token than q6-dual. The range spans eight case means of three runs each: one and two streams, 4K and 32K, temperature 0 and sampled; the table above shows the temperature-0 cases. The runs were not interleaved. In steady decode under agent load q6-quad measured more, 9.52 against 8.90 and 7.24 against 6.73 J/token, separate windows. Neither difference is isolated.
-
The qualification windows run synthetic agent load. The production concurrency counts span earlier production versions and include our own checks.
-
The reviewed Railway points are an LLM-assisted, fallible assessment.
-
Q4 and Q6 were both scored on every item of the three accuracy runs: all of GSM8K, IFEval, HumanEval+ and MBPP+, the first 90 items of each MMLU-Pro subject, the first 100 of each BFCL category, and the 429 RULER items. The 95 % CI half-width of the 4,791-item paired sample is 0.54 points pooled and about 0.6 to 2.4 points per suite, so smaller differences cannot be told from zero. The weight audit has no GPU positive control yet.
-
Stock llama.cpp ran as configured, an untuned split: every expert layer on the CPU and one GPU, about 21 GB of VRAM unused. The llama.cpp speed and energy comparisons use llama.cpp --fit instead, the faster valid configuration that loaded.
-
The Strata comparison crosses instruments; its conditions line names both. That Lamina's design for unequal GPUs explains our results against Strata is our stated reason and is not isolated.
-
Huge pages have two costs. The advice makes model load slower, 151-156 s against 105 s. And during an earlier corrected memory error, before both qualification windows, the kernel could not soft-offline the failing page inside the huge-page arena. Neither window nor the later soak logged a new memory error.
-
The KV cache and mixing-matrix costs are measured as KL on seven temperature-0 items, up to the first different token, not on the accuracy suites.
-
All results come from one host. We did not measure profiler overhead.
References
Method names (the USE method, workload characterization, time division, CPU profiles, active benchmarking, static performance tuning) and the flame graph conventions follow Brendan Gregg's published work. None of these projects or authors endorses this page.
- Brendan Gregg, The USE Method
- Brendan Gregg, Performance Analysis Methodology
- Brendan Gregg, Active Benchmarking
- Brendan Gregg, CPU Flame Graphs and the FlameGraph tools
- Brendan Gregg, Systems Performance: Enterprise and the Cloud, 2nd edition.
- John McCalpin, STREAM
- Zagitta, gpu-unlock
- Strata (MIT)
- Lamina, the Strata fork we build on (MIT)
- llama.cpp and ggml (MIT), whose CPU code defines our reference order
- Lomina, Lamina plus our patches
- Lomina's patch list, one commit per patch
- Qwen3.8-Flash-Next and Unsloth's UD-Q6_K_XL and UD-Q4_K_XL quantizations
- Unsloth Dynamic 3.0 GGUFs, the method behind those quantizations
- EleutherAI lm-eval
- EvalPlus (HumanEval+, MBPP+)
- GSM8K
- IFEval
- MMLU-Pro
- NVIDIA Compute Sanitizer
- RULER
- Berkeley Function Calling Leaderboard (BFCL)
Glossary
| Term | Meaning |
|---|---|
| arena | the host memory that holds every routed expert's weights |
| CPU pool | the worker threads that compute the experts no GPU holds |
| debug build | an engine build with extra GPU checks behind switches; it runs with its switches off unless we say otherwise, and then its outputs equal production's |
| dp4a | a GPU instruction that adds four 8-bit products to a 32-bit integer sum |
| host registration | cudaHostRegister: pinning host memory so a GPU can copy from it by DMA |
| KL divergence | how far one next-token probability distribution is from another; 0 means equal. Ours are lower bounds, computed over the top 256 tokens |
| KQ | the engine's name for its exact CPU expert kernels; KQ prefetch is their software prefetch |
| live rate | the engine's own decode rate over all decoding streams, under agent load |
| MoE | mixture of experts: each layer holds many expert blocks, and a router picks a few of them for each token |
| MTP | multi-token prediction: a layer trained with the model to predict the token after the next; the engine uses it to draft tokens that the full model checks |
| nats | the unit of KL divergence when it is computed with natural logarithms |
| near tier, far tier | K/V cells in VRAM; K/V cells in host RAM, read over PCIe |
| NUMA | non-uniform memory access: each socket is a node with its own memory, and reading another node's memory is slower |
| page walk | the CPU reading the page table after a TLB miss |
| PMD split | the kernel breaking one huge-page entry of the page table into small-page entries |
| prompt read | the engine reading the prompt before its first output token; other tools call it prefill |
| qualification window | hours of agent load, a soak and vision probes, with pass rules fixed before it starts |
| Railway | our graded agent task: agent clients solve it against the engine, and a grader checks 60 points automatically |
| RAPL | the CPU's running-average-power-limit counters: energy used by each socket's package and DRAM |
| slot | the engine's name for one stream's state inside the engine: its K/V cells and recurrent state |
| SMT | simultaneous multithreading: two hardware threads share one core; each is the other's sibling |
| stream | one request in progress in the engine; q6-dual serves up to two at once, q6-quad up to four |
| T0 | temperature 0: the model takes its most likely token at every step |
| THP | transparent huge pages: the Linux kernel backs memory with huge pages on its own |
| verify window | one decode step over every stream's last token and its draft |
Questions about this report, or tuning work of your own: work with us at lomo.dev/contact. The web version of this report: perf.lomo.dev. Lomina's patches, one commit each: github.com/lomolabs/lomina.