A 544-word program with two matrix instructions spends about 95% of its time not computing. Almost all of it is the host re-sending weights the device already has. Turn that off and the launch gets 5.15× faster with byte-identical output. Then halve the weight bytes with w4 quantization and the full model reaches 25.5 tok/s — matching the vendor's own w4 reference. Toggle dispatch below; scroll to §3 for the w4 story.
up_proj launch · K=1536 N=168Note the middle band. Wait drops too, 0.2932 → 0.1659 ms — the NPU work is identical, so what shrinks is the queue behind a transfer that is no longer queued.
The four deployed projections were each timed on the board. This calculator is
anchored on them — it reproduces k_proj and up_proj
exactly and the other two within 0.015 ms — so it interpolates a real measurement rather
than inventing one. Click a row to load it.
| deployed kernel | K | N | input B | measured ms | fit |
|---|
A per-launch number is not a product claim. Amdahl applies: the rest of a decode step is not transport. Deployed decode at 8192 context (two separate runs, medians of 17 and 21 steps — not one interleaved A/B):
| dispatch mode | ms / token | tok/s |
|---|---|---|
| nocache | 222.3 | 4.50 |
| cached | 219.3 | 4.56 |
| mixed | 198.6 | 5.04 |
| zero_once_v2_352 | 167.1 | 5.98 |
Resident dispatch removes redundant transfers. The next lever removes redundant bytes: quantize the weights from int8 to uint4 and the DMA payload halves. The two compound — fewer bytes, each sent once — and together they take MiniCPM5 decode from 12.05 to 25.5 tok/s.
| configuration | ctx | ms / token | tok/s | vs baseline |
|---|---|---|---|---|
| w8 vendor baseline | 8192 | 83.0 | 12.05 | — |
| w8 + resident dispatch | 8192 | 167.1 | 5.98 | 0.50× |
| w4 DLD (v4 patcher) | 8192 | 51.9 | 19.27 | 1.60× |
| w8 vendor baseline | 1024 | 59.6 | 16.77 | — |
| w4 DLD (v4 patcher) | 1024 | 39.2 | 25.5 | 2.12× |
| vendor cpm5x4_w4.om | 1024 | 24.55 | 24.55 | ref |
The method patches four surfaces inside the .om container, all traced from
the DLD (direct-load) instructions backward through the register chain:
| surface | what changes |
|---|---|
| paraDataType | s8 (0x06) → u4i (0x03) in cube metadata |
| GLP[2,3,4] | bond count → 16, PLUT codebook in GLP[3]+GLP[4] |
| GLP[6] via SGLP MOV | dtype + preproc enable in the instruction stream |
| weight bytes | k-means 16-centroid → 4-bit index packing, upper half zeroed |
cpm5x4_w4.om on the board measures 11.998 ms — identical to
w8 (11.998 ms). Its metadata says u4i but its weight section is not repacked: the DMA
still transfers the full int8 payload. Only the DLD-level v4 patch produces a real w4,
because it rewrites all four surfaces together.decode.om (single-layer ctx1024): w8 baseline 2.1274 ms
(median of 10), w4 v4 1.3809 ms (median of 10), w8 control
2.1313 ms. The 1.541× comes from a measurement, not a model — and two
projection routes from it agree: ctx-scaling from R9 (25.5) and vendor-baseline ratio
(25.8).The vendor executor's ordinary execute op re-sends every input buffer on every launch.
A trained weight does not change between tokens; an activation does. That distinction is a
compiler fact — a host runtime cannot recover it from buffer sizes — so the
compiler now states it, traced from each load to the op that consumes it, and
the host runtime consumes the statement.
tile_hal::cost::LaunchCost with those four launches as a test
fixture, so the constants cannot drift from the measurements without the build saying so.up_proj was timed twice: 0.2502 ms in the four-point sweep,
0.2322 ms in the resident A/B. Same kernel, same board, 7% apart — ordinary
between-run spread on live silicon. It matters here because a calculator anchored on the
sweep reads about 4.84× where the A/B pair reads 5.15×.
The headline stays 5.15× because the A/B timed both arms in one interleaved run and the
sweep did not; if you recompute from the four rows above and land near 4.84×, that is the
spread and not an error.