A nine-billion-parameter language model decoding on a single FPGA board, built from an empty directory. Every token it produces needs 4.09 GB of four-bit weights read out of DDR4 and multiplied. This page walks through what the machine has to do to make that happen, and what it took to trust the answer.
Fly through the placed design in 3D · RTL, reference models, evidence and docs on GitHub
Decoding one token at batch size one uses every weight in the model exactly once. The 9B pack is 249 matrices totalling 3,902 MiB at 4.125 bits per weight, which is about 7.9 billion multiply-accumulates per token derived.
None of that fits on the chip. All the block RAM and UltraRAM in the xcvu9p adds up to about 44 MB derived, roughly one percent of the weights. So the weights live in four 4 GiB DDR4 DIMMs and are streamed past the multipliers again for every token.
The four channels deliver 17.875 GB/s each, 70.70 GB/s together silicon. That sets a floor of about 58 ms per token and a ceiling near 17.3 tokens per second derived, before any other work is counted.
The matvec engines already run at that floor: 1.003 clock cycles per 64-byte beat in the chip testbench sim. The remaining complexity in this design is about everything that happens between matvecs.
The host does almost nothing per token. A sequencer on the chip reads a program out of DDR and drives two kinds of engine with it: one layer engine that holds the working vectors and does all the non-matrix math, and four matvec channels, one bolted to each DIMM. Select a step to see which parts it touches.
The first working version drove the engines from Python, register write by register write: about 100,000 MMIO accesses and 9.3 seconds per token, 98.8% of it host overhead silicon. The fix was to compile that register sequence into a binary stream and let the chip execute it.
The layers are unrolled. A reference-model run emits every register write, command and data move for a whole forward pass, with the weight addresses baked in. The host uploads it once.
The program is fixed but the numbers are not. Each vector picks its own exponent at run time, and later shift amounts depend on it. Eight 18-bit index registers carry those values, and a record can add or subtract one from its operand. A decode step has on the order of 1,656 such indirected records at the 0.8B size, which is why the registers live inside the sequencer and are read combinationally at decode.
Flags hold an indirection code (none, add, subtract) and either an index-register number or a channel number.
What the stream is made of. Register writes, data moves, matvec launches, waits.
Started by a CMD record. Norms, rotary embedding, convolution, gates, the DeltaNet step, attention, state load and store.
Selected inside an ALU command. Elementwise glue over the scratchpad, one element per clock.
; one projection y = W·x, four channels, chunk 0 MOVX ch0 scratch[x8] → XWIN, len K MOVX ch1 … ; ×4, the same x each time MVGO ch0 shape, weight base, beats, no-wait MVGO ch1 … ; ×4, one per DIMM FENCE ; wait for the engines MOVY ch0 RES → scratch, shift = imm − XRF[0] MOVY ch1 … ; ×4, rows land side by side
A stream is validated as it runs. Twenty error codes cover unknown opcodes, reserved bits, out-of-range jumps, bus errors and watchdogs, and any of them halts the sequencer with the code in a status register. Newer record forms are designed to fault on an older bitstream before a wrong result is consumed. One of them could not be made to, and that exception is listed under silent failures.
Qwen3.5 is a hybrid. Three layers in four are DeltaNet linear attention and every fourth is ordinary attention. They share the matvec engines and the scratchpad and nothing else, so the layer engine carries two separate state machines with separate state memories.
Keeps a 128 × 128 matrix per value head as its memory of the sequence. Each token decays the matrix, reads it with the key, writes back a rank-one correction scaled by a gate, then reads it with the query. It never looks at earlier tokens, so the work per token is constant.
Around it: a four-tap depthwise convolution over 8,192 channels with its own history, and per-head gates computed through softplus, exp and sigmoid ROM tables.
Appends this token's key and value to a cache as int8 with an exponent, then every query head scores itself against every cached key, takes a softmax through an exp ROM and a serial reciprocal, and sums the values. The work grows with the context length.
Around it: partial rotary position encoding on 64 of 256 dimensions, RMSNorm on queries and keys, and a sigmoid output gate.
The context cost is visible on the board: a decode step takes 137.7 ms near position 30 and 147.9 ms near position 520, 7.4% more silicon. The DeltaNet layers account for 71.7% of a token's time in the testbench census, because there are three times as many of them and each is slower.
There is no floating point on the chip. Every operation is an exact integer algorithm defined in one Python file, ref/layer_fixed.py, and the RTL has to reproduce it bit for bit. The project rule is that when hardware and reference disagree, the bug is real.
Fixed formats alone were not enough. An early fixed shift crushed the DeltaNet output to 0.17 of a least-significant bit and the 0.8B model produced nonsense. The fix was block floating point: DYNQ8 and DYNQ16 scan a vector and choose its exponent on the chip, per vector, per token.
Exactness shapes the hardware. The vector ALU is a single lane, because argmax ties must resolve to the first index and the exponent searches depend on arrival order. Parallel lanes would be faster and would give different answers.
| Quantity | Format |
|---|---|
| Weights | INT4, one uint16 scale per 128 |
| Matvec input | int8 + per-vector exponent |
| Residual stream | int16 Q8.7 |
| Normalized q, k | int16 Q1.14 |
| DeltaNet state | int16 Q2.13 |
| Gates, RoPE tables | Q15 |
| KV cache | int8 + exponent per token, head |
| Rounding | half away from zero, everywhere |
On the board, the 9B gate matched 24 of 24 tokens over four prompts, 36,886 state checks on each of eight full-model runs, and the entire 162,529,280-byte state region against the emitter's hash with no carve-outs silicon.
Bit-exact to the integer model is a separate question from faithful to the float model. Against the bf16 original, the quantized 9B agrees on the top token in 98 of 108 teacher-forced steps sim. GPTQ, which rewrites the 4-bit codes without changing the layout or the byte count, cut the perplexity penalty from +8.79% to +2.58% sim.
At 0.8B and 2B, every layer's persistent state sat in on-chip memory, banked by layer. The 9B doubles the DeltaNet value heads, doubles the attention heads and adds eight layers. The same design needed 928 of the device's 960 UltraRAMs.
It synthesised and placed. It did not meet timing: eleven out-of-context placements, the best of them 0.554 ns short. Floorplanning alone could not close a memory that has to span all three dies.
The redesign moved all layer state into DDR and left a two-slot cache on the chip for each kind. While one layer computes out of one slot, a 512-bit DMA engine stores the previous layer's state and loads the next into the other. That added two layer commands, a new AXI master and its own error codes.
The DMA lane costs 5.125 ms per token running beside 41.588 ms of compute silicon, and moves about 70 MiB per token at a context of 512.
| State region, DDR channel 3 | Size |
|---|---|
| DeltaNet matrices, 24 layers × 1 MiB | 24 MiB |
| KV cache, sized for 4,096 positions | 128 MiB |
| Conv taps and history, 24 × 128 KiB | 3 MiB |
A census on the chip testbench splits one 131.1 ms token three ways. The three activities sum to 98% of the token, which means they happen almost entirely one after another: stream weights, then move vectors, then compute.
So the DDR path, the thing the physics says is the limit, is idle more than half the time. The engines wait for the movers, the movers wait for the scratchpad, and the scratchpad has one owner at a time. Every speed-up since the 9B first ran has been a way of overlapping those three.
A dependency model of the stream puts the limit of overlap at 86.7 ms per token, 1.51 times the shipped order model. The naive bound of 2.36 times is not reachable, because the scratchpad is single-ported between compute and the movers.
| Round | What changed | Chat gain |
|---|---|---|
| Reorder | Software only. Fences moved to the point of use, a dependency-safe reorder, redundant MOVX removed. | ×1.125 |
| R1 | FENCE takes a channel mask and waits only for the channels it names. | ×1.041 |
| R2 | A second bank in each XWIN and RES memory, so the next x can be staged while an engine runs. | ×1.032 |
| R3 | One scratchpad read broadcast to all four channels over a direct 376-flop bus. Built and signed off, not loaded. | ×1.085 model |
The xcvu9p is three dies stacked on an interposer. Signals that cross between dies are slow and limited in number. The design uses 26% of the LUTs, which sounds comfortable, but the hard parts are local: the layer engine takes 81% of one die's DSPs and all of the UltraRAM in use.
The main clock is 250 MHz because the PCIe bridge generates it. That gives every path 4 ns. The newest build closes with 0.004 ns to spare on its worst path; the bitstream on the board closes with exactly 0.000.
That zero was produced once. Six placement runs of the same netlist spread over 0.512 ns, so the margin is far smaller than the tool's own run-to-run noise.
| build_046 | Die 0 | Die 1 | Die 2 |
|---|---|---|---|
| Logic blocks used | 61.9% | 66.2% | 7.3% |
| LUTs | 152,630 | 141,740 | 15,457 |
| Flip-flops | 115,833 | 182,654 | 21,656 |
| DSP slices | 1,845 | 12 | 3 |
| UltraRAM | 182 | 0 | 0 |
| Block RAM tiles | 112.5 | 113 | 25.5 |
2,993 wires cross between die 0 and die 1, and 1,358 between die 1 and die 2. The third die is nearly empty.
| Step | Worst slack, ns |
|---|---|
| First placement | −0.859 |
| Best of four placement directives | −0.156 |
| Floorplan: none, then a layer region, then a context region too | −0.247 → −0.768 → −1.126 |
| RTL round: one memory cascade capped, three stages split | +0.091 gained |
| Clock root moved to the layer engine's centroid | −0.156 → 0.000 |
| Post-route physical optimisation | +0.000 gained |
The clock-root move changed clock skew by 0.407 ns and left the data paths alone. Floorplan regions cost slack every time one was added, so the shipped build has none. R1, R2 and R3 were each built incrementally against a signed-off checkpoint and closed at +0.001, +0.004 and +0.004.
| Clock | MHz | Slack, ns |
|---|---|---|
| Main clock, from the PCIe bridge | 250.00 | +0.012 |
| DDR channel 0 user clock | 300.12 | +0.064 |
| DDR channel 1 user clock | 300.12 | +0.055 |
| DDR channel 2 user clock | 300.12 | +0.055 |
| DDR channel 3 user clock | 300.12 | +0.026 |
| Design worst, inside the bridge | +0.004 |
The charter allows no claim without evidence captured in the repository. Every stage needed its own reference model, simulation against it before hardware, and four seeds on the board, each run twice without reprogramming.
That rule is why the RTL is one line in twenty. There are 23 testbenches totalling 11,406 lines, almost exactly the size of the RTL they test. There are 33 reference-model and generator scripts, 4,860 tracked evidence files, and 22 gate reports.
Two testbench habits recur. Differential benches feed one random command stream to a frozen copy of a module and to its rewrite, compare the full scratchpad after every command, and never assume the two take the same number of cycles. And benches carry sabotage tests: deliberately broken comparators that must fail, to prove the check can.
A design this layered fails quietly more often than loudly. These are on the record in the repository, each found the hard way.
| Situation | What happens | What guards it |
|---|---|---|
| A run reuses DDR without resetting the state region | The wrong token comes back with error code 0x00. | The chat tool now writes the region itself. The lower-level runner is unchanged, so the defect stands there. |
| The weight pack in DDR belongs to a different model | The identity gate passes. Nothing ties the resident pack to the resident model; the 2B pack was once uploaded over the 9B one this way. | Still open. A per-model template pin makes it harder to reach. |
| The host is slow to drain the token FIFO | A push past 64 entries drops the token. The sequencer does not stall. | A sticky overflow bit that survives restart. |
| An R2 stream runs on a bitstream without R2 | Accesses to the second bank silently use the first. | Host admission against a capability register. R1 and R3 streams fault at decode instead. |
| Context reaches 512 positions | A 40-bit sum in the attention core can wrap in the worst case. 526 positions have matched on the board; that is evidence, not proof. | The ceiling is held at 511 by analysis until the register is widened. |
| The reference model runs at the wrong residual format | 12,096 wrong shifts in the reference, invisible for 17 hours. The chip was right. | The format is now derived from the model tag. |
| The placer moves the layer engine to another die | The clock-root constraint still applies without error, now pointing at the wrong die. | A script checks every routed build. It has an open hole: for an unknown location it compares "?" with "?" and reports OK, so that result is read as a failure. |
| A 4-core workstation does the arithmetic | It computed wrong results on two occasions in the 9B campaign. | Every emission, simulation and build runs on the server. The workstation is retired from numeric work. |