Every time this model predict a token, it moves across 480 small parts of its architecture (10 expert networks in each of the 48 blocks). On my laptop, most of those model pieces were sitting in the wrong hardware component when the token needed them (System RAM not on the GPU VRAM).
The model is Qwen3.8-Flash-Next one of the greatest local model runs on consumer hardware, its GGUF file size is 83.6 GB (unsloth quantized model UD-IQ3_XXS). My laptop’s GPU has 16 GB of memory and only about 15 GB of those are really usable. So the model doesn’t fit not even close. Most of its experts lives in RAM and travels to the GPU when they are needed. The decode ran slowly (about 30 tokens/second) at the 90K context window.
After a weekend of optimization with Fable 5.2 and few Opus and Sonnet 5.5 subagents its decoding speed reached 80 tok/sec and prompts processing about twice as fast. None of that came from faster math since the arithmetic at the end is the same arithmetic I started with, instead it was more of the art of studying how each byte move and where each expert's weights sit, what is already waiting when the GPU reaches for it and what still has to move from RAM through the slow PCIe that forces the GPU to wait, Now Each byte waits less, sits in a better place and moves sooner.
I should say up front that I didn’t write most of this code by hand (obviously) thanks to Claude-code, and when I say “we” below, that’s me and the AI agents that did the heavy lifting who I mean.
The numbers#
30 tok/sec is where I started using the flags that I used to run this model with using llama.cpp and unsloth desktop, but it is not a fair baseline to be honest. The same engine with flags that fable was able to tweak reached ~ 800 tok/sec of prefill (prompt processing) and 43.8 tok/sec of decode (think of it as read and writing). That is the number this project aimed beat. I ended up with ~ 1480 tok/sec of prefill and ~ 80 tok/sec decode so the engine code optimization are responsible for roughly 1.8x of prefill and decode speed.
Those figures come from one fixed test request. Near the end I replay real coding sessions instead, where a different drafter wins and the picture across a full 90K window is 75 tok/sec at the start and 57 when it is nearly full, against 49 and 45 without guessing ahead.
Disclaimer: This project was focused on 1 model runs in 1 file format on 1 laptop. It proof nothing about other setups, so although the techniques used here can apply to any MoE and hardware the timing and gains will significantly differ based on the model architecture, the hardware, the OS and the engine
A kitchen with a very small counter#
I’ll use a famous example for the rest of this blog, about a chef who is significantly fast but can only cook with ingredients that sits on the counter. The counter is the GPU VRAM ~ 15 GB actually usable and the chef can take anything on it almost instantly, down the hall is a huge pantry the 128 GB of RAM where everything else sits. between the pantry and the counter a single tight corridor (PCIe) with a bandwidth ~ 50 GB/second, That sounds like a lot until you know the chef reads from the counter about 17x faster ~ 858 GB/sec.
The model is a strange kind of recipe. Every token is a dish that passes through 48 stations in a row (each station is the model layer). At each station there’s a shelf of 512 spice jars (experts per layer) and a little card, the router that says which 10 spices (10 active experts) this dish needs. The next dish wants a different 10 spices. The jars are the model’s experts small specialised networks and the design is called MoE (Mixture of Experts) there are 24,576 jars (512 experts * 48 layer) about 2 MB each so all of them about 50 GB they can not all be on the counter 15 GB.
So the chef keeps a shelf of jars on the counter (expert cache) if a dish require a spice jar that is already there that is a hit and the chef does not have to look up, if not it is a miss the runner goes down the hall to pick up the spice jar and the chef waits (remember the chef speed is ~ 858 GB/sec while the runner 50 GB/sec)
One token on an early build: about 141 misses, and 7.7 of its 22 ms spent waiting for copies, at a 70.7% hit rate. The arithmetic is not what decides the speed; the waiting is.
The system speed now does not depend on how fast the chef cooks but on how often the chef waits for the runner and how often the runner stay idle when the chef cooks waiting for the next dish spice jar misses to go and grab them from the pantry
Two more words. Reading a prompt (prefill) is a feast: hundreds of dishes pass each station together, nearly every jar is needed, and the runner hauls them in bulk. Writing the answer (decode) is made to order, one dish at a time, 10 spice jars per station each, decode is what I sit and watch so it came first.
There is one more thing fighting for counter space which is the order book. The model writes down notes on everything it produced so far (the KV cache) so a 90K context needs ~ 2.6 GB of the counter area free and reserved for itself before anything starts which make the counter area available for other ingredients smaller, notice that not every session would need the full 2.6 GB and the context fills gradually so at the beginning of each session that part of the VRAM will be blocked and nothing occupies it at all which waste valuable GPU resources.
Under the hood The model and the machine, precisely
Qwen3.8-Flash-Next in the UD-IQ3_XXS GGUF (about 3 bits per weight), 83.6 GB. 48 blocks: 36 Gated DeltaNet recurrent blocks and 12 sparse-attention blocks; each has a 512-way router choosing 10 routed experts plus one shared expert. One routed expert (gate, up, down) is 1.94 MiB. A separate Q8_0 file holds a multi-token-prediction (MTP) draft block. The rig: RTX 5080 Laptop GPU, Core Ultra 9 275HX (24 threads), 128 GB RAM, Windows 11. CUDA reports 16,275 MiB and offers 15,067, and that is a hard wall: past it, Windows silently demotes memory to system RAM and reads of the oldest data fall from 808 to 46 GB/s, with no error. Measured rates: GPU read about 858 GB/s; pinned host-to-device about 51 GB/s for one large copy, 42–46 GB/s for many 2 MiB copies. Every speed number, unless stated otherwise, is for one fixed request: a 1,808-token prompt, 602 greedily decoded tokens, 90k context window.
The engine I threw away#
The first thing I built was a faliure a useful one: started from scratch a new engine designed specifically for this model in Rust and CUDA. the decode speed was a surprise at 3.3 tok/second 😂 so I asked myself a reasonable question, does this even make sanse! that is going to be huge waste of time and resources to start from scratch! why don't we take a differnet approach?
So I thought to start again but this time from where the best thing that I already had as my starting point and build a continuous improvement cycle that measures each bottleneck at the process, identify the root-cause and works towards eliminating the waste at this stage and then move to the next bottleneck, etc., in my hands I had Unsloth build of llama.cpp it already ran this model that quantized by Unsloth themselves, already had an expert cache and already supported speculative decoding with the model’s own small draft head my engine is a working copy of it but laser focused ONLY on running this specific model as efficient as possible on my hardware and the starting point engine's speed became the floor that every improvement cycle benched marked against it
With my original settings it prefills ~ 800 tok/sec and decode ~ 30 tok/sec. Then came the free win hiding in llama.cpp flags; a larger batch size let the whole prompt go through at once so each spice jar is carried once instead of twice, On its own that made reading ~ 43% faster. And the expert cache was switched off, turning it on took writing from 30 to 43.8 though it handed back most of the reading gain with both on prefill dropped back to ~ 845 tok/sec (No code changed yet).
Each row was measured in its own test session, so neighbouring rows also differ by a few percent of session drift; the single-session comparison is the next big chart.
The numbers behind this figure
The fastest number I ever measured#
Early on, one run pushed prompt reading to about 1,850 tok/sec more than double the floor and I was about to celebrate 🥳 BUT!!
Then I looked at the output the first request wrote 27 correct tokens and then nothing but token number 0; the requests after it were all 0 from start to finish with the routing broken the stations asked for almost no jars so of course the chef was fast but coocking with no spice or ingredients! Actually it was not cooking and nothing reported an error.
From then forward output was checked before any speed benchmarking so here is what “lossless” means in this blog, Every change sat behind a switch off by default and I kept it only if with greedy decoding (always take the most likely token) the model wrote exactly the same tokens with the switch on as off across a fixed set of short, long and nearly-full-context requests repeated. One exception is on record a change to the draft’s buffers altered one 20-token test request we never found out why and I accepted it with that recorded. and “the same” means the same as that setup without the change not the same as stock llama.cpp doing a jar’s math on the GPU instead of the CPU rounds a little differently so text can drift from the stock setup after a few dozen tokens nothing here approximates the model.
Counting before cooking#
Before building anything I had the agents do the clock-watching, an early decode step took 22 ms, about 141 jars were missed per token 273 MB of them and copying them plus organising the copies took 7.7 ms while the chef waited, when the runner was busy only about 23% of the step. scheduling was the bottleneck the corridor had capacity but while the chef was cooking a dish, the runner stood idle, and whel the runner was bringing the spice jars, the chef was waiting!.
Would a cleverer shelf help?! we recorded which spice jars every token (dish) asked for and replayed the recording through simulated shelves including the best possible eviction order, one that always throws out the jars needed furthest in the future you can’t build it because it needs to know the future but it shows the best any policy could ever do (It’s Belady’s algorithm, from 1966.)
At the real shelf size plain least-recently-used eviction got 68.1% hits the engine’s own cache 70.7% and the best possible order 84.0% The gap is real but only clairvoyance closes it. meanwhile growing the shelf took even plain LRU from 53% to 90% and hits drove speed directly on the real cache 60.8% gave 40.2 tok/sec and 78.5% gave 48.5.
So I stopped thinking about policy and went looking for the counter space where the ingredients and jars sits
No replacement policy can beat the best possible order, and that order needs to know the future; growing the cache takes even plain LRU past it. Labels on the measured points give the decode speed at that hit rate.
The numbers behind this figure
Expensive VRAM Memory reserved just in case#
Every megabyte on the counter (VRAM) has an owner the model’s fixed parts that every token uses (always-on weights for shared experts and attention layers ~ 3.8 GB) the jar shelf, the order book, scratch space for computing, the draft model’s weights, and a safety margin. Most owners need everything they have. Two were holding space for a worst case that wasn’t happening "yet!".
The first was the order book. A 90K tokens of context reserved its 2.6 GB upfront and most of the time most pages are blank so I let the blank area used as a temporary jar shelf until the KV cache grow and needed that area. The GPU VRAM makes that possible the engine keeps fixed addresses and underneath them you choose which physical 2 MB pieces sit where so when the conversation grows jars move off that temporary allocated area and give it back to its owner (KV cache) with no address changes.
The first full test passed every check perfectly because the feature never switched on 1 jar tensor had a few bytes of padding at its end the code refused to lend around it and the log said so politely every time: lent 0 MB, after the fix 2,516 of 2,520 blank megabytes went to the shelf 38% more jars sit infront of the chef to pick them without having to wait the runner to go and grab them, the hits rose from 70.7% to 78.5% and decode got 4–7% faster.
The second was the feast prep table, the main scratch buffer 1.3 GB is sized for 2,048-token prompt batches a decode step needs 16–34 MB of it so during made to order service, about 1.26 GB is lent to the shelf and taken back before a feast, the first working build took 62 to 170 ms per handover and the cost turned out to be per driver call not per byte moving the same memory in 16 MB pieces instead of 2 MB brought it to about 10–12 ms so the decode went from 59.6 to 62.0 at a 1.9% cost to perfill.
The draft model had the same habit, most of its 978 MB scratch buffer was room for a copy of one jar tensor this setup never needed, so trimming the draft’s work so that copy can not happen cut the buffer to 248 MB and gave the shelf the other 730 MB.
Before lending, the expert cache has 5,259 MiB. During decode early in a conversation it also gets the order book's blank pages (2,516 MiB) and most of the prep table (about 1,262 MiB): about 9,037 MiB, with nothing new bought.
Nothing new was bought: memory reserved for a long conversation and for big prompt batches is lent to the expert cache while it would sit empty.
The numbers behind this figure
Lending is most generous when the conversation is small and reduced as the context window fills, at full context there is nothing left to lend by design.
An early build without the draft: single samples, so the wobble is noise. Lending gives back memory as the order book fills.
The numbers behind this figure
Under the hood How the lending works
The KV cache and attention indexer live in a CUDA virtual-memory range backed by one physical 2 MiB handle per chunk, the mechanism vAttention uses. Handles not yet needed are mapped into the tails of the expert-cache banks. When the context grows, the engine synchronises, parks the borrowed slots, unmaps those handles from the banks and maps them back into the KV range, zero-filled. Addresses never change, so captured CUDA graphs and slot maps stay valid; a probe confirmed that a graph replayed after a remap reads the new memory. Per handle, map costs under a microsecond, set-access about 15 µs and unmap about 76 µs, which is why handle size mattered more than bytes moved. The compute buffer lends everything above the measured high-water mark of small graphs on entry to a batch of at most 32 tokens, and a check after every scheduler allocation takes it back if a bigger plan needs it. Prefill has its own borrower: a ring of three upload slots, taken from the cache only while a large batch runs, lets the next layer’s experts stream in while the current one computes. Prefill went from 1,058 to 1,484 tok/sec, decode unchanged.
An apprentice who guesses#
decode is slow partly because each token depends on the one before it, speculative decoding cheats safely, a quick apprentice (or prep coock) guesses the next couple of tokens and the chef checks the last real token and both guesses in a single pass matching guesses are kept at the first wrong one the chef’s own choice is used instead so the result is exactly what the chef would have written alone, this model ships with its own apprentice "MTP head" and llama.cpp already supported it.
On my laptop initially it made decode worst and I used to turn it off, 43.6 tok/sec without it and 34.2 tok/sec with it 😮. The apprentice and its gear took about 4.5 GB of counter the shelf fell below its minimum size and the engine silently dropped the shelf altogether! Only when lending given the space it started paying back, 52.2 tok/sec with the MTP against 47.0 tok/sec without it in the same test.
If both guesses are right, one pass yields three tokens; if the first is wrong, it yields one, and that one is the chef's own choice, so the output never changes. About 80% of guesses are accepted: 2.61 tokens per round on average.
The apprentice is good: about 80% of its guesses are accepted and a round average ~ 2.61 tokens out of possible 3, so why not guess further ahead? I tried and it lost 1, 2 and 3 guesses gave 43.2, 47.8 and 45.2 tok/sec, against 45.2 with no apprentice. It’s the kitchen again, 1 dish needs 10 spice jars per station 3 dishes checked together need about 17 different ones and every extra guess drags more misses, here the cost of checking limits speculation regard;ess how good the guesses are!
The last step on the ladder was free the apprentice’s processor work used all 24 threads of a CPU that mixes fast and efficient cores with 8 decoding went from 73.4 to 76.2 tok/sec in the same run yet the apprentice itself got only about 0.2 ms per round faster.
The y axis starts at 72.5 to show a 3 tok/s effect; say so with a broken-axis mark. The draft itself got only ~0.2 ms faster per round; most of the gain was elsewhere.
The numbers behind this figure
Reading over the chef’s shoulder#
By now the accounting looked different in 1 checking round of 35.0 ms the chef cooked for 18.4 ms and waited for missed jars for 14.6ms that is ~ 42% of the round just waiting. While the chef was cooking the runner stood in the corridor doing nothing! the obvious move was to guess the next station’s jars and send the runner ahead.
I had tried that early on and it lost, it cut blocking misses by 63% and still made writing 2–4% slower, every copy was issued one at a time on the chef’s clock and the guessing itself cost time. Waiting for jars was then only 22% of a step I wrote down why and moved on.
about ten rounds later those reasons were gone! copies now went out in one batched call per layer and router results came back without the chef waiting, the waiting share had nearly doubled so I had the agents rebuild it with a second lane that carries guessed jars for the next dish while the chef cooking the guess is cheap, the next station’s own selection step applied one step early to slightly old information. Offline it named about 65% of the next station’s misses with 10 guesses. if a guessed jar is still in the corridor when the chef reaches for it the chef waits for that one jar only instead of waiting the whole jars.
Old and new timelines side by side: with the lookahead, guessed experts travel while the GPU computes, the GPU waits only for one late upload and one unguessed expert, and the same work ends sooner.
In one test session on the final build, writing was 65.6 tok/sec without lookahead and 73.3 with it and hits went from 74.6% to 88.8% (correct jars guessed in advance) with identical tokens and accepted guesses on every request(so basically lossless quality).
More guesses I assumed would mean more speed!. But I was wrong they caught more misses and made the whole cooking process slower, at 20 guesses and 48 MB per station hits reached 93.7% which is great but decode speed fell to 57.2 tok/sec the best was 10 guesses and 24 MB about what the corridor carries while one dish is cooked (half a millisecond at about 47 GB a second) beyond that the chef waits behind the runner own deliveries, the next gains must come from better guesses per megabyte today 63% of guessed jars get used.
Each dot is one lookahead setting on the final-but-one build with the draft on. The winner is not the highest hit rate.
The numbers behind this figure
Without the apprentice there are too few misses per step for the guessing to pay (~2% slower) so it runs only when there is something to check.
Under the hood The lookahead in engine terms
It runs only on multi-token verification batches. Once layer l’s blocking miss copies are queued, one batched upload of the predicted experts for layer l+1 goes out on a second CUDA stream, ranked by router score and capped at the per-layer byte budget. The predictor (“one-mixer-ahead”) applies layer l’s own residual mixer and router to the residual stream one sub-layer early; a router-only probe named 52% of misses against its 65%. Prefetched experts enter normal cache slots marked unused, so they are evicted first. No plan may evict a slot whose upload is in flight, and everything drains before large batches, ring borrows and elastic moves. If layer l+1 selects a slot still in flight, the compute stream waits on that upload’s event on the GPU; the host never blocks.
The safety check that wouldn’t break#
That wait is what stands between a fast lookahead and garbage so I wanted to see the garbage. We built a switch that skips the wait added a 10 ms delay so the chef would surely reach too early and ran it, the output was perfect. the counter said 25,697 waits had been skipped and every token was identical.
some ordering between the two lanes that nobody had designed was standing in for the wait. a safety mechanism you can’t break isn’t proven so we changed the test: the processor itself now held the uploads back, skipping the wait then produced garbage on the very first request; with the wait in place everything matched! only then I accepted the feature. What the accidental ordering was is still open question.
The block that passed every test#
A follow-up build added three optimizations to the guesser passed every identity test and even seemed to help a bit but the old guesser was still in the graph next to the new one, both ran at every station the old one wrote its answer last and the new options steered work nobody read the tests passed because the old path was correct.
A read-only analyst agent, reading the source for another reason spotted the second block and a count in the logs confirmed it 9,085 operations in a three-token step where about 8,000 were expected! Deleting it took decoding from 70.0 to 73.3 tok/sec about 5% faster Check that a new option changes what it claims to with a counter you can compare against it the number you expect.
A perfect fusion worth nothing#
Per-operation timing made decode look like death by a thousand small tasks: 2,550 to 3,231 GPU operations per step many costing 10–45 µs per operation! merging them (“fusion”) looked like the next big thing, a hardware probe disagreed: inside a recorded CUDA graph which is how the engine replays its work, launching an operation costs well under a microsecond the timing mode was charging every small task for its own measurement.
I had the cheapest fusion built anyway as a test about 240 fewer operations per round checked bit for bit, 386,300,160 numbers and zero differences, decode went from 76.27 to 75.97 tok/sec which is noise near-perfectly exact worth nothing.
Taking it all apart, in one sitting#
Nearly every number so far comes from the test session of the change it describes and sessions drift by several percents so the ladder’s steps don’t compare cleanly with eachothers, to fix that I ran one controlled experiment on the final build by starting from the full setup switch off one thing at a time alternating all setups over three rounds and compare every output with the full setup both unmodified baselines ran in the same session.
One session, all setups interleaved over three rounds; each row turns off exactly one thing from the full setup.
The numbers behind this figure
In that session the full setup wrote 75.0 tok/sec and the tuned, unmodified seed 44.2: 1.7 times faster, measured side by side. Switching off the lookahead cost about 7.4 tok/sec, and hits fell from 88.8 to 74.6 percent. Switching off the asynchronous router results cost about as much, because the lookahead relies on them and stops too: the hit rate drops to the no-lookahead level. The borrowed upload ring matters only for reading: without it, prompts were read at 1,046 instead of 1,446 tok/sec, while writing didn’t move. Without the order-book lending, writing fell to 34.2 tok/sec: the shelf no longer reached its minimum size and the engine dropped it, the same silent collapse the apprentice caused at the start. Some switches that mattered when they were added barely register in the finished setup: draft crop. With the apprentice switched off entirely, writing was 52.7 tok/sec with 81.4% hits. Every configuration with a single switch off wrote identical tokens to the full setup, except the one without order-book lending.
Where the time goes now#
On the build I timed in detail, one writing round yields 2.61 tokens and takes about 35 ms (a little less after the thread fix). The apprentice’s two guesses take 5.3 ms. The chef cooks for about 21. Waiting for missed jars, once 14.6 ms of a round, is down to about 7.7.
The top bar covers only the verification span, the bottom bar the whole round, so totals are close by coincidence. Instrumented timings run slower than real ones; treat parts as approximate.
The numbers behind this figure
Computing is now the largest block, about 60% of the round. Its true floor, just reading the needed bytes at full speed, is about 8 of those 21 ms, and the fusion experiment says the gap comes from how efficiently the kernels handle these compressed 3-bit formats. The operation count barely matters.
Speed also depends on how full the conversation is. With 88,000 tokens in it, almost the whole window, writing runs at about 45 tok/sec: the order book has taken its pages back.
Lending is largest when the conversation is short and gives memory back as it fills; the right panel shows what is left when it is nearly full.
The numbers behind this figure
At a 16,000-token context window the full setup wrote 77.5 tok/sec, against 48.1 for the tuned seed; at 90,000 it was 74.7 against 42.0. Filled to nearly the whole 90,000-token window, the full setup still wrote 45.0 tok/sec.
Five short prompts of different styles, 400 tokens each; the standard request elsewhere is a single prompt, so this shows how much the text itself matters.
The numbers behind this figure
Across five short prompts of different kinds (code, a story, a list, an interview and JSON), the full setup wrote between 67.9 and 88.9 tok/sec, and the tuned seed between 39.8 and 46.5. The apprentice did best on JSON, where 96% of its guesses were kept.
Chasing the 8 ms floor#
That gap, 21 ms of cooking against a floor near 8, was too big to leave as a footnote, so I gave it its own round. The first step was to stop trusting the per-operation timing and look at a real round from the inside. A profiler traced every one of the 4,096 kernels the chef runs in one checking round, inside the recorded graphs, without changing them.
The picture was not the one I expected. Of a 37 ms traced round the chef cooked for 20.4 ms, and for 17 ms the GPU ran nothing at all. Almost none of that idle time sat inside a station: 0.24 ms. It sat between stations, in the moment after one dish is plated and before the next one starts. The heavy kernels cost what I thought they cost. The small ones cost a fifth of what the old timing claimed, which is the fusion lesson again.
Then the kernels themselves. I had the agents build a small test bench outside the engine: it lifts the engine’s own kernel out of the source, runs it at the exact shapes a writing round uses, and tries every rearrangement the study had proposed. Each one had to produce the same bits as the original before its time was even printed. For the expert kernel there were 99 variants: more rows per group of threads, decoding a jar once when several tokens share it, the lookup tables moved to faster memory, wider reads. All 99 matched bit for bit. None was faster. Most were slower.
A second round on the other kernels found small wins: 30% on one of the mixer kernels, 10 to 20% on a few projections. Added up along the path that decides the round, they are worth about 0.3 ms out of 34. The chef is not slow because the knives are laid out badly. The chef is slow because every jar arrives compressed to about 3 bits per weight, and unpacking costs roughly 25 instructions for every four weights. The 8 ms floor assumes the bytes only need to be read. To get near it the weights would have to arrive in a different format, and that changes the output. So the floor is real, and I can’t reach it without leaving the lossless tier.
Four fixes worth nothing#
The 17 ms between stations looked like the easier prize. An analyst agent went through the trace and split it by cause, and a list of small host-side fixes fell out: stop blocking on the little input copies, send the runner to the six stations it was skipping, read the router’s answer back in one call instead of two, stop rebuilding the apprentice’s graph twice a round. Each was built behind a switch, each produced identical tokens, and each was estimated at a few tenths of a millisecond.
Together they were worth nothing. One made writing 2.8 tok/sec slower. The one that sent the runner to more stations raised the hit rate from 88.9 to 90.3% and the speed did not move at all.
A clean measurement without the profiler explained it. Inside the checking pass the chef is idle for host reasons for only about 2 ms a round. The rest of the “nothing running” time was the chef standing at a station waiting for missed jars to come down the corridor, 7 to 8 ms a round, and the host was waiting right there with it. Shaving the host’s own work only made it arrive earlier at the same wait.
The night the GPU ran at half speed#
In the middle of this every number halved. The accepted build, untouched, wrote 38 tok/sec instead of 75. I blamed the charger, then the laptop’s performance mode. Both were wrong. The GPU’s clock was stuck at 960 MHz instead of about 2,550, idle or busy, and the moment it got stuck was in my own logs: a second profiler, one that takes control of the GPU clock while it measures, had hung and been killed an hour earlier, and it never gave the clock back. A restart fixed it. Every measurement from that hour went in the bin.
If a run is ever at half speed, read the GPU clock under load before you read anything else.
Sending the order before the dish is done#
So the wait for missed jars was the thing to attack, and the trace showed where it started. A station’s router decides which jars the next dish needs, but that decision reached the host only after the whole station had finished: the router, then the runner’s guess for the station after, then the shared expert that every token uses. Only then did the host read the list, find the missing jars and send for them. The last two steps have nothing to do with the list. They were simply ahead of it in the queue.
The change is an ordering change. The router now posts its list the moment it is done, into a small piece of memory the host can read while the GPU keeps working. The guess and the shared expert run after that. The host reads the list, picks the jars and starts them down the corridor while the station is still finishing, and the chef waits only if a jar is still on its way when the next dish actually needs it. No arithmetic changed, and all 12 test requests came out identical to the previous build. So did a fill of the whole 88,000-token window.
Writing went from 74.4 to 79.8 tok/sec in one sitting, with every sample of the new build above every sample of the old one. At a nearly full window it went from 43.4 to 46.4.
The safety check got the same treatment as before. We delayed every delivery by 10 ms and filled its place on the shelf with garbage first: output identical. Then we removed the chef’s wait: every request failed. My first attempt at that test passed when it should have failed, because I had left a comparison mode on that quietly did the waiting itself. Same lesson as last time, a different way to learn it.
The half that didn’t pay#
About 7 ms of waiting was still there, so we tried the obvious second half: let the chef start on the jars already on the shelf while the missing ones are in the corridor, and add those in when they land. It took a new gate inside the recorded graph and a version of the expert kernel that skips absent jars. It crashed on its first load, on a flag that is only legal while a graph is being recorded. Once fixed, it was correct: identical tokens on every request.
It was also worth 0.3%, which is noise. The split did what it was built to do, and the idle time between stations fell from 7.3 to 3.1 ms. But 2 to 3 ms came straight back as waiting at the new gate, and the rest went on running every station’s expert step twice. About a quarter of the jars a station needs are still in the corridor when it starts. What is left is 5 to 7 ms a round that no reordering removes, because it is the corridor itself: so many bytes, at the speed the link carries them.
A second apprentice, and a real shift#
Everything above was timed on one fixed order: the same 1,808-token prompt, the same 602 tokens written back. That is fine for telling whether a change helped. It is a poor picture of a working day. So for the last test I replayed five of my own recorded coding-agent sessions, tool calls and long tool outputs included, stopped each one at about 2,000, 42,000 and 84,000 tokens of conversation, and let the model write the next turn. Before every timed turn the GPU had to cool back to within 4 °C of idle, because a warm laptop is a slower laptop.
I also brought in a second apprentice. DFlash 2 is a small separate drafter that someone else trained for this exact model, and llama.cpp already supports it. Where the model’s own MTP block guesses one token after another, this one writes a whole block of guesses in a single pass. It can guess up to 7 tokens ahead, and I expected the long guesses to be the prize.
Total tokens over total writing time across five replayed sessions per point. One run per setup, so read differences of a few percent as noise.
The numbers behind this figure
| Setup | about 2k | about 42k | about 84k |
|---|---|---|---|
| DFlash 2, 2 guesses | 75.0 | 66.5 | 57.0 |
| MTP block, 2 guesses | 73.2 | 58.3 | 43.7 |
| No guessing | 48.8 | 46.2 | 45.3 |
| DFlash 2, 7 guesses | 57.0 | 52.3 | 35.9 |
They were the opposite. With 7 guesses the chef checks 8 tokens in one go, and each extra token asks for jars the shelf doesn’t hold. The share of jars found on the shelf fell from 88% to 71%, the share of guesses kept fell to between a quarter and a half, and a round took twice as long. An earlier run had shown me 97 tok/sec with 7 guesses, and I nearly believed it. The text it wrote was the model repeating itself in a loop, on a filler prompt, and a loop is the easiest thing in the world to guess. Real work doesn’t repeat like that.
Two guesses from DFlash 2 won at every length: 75 tok/sec in a short conversation, 66.5 in the middle and 57 with the window nearly full. The MTP block is level with it at the start and then falls away, and near a full window it is slower than not guessing at all. Part of that is plain to see: its guessing step gets slower as the conversation grows, from 5.5 to 9 ms, while DFlash 2 stays at about 2.5. Another 10 ms or so per round I could not explain before I stopped, and I’d rather say so than invent a reason.
The fixed order flattered the engine a little, too. It says 80 tok/sec; my own sessions say 73 to 75 at the start of a conversation. Both are true, and the second one is the number I’d plan a day around.
One note on what “same output” means here. With either apprentice, every token that comes out is still the big model’s own first choice. But checking three tokens at once rounds the arithmetic a little differently from checking one, so where two candidate tokens are nearly tied the text can take a different turn from the no-guessing run. The two apprentices agreed with each other on 13 of 15 prompts.
I had planned a switchboard that changes apprentice as the conversation fills. One setup won everywhere, so there is nothing to switch. DFlash 2 with two guesses is the default now.
Standing on shoulders#
Almost every idea here was had before, often by several people. The engine is llama.cpp, with its expert cache, MTP draft support and backend sampling; the weights are Unsloth’s GGUF of Qwen3.8-Flash-Next. An LRU expert cache plus loading experts early by guessing from the current state appear in Eliseev and Mazur’s offloading of Mixtral; MoE-Infinity builds an activation-aware expert cache for personal machines; Pre-gated MoE lets one block choose the next block’s experts so the copy overlaps the compute. Backing the KV cache with GPU virtual memory is vAttention’s mechanism. This year’s FreeToken already moves VRAM between the expert cache and the KV cache at run time. Speculative decoding comes from Leviathan and colleagues and Chen and colleagues, draft heads from multi-token prediction and DeepSeek-V3, and SpecFit and AcceptMoE make the point that checking cost limits speculation in offloaded MoE models. The best possible eviction order is Belady’s.
One report I read only after the measurements here were done, on 17 November: Exstill’s technical report on a single-chip processor for the next token. It had no part in this work, but it argues the same point from the silicon side, that most of a token’s cost is generality and moving data, and it is worth reading next to this.
What’s mine is the fitting: choosing which of these to combine on this machine, lending the scratch buffer’s worst-case reserve as well as the order book’s, remapping without rebuilding so recorded graphs stay valid, and sizing the lookahead to what the corridor carries while one station cooks. I didn’t compare against other engines, and a stronger outside baseline could shrink the factor.
What’s left, and what you can take home#
The last round settled most of what this list used to say. Faster kernels for these compressed formats were worth about 0.3 ms, checked bit for bit. The host-side fixes were worth nothing. Sending for missed jars earlier was worth 7%, and it is in the numbers now: 79.8 tok/sec against 44 for the tuned seed in its own session, about 1.8 times. What remains of a 31 ms round is roughly 20 ms of cooking that the format fixes in place and 5 to 7 ms of corridor. Still untried: warming the shelf with what the prompt just used, and letting misses jump ahead of the runner’s guesses on the link, each worth a millisecond at best by my estimates. The lossless tier is at diminishing returns.
The bigger levers are lossy, and I haven’t touched them. Compressing the order book to 8 bits gave 10% faster writing in one early data point, by handing its memory to the shelf, but it changes the output. So would routing that prefers jars already on the counter, or skipping a low-weight jar on a miss. Each needs a proper quality study first, and none is in any number above.
If you want to try this on your own machine, start from the best engine that already runs your model and sweep its flags before you write any code. For me that alone took writing from 30 to 43.8. Measure the hardware once: memory read rate, link rate, and where the real memory wall sits. List every owner of your GPU memory and ask which ones are holding space for a worst case. Simulate the best possible eviction order before you tune a cache, and build the cheapest version of a big idea before the big version. Ask whether a cost is per call or per byte. Sweep thread counts. When you add a safety check, make sure you can break it.
The gains came from knowing the kitchen: how big the counter is, how long the corridor is, and when to send the runner.
Sources and credits
- llama.cpp · GitHub ggml-org/llama.cpp
- expert cache · GitHub ggml-org/llama.cpp #29887
- MTP draft support · GitHub ggml-org/llama.cpp #22673
- backend sampling · GitHub ggml-org/llama.cpp #17004
- Unsloth’s GGUF · Hugging Face unsloth/Qwen3.8-Flash-Next-GGUF
- Qwen3.8-Flash-Next · Hugging Face Qwen/Qwen3.8-Flash-Next
- offloading of Mixtral · arXiv 2312.17238
- MoE-Infinity · arXiv 2401.14361
- Pre-gated MoE · arXiv 2308.12066
- vAttention · arXiv 2405.04437
- FreeToken · arXiv 2608.16157
- Leviathan and colleagues · arXiv 2211.17192
- Chen and colleagues · arXiv 2302.01318
- multi-token prediction · arXiv 2404.19737
- DeepSeek-V3 · arXiv 2412.19437
- SpecFit · arXiv 2610.15417
- AcceptMoE · arXiv 2608.02989
- Belady’s · doi:10.1147/sj.52.0078
- DFlash 2 drafter · Hugging Face incoai/Qwen3.8-Flash-Next-DFlash2
- DFlash 2 support · GitHub ggml-org/llama.cpp #27342
- Exstill technical report · arXiv 2611.18859 (read after this work)
Every speed figure is from one fixed request on my laptop unless its caption says otherwise: a 1,808-token prompt, 602 greedily decoded tokens, a 90,000-token context window. Figures are drawn in the page from the data embedded in it.