Layer-Hot Decoding: A Second Token per Weight Pass Ran at 0.87x of Plain Decoding on an M4
layer-hot-decoding is an open-source proof of concept. It tests one idea for making a language model write faster on a laptop. On this machine the idea does not beat the existing tools, and the work stopped at a gate set before it began. The code, plans and result files are on GitHub.
Every figure below is Measured on one MacBook Air M4 with 16 GB of memory, with Qwen3 models at 4 bits, between 14 and 16 November 2026.
Summary
- Measured, 14 November 2026: on MLX, a second token in the same pass over the weights cost 2 to 11% extra (Qwen3 0.6B, 1.7B and 4B). On llama.cpp it cost 38 to 57%.
- Measured, 14 November 2026: a guess made after the first 1 to 8 layers matched the full model's next token 27 to 40% of the time, mostly on punctuation and short function words.
- Measured, 15 November 2026, Qwen3 4B, 12 prompts run twice: the loop ran at 0.87x the speed of plain decoding in mlx-lm. No prompt was faster.
- Measured, 15 and 16 November 2026, Qwen3 4B: the fastest existing tool on this machine, llama.cpp with a DFlash2 drafter at 8 bits, ran at 1.22x its own plain decoding. EAGLE-3 ran at 0.64 to 0.82x.
- Measured, 16 November 2026, Qwen3 4B: a guess head that also reads the previous token's final state was right 28.9% of the time. With the token's plain embedding in place of the layer-hot input it was right 29.4%.
The idea
A language model reads all of its weights once for every token it writes. On a laptop the reading takes most of the time, not the arithmetic. So while a layer's weights are loaded, a second token could go through the same layer for little extra cost.
That second token is a guess. A small trained head (the guess head) makes it from the first token's state after only the first 1 to 8 layers. The full model then checks the guess in the same pass. A wrong guess is thrown away, so the text is the same as the model's plain greedy output, and every pass still produces at least one token.
The idea pays only if two things hold:
- A second token in one pass costs much less than a second pass.
- The guess is right often enough.
Each was measured on its own before the full loop was built. The plan, with its gates, was written on 14 November 2026 before any measurement, and is in the repository unchanged.
Setup
- Machine: MacBook Air M4 (Mac16,12), 16 GB, no fan, on the charger.
- Models: Qwen3 0.6B, 1.7B and 4B at 4 bits, from mlx-community on MLX and as Q4_0 files from unsloth on llama.cpp.
- Software: Python 3.12.11, mlx 0.32.4, mlx-lm 0.32.2, llama.cpp
e3483e4(master of 14 November 2026), dflash-mlx 0.1.8.
Each run saves the machine's state next to its numbers. A round was thrown out if the laptop was on battery, the processor was under 90% idle before it started, the system reported a speed limit, memory swapped to disk, or free disk was under 5 GB. Speed comparisons ran plain, loop, loop, plain on each prompt in one process after a warm-up, because this laptop slows its GPU by 15 to 25% after a few minutes of load.
A second token costs 2 to 11% on MLX
Measured, 14 November 2026, 512 tokens of context. The figure is the time of one pass with two tokens divided by the time of one pass with one.
| Model | One token per pass, MLX | Two tokens, MLX | Two tokens, llama.cpp Metal |
|---|---|---|---|
| Qwen3 0.6B | 5.4 ms | 1.11 | 1.50 |
| Qwen3 1.7B | 12.8 ms | 1.02 | 1.46 |
| Qwen3 4B | 29.5 ms | 1.04 | 1.38 |
On MLX the second token is nearly free, and from three tokens on the cost rises steadily, to 2.7 to 3.1 times one at eight. On llama.cpp the step from one token to two is the costly one, and from two to eight the cost stays nearly flat. The hardware half of the idea holds on MLX.
The guess is right 27 to 40% of the time
Measured, 14 November 2026. Each model wrote 256 tokens for each of 475 prompts (150 chat, 175 code, 150 prose openings from Wikipedia), about 118,000 positions per model. Each guess was scored against the model's own next token. Topics were split 80/20, so no topic appears in both training and test.
With no training, a guess read off the shallow state was right under 2.5% of the time: after 1 to 8 layers the state still mostly holds the current token. A trained head did better.
Qwen3 4B, trained head, held-out positions:
| Layers before the guess | Right | Punctuation and spaces | Function words | Content words | Predicted speed |
|---|---|---|---|---|---|
| 1 | 27.1% | 41% | 40% | 11% | 1.12x |
| 2 | 30.0% | 48% | 42% | 12% | 1.11x |
| 4 | 34.3% | 55% | 48% | 14% | 1.13x |
| 8 | 36.3% | 57% | 51% | 15% | 1.09x |
The predicted speed is not a timed run. It replays the loop over the held-out text and prices each cycle with the times measured above.
Across the three models the trained head was right 27 to 40% of the time. Deeper layers help a little but cost more than they gain. The best predictions were 0.97x (0.6B), 1.06x (1.7B) and 1.13x (4B), all under the 1.2x the plan required before building the loop. One guess per pass at about 30% caps the idea near 1.2 to 1.25 tokens per pass, even if the second token and the guess cost nothing.
The loop was built anyway, because the later steps run on it.
The loop, measured
The loop was checked against mlx-lm's plain greedy output on 24 held-out prompts of 128 tokens, on all three models. Where the two differ, the model's top two choices at that token were tied, or one or two steps apart in 16-bit rounding. Checking several tokens at once rounds slightly differently from checking one, and at a tie that flips the choice. dflash-mlx documents the same effect.
Measured, 15 November 2026, Qwen3 4B, guess after layer 1, 256 tokens per prompt, against mlx-lm:
| Version | Prompts | Code | Prose | All |
|---|---|---|---|---|
| Two CPU round trips per cycle | 6, once | 0.89x | 0.82x | 0.86x |
| Every decision on the GPU | 12, twice | 0.91x | 0.84x | 0.87x |
The loop produced 1.13 to 1.30 tokens per pass. In the second run every prompt was slower than plain decoding (0.81 to 0.98x).
Plain mlx-lm prepares its next step while the GPU runs the current one. The first version of the loop could not, because it needed the guess and the count of accepted tokens back on the CPU twice per cycle. The second version keeps every decision on the GPU and regains that overlap.
Timed alone, the GPU work of one cycle is 1.07 to 1.09 one-token steps, which at 1.21 tokens per cycle would be about 1.1x. Under sustained load a cycle took 1.34 to 1.37 steps, about 35 ms against 26 ms. The extra 7 ms is not GPU arithmetic. The remaining candidates are on the CPU side, building and sending each cycle's work. It was not traced, because the profiler that would show it needs administrator rights. Short runs on a cool GPU reached 1.05 to 1.2x and are not reported as results.
Existing tools on the same machine
DFlash and DFlash2 are small drafter models that guess a block of tokens for the main model to check. EAGLE-3 is a one-layer drafter that reads the main model's internal states.
Measured, Qwen3 4B, 6 prompts (3 code, 3 chat) of 256 tokens. Each tool ran against its own plain decoding, plain, tool, tool, plain: llama.cpp tools against llama.cpp, dflash-mlx and the loop against mlx-lm.
| Tool and setting | Date | Code | Prose | All |
|---|---|---|---|---|
| llama.cpp DFlash2, 8-bit drafter | 15 Nov 2026 | 1.31x | 1.13x | 1.22x |
| llama.cpp DFlash, 8-bit drafter, 7 guesses per check | 15 Nov 2026 | 1.52x | 0.87x | 1.19x |
| llama.cpp DFlash, 8-bit drafter, 15 guesses (default) | 15 Nov 2026 | 1.07x | 0.57x | 0.82x |
| dflash-mlx, 8-bit drafter | 15 Nov 2026 | 1.08x | 0.67x | 0.88x |
| llama.cpp EAGLE-3, 3 guesses | 16 Nov 2026 | 0.82x | 0.82x | 0.82x |
| llama.cpp EAGLE-3, 7 guesses | 16 Nov 2026 | 0.61x | 0.67x | 0.64x |
| Layer-hot loop (above, 12 prompts) | 15 Nov 2026 | 0.91x | 0.84x | 0.87x |
With default settings, no tool clearly beat plain decoding here (0.86 to 1.09x, 14 to 15 November 2026). Two changes made the difference. DFlash by default checks 16 tokens per pass, and on this machine 8 tokens already cost 1.77 times one. Checking 8 took it from 0.82x to 1.19x. DFlash2's drafter is 2.7 GB, larger than the 2.3 GB main model, and storing it in 8 bits took it from 1.11x to 1.22x. A rerun on 16 November gave 1.221x again. EAGLE-3 stopped near 2.1 tokens per check and lost.
The 2.0x and 3.4x published for DFlash2 were measured with a 27B model on an M3 Ultra, not a 4B model on a fanless laptop.
Trying to raise the guess rate
The guess rate is the limit, so four ways to raise it were tried. All kept the model's own weights unchanged.
| Attempt | Date, model | Result |
|---|---|---|
| One attention layer added to the guess head | 14 Nov 2026, 0.6B | 4 to 5.5 points more after 1 to 2 layers. It costs about one extra layer per guess, and predicted speed moved by 0.03 or less. |
| Second-best guess in a spare row | 14 Nov 2026, 0.6B and 1.7B | The right token was in the top two 37 to 40% of the time, against 28 to 31% for the top one. The best setting never used it: on MLX a third token costs 0.25 to 0.45 of a pass more than a second. |
| Guess head inside DFlash's check | 15 Nov 2026, 4B, replayed on 40 prompts | Right 9 to 24% of the time where DFlash failed, since DFlash already takes the easy tokens. 3 to 9% more tokens, for 1 to 10 extra rows. |
| Head that also reads the previous token's final state | 16 Nov 2026, 4B | 28.9% right with the layer-1 state, 29.4% with the plain embedding. |
The last row is the EAGLE-style input: the previous token's final state, which each pass already computes, plus the current token's embedding. The layer-hot version swaps the embedding for the token's state after one layer. The swap changed the result by -0.5 points.
That head was limited by training data. It gained about 6 points per doubling, from 16.8% on a quarter of the data to 28.9% on all of it (about 96,000 positions). Reaching 75% at that rate would need about 128 times the data, about 40 GPU-hours on this laptop. The public EAGLE-3 head, trained on far more, implies about 60% here, and even 60% predicts 1.18x under sustained load, below DFlash2's 1.22x. The plan required 1.3x predicted to go on, so the work stopped there.
Tuning the model's own early layers was not run. One version removes the reuse of shallow states the loop depends on. The other changes the model's output and needs training that does not fit in 16 GB.
Limits of this evidence
- One laptop and one model family, Qwen3 up to 4B. A larger model or another GPU may give different numbers.
- The GPU slowdown under load is not reported by anything readable without administrator rights. Interleaved runs balance it out but do not remove it.
- Speed runs used 6 or 12 prompts of 256 tokens.
- The loop's output differs from plain greedy output at near-ties. In the GPU-only version one prompt differed at 3 rounding steps, above the test's limit of 2. On inspection the two choices were exactly tied in the loop's own state.
- The only public DFlash2 drafter for Qwen3 4B needed its configuration flattened for llama.cpp. It reached 2.8 to 3.2 tokens per check, below the about 4.8 its own validation implies. The cause was not isolated.
- The llama.cpp tools matched their plain output on 5 of 6 prompts; the one difference was not inspected. dflash-mlx differed on more, for the same rounding reason as the loop.
Reproduce
RESULTS.md holds every table, gate decision and caveat. docs/PLAN.md is the plan as written before any measurement, and docs/PLAN_acceptance.md the follow-up that stopped at its first gate. docs/REPRODUCE.md gives the setup and the command for each step, and results/README.md maps each number to its result folder.
More Articles You Might Like
What Failed in My Own Controls: Seven Results From October 2026
Seven failures in my own legal AI controls, five measured against a rule set before the run and two found in review, each with its date, configuration and evidence: an auditor whose rejections were mostly wrong, a model-hiding scheme recovered 100%, routing that failed its pre-registered rule twice, two missed latency targets, a calculator fallback and a wrong statutory instrument on my own case study.
In-Flight Rollback on SGLang: A Sentence-Level Check Cut Wrong Legal Answers From Memory by 83 to 86%
legal-rag-verifier checks each sentence while the model writes it, cuts a rejected one and rewrites it with the statutory text added. 240 UK statute questions answered from memory, 14 October 2026: answers holding a wrong sentence fell from 132 to 23 for Qwen 27B and from 198 to 28 for Qwen 2.5 7B. After a real error, the default retry was wrong again 71 times in 95, and a retry with the provision added at the cut 16 times. With the source already in the prompt, Qwen 27B had 4 such answers with the loop and 4 without, against 3 for Gemini 3.8 Flash and 8 for Claude Opus 4.6.
Jev System One vs Specialized Sovereign RAG. An Empirical Benchmark
Across 20 measured trials on Apple Silicon MPS, a cloud-hosted decision primitive averaged 457.19ms P50 (381.0ms upstream cloud floor) and consumed 453 tokens before retrieval began. A co-hosted sovereign classifier completed the same routing in 0.23ms with zero tokens.
New entries are published to the feed.
RSS: /feed.xml