Repository navigation
Description
Split out of #612 (item 1, PR #640). That PR makes two NPU engines possible through a supported opt-in
lock (--npu-streams N); it says nothing good about their throughput, and now it has been measured.
The problem, measured
Two resident engines on whole-array kernel sets lose throughput. strixhalo 2026-10-30, binary
b78868c (-DONEBIT_NPU=ON), both serves on the shared lock (no NPU_NO_DEVICE_LOCK), 8 greedy
tokens, temperature 0, 3 reps per arm, rep 1 dropped, each model measured alone with the other not
loaded, kernels ~/lb/lfm2-npu/kernels_m16:
| arm | wall (s), mean of 2 measured reps | decode (tok/s) |
|---|---|---|
| Qwen3-0.6B alone | 5.79 | 1.38 |
| Qwen3-4B alone | 25.08 | 0.32 |
| both at once: Qwen3-0.6B | 16.99 | 0.47 (34.1 % of solo) |
| both at once: Qwen3-4B | 35.61 | 0.22 (70.4 % of solo) |
| aggregate | 0.41x |
Running the two models back to back is 2.4x faster than running them together. The per-token times add
up (0.72 + 3.13 s solo per token = 3.85 s against 4.45 s concurrent, plus ~16 % handoff), which is what
"two whole-array streams share one DMA engine" looks like. The 0.6B pays most (34 % of solo) because it
is latency-bound; the 4B keeps 70 % because its token cost is its own 3.3 GB weight stream anyway.
The same protocol on one model twice, lock bypassed, measured 65.7 % of solo per stream, 1.31x
aggregate (a88ef00, 2026-10-29) — better aggregate only because both streams stream the same weights.
The arrangement that scaled, and why it is not here
#612's own table has the row: "Two concurrent NPU streams, disjoint array halves — ~100 % of
single-stream speed each, the arrangement that scales". The September prototype got there by giving each
stream a disjoint half of the array columns, which also halves per-stream weight reuse; four
full-array streams measured ~24 % each with no aggregate gain, i.e. full-array execution is mutually
exclusive but column-disjoint execution is not.
It cannot be re-run to confirm: the prototype's model is gone and its halved xclbin pair is ABI-stale by
its own header (2026-10-29 pass, #612). So "~100 % each" is a September claim, unverified at any current
pin — this issue exists to settle it, not to repeat it.
What it would take (smallest build plan)
- Kernel side — a half-array ELF family. Rebuild the
full_i8_*design family from
npu/dx/kernelsfor a 4-column (half) array: same geometry, half the AIE columns per program, so two
engines' programs occupy disjoint column sets. Nothing else about the model changes: the weights
(model.q4nx) stay whole, each engine loads its own copy as it does today. - Verify before any model run (lane rule): host-side bounds proof for the rebuilt programs, then the
existing small-shape CPU-vs-NPU checks (ctest -R npu_q4nx,npu_forward_loader, golden tensors), and
only then a model. - Lock carries the partition id.
--npu-partition {0,1}: takeLOCK_EXon
/tmp/1bit-npu-device.part{N}andLOCK_SHon the whole-device file. That gives exactly the
semantics wanted: two partitioned engines on different partitions co-exist; two on the same partition
exclude each other; a full-device (LOCK_EX) run excludes both and waits for them; a partitioned run
waits for a full-device holder.--npu-streamsstays for the no-partition case. - Measure with the same protocol as showcase: one measured heterogeneous demo (2-stream NPU, batched HRX, hybrid) at the current pin #612 (8 greedy tokens, 3 reps, rep 1 dropped, solo then
concurrent, per-stream and aggregate, pin stamped), on the same pair Qwen3-0.6B + Qwen3-4B so the
numbers are directly comparable with the 0.41x above. Acceptance: aggregate > 1.0x, and both streams'
greedy outputs identical to a whole-array run of the same prompt (a partition that changes the answer
is a bug, not a speedup). - Say what it costs: half-array programs have half the tiles, so a single stream on a partition is
expected to be slower than solo on the whole array; the win, if any, is aggregate. If step 4 shows
aggregate <= 1.0x, close this issue with that number and stop claiming the arrangement scales.
Out of scope
- The N=8 / 17.1 GB OOM boundary from showcase: one measured heterogeneous demo (2-stream NPU, batched HRX, hybrid) at the current pin #612 (needs the same half-array sets first, then a memory sweep).
- Tensor-parallel across the two engines: each engine serves its own requests here. An all-reduce
between them would be a different design and is not what the second engine exists for. - Anything Windows/ONNX: per the owner's decision on showcase: one measured heterogeneous demo (2-stream NPU, batched HRX, hybrid) at the current pin #612 (option b), on Linux both engines are this
runtime.
Activity
bong-water-water-bong commentedon Oct 31, 2026
Triage:
enhancement. Split correctly from #612, and the comparison it sets up is sound: the mechanism it hasto beat is merged (
#6403c2521222,--npu-streams N), the 0.41x aggregate in the body was measured with#612's protocol (8 greedy tokens, 3 reps, rep 1 dropped, each model alone first), so a half-array run measured
the same way will be directly comparable.
Order of work, and which part does not need the device:
model run (lane rule), since a 4-column program that reads outside its partition is a wrong answer, not a
crash.
--npu-partition {0,1}lock semantics (item 3) — plain file locking (LOCK_EXon/tmp/1bit-npu-device.part{N}+LOCK_SHon the whole-device file next to the existingapp/npu_device_lock.h), fully testable on this box with a two-process test that asserts the fourcombinations the issue names: partition/partition co-exist, same partition excludes, full-device excludes
both, partitioned run waits for a full-device holder.
throughput table measured through a readback that can return a short tile is not a throughput table.
If item 4 lands ≤ 1.0x aggregate, this issue closes with that number and #612's September "~100 % each" row
stops being repeated anywhere. I would rather see that outcome recorded than the arrangement stay folklore.
Board row:
~/briefs/TISSUES-BOARD.md(window order: ORCHESTRATOR item 4).bong-water-water-bong commentedon Oct 31, 2026
Status after today's merges (
#692state,4a58da9b0pin): not closed — no part of this issue is in the tree.Checked rather than assumed, at
origin/main3cddcd6:What today's work did not change:
#692is the pb16i weight layout and the sealed multi-instance ELF (contextswitches 386/token → 3, per-launch arithmetic byte-exact). It shortens one engine's token, which lowers the cost
side of running two engines but does nothing about the mechanism this issue asks for: a half-array (4-column) ELF
family plus
--npu-partition {0,1}so two engines occupy disjoint columns instead of sharing one whole array.#672was a pin bump.So the build plan in the body stands unchanged, and so does the acceptance: aggregate > 1.0x for the
Qwen3-0.6B + Qwen3-4B pair with both streams' greedy output identical to a whole-array run. If item 4 shows ≤ 1.0x,
this issue closes with that number and the September "~100 % each" claim stops being repeated.
Ordering note for whoever picks it up: item 2 (the lock semantics) is the only part that needs no device and it is
still the right first step —
LOCK_EXon/tmp/1bit-npu-device.part{N}plusLOCK_SHon the whole-device lock.Item 1's ELF family and item 4's measurement need a window, behind #666.
bong-water-water-bong commentedon Nov 1, 2026
Measured on strixhalo 2026-10-31 23:01-23:03 (Ross kernel lane, record in TROSS-GU-STATE.md 23:10 entry), half-array kernel sets built for Qwen3-0.6B on
npu2_4col(4 columns) next to the whole-array set (8 columns), all 16 ELFs x 3 seeds byte-exact against the frozen int8 harnesses (48/48):--npu-streams 2, greedy text identical in every arm): whole-array sets 1.15x aggregate vs one engine, half-array sets 0.88x of one whole-array engine.By this issue's own acceptance rule the half-array arrangement does not pay on the current amdxdna/firmware (no spatial partitioning); closing with that number. Re-open if a firmware with spatial partitioning appears. The generator with
--device npu2|npu2_4colandbuild_family.share in npu-kernelsnpu/arena/HALF/.