Repository navigation
Description
What is wrong. The brief's step-3 requirement for 1bit npu-pack import is that "int4 codes + scales are exact; any mismatch is a parse error". The codes are exact — every attention tile and MLP group decodes and re-encodes byte for byte. The scales are not, and cannot be with the current container format: our Q4NX stores per-group scale/zero as bf16, the OGA packs store them as fp32, so on import roughly half the groups lose the low mantissa bits.
Measured on all four OGA packs on this box, device-free (1bit npu-pack import <pack> -o /tmp/x, ~10 s each):
| pack | groups bit-equal after import | container round trip (vs pack) | max |diff| |
|---|---|---|---|
| Qwen2.5-0.5B | 43.46 % | 3.34e-3 rel | 2.44e-4 |
| Llama-3.2-1B | 43.09 % | 3.34e-3 | 4.88e-4 |
| Qwen3-1.7B | 46.23 % | 2.84e-3 | 4.88e-4 |
| Qwen3-4B | 47.69 % | 2.75e-3 | 3.66e-4 |
The importer prints this today as bf16 scale/zero exact for N% of 32-column groups (format limit) — so it is visible, but the requirement it is failing is not written down anywhere, and every "weight-exact" claim about the import path (including several in our own lane notes) reads as if it held.
Why it is a real bound and not rounding noise. bf16 has an 8-bit mantissa: 2^-9 ≈ 2e-3, which is exactly the observed 2.7-3.3e-3 relative round-trip error. A 4-bit code with an fp32 scale and the same code with a bf16 scale differ by up to half a bf16 ulp of the scale — i.e. ~0.2 % of each weight, on ~56 % of groups.
What is not known. Whether this is visible in logits. The family gates' KLD numbers (7e-6 / 1e-5 vs the upstream fp16 checkpoints) are small enough that a 2e-3 weight perturbation is plausibly invisible, but nobody has measured the two containers against each other (same weights, fp32 vs bf16 scales, same logits) to say so. That comparison is the acceptance test for whichever option is chosen.
Options, in increasing size.
- Document the bound where the requirement is stated and keep bf16 (zero code change): the import is "codes exact, scales to bf16", and the number is in the manifest the importer already writes. Cheapest, and honest.
- Carry fp32 scales for imported containers, gated by the container's layout-version field, so pack imports keep the pack's own fidelity while GGUF-derived containers keep bf16 (which is where the bf16 choice came from). This is the option that satisfies the brief as written.
- Do nothing and remove "scales exact" from the requirement — not recommended: it hides a measured 2.7-3.3e-3 floor behind a claim that reads stronger than it is.
Reproduce (device-free, no NPU ticket, ~10 s per pack, ~6 GB scratch):
/home/bcloud/wt/oga-fwd-timings/build/1bit npu-pack import \
~/models/oga/Qwen3-1.7B_rai_1.8.0_npu_4K -o /tmp/imp/17b
# -> "container: read back through q4nx::dequant_tile rel_err 2.842e-03 max |diff| 4.883e-04"
# -> "parameters: bf16 scale/zero exact for 46.23% of 32-column groups (format limit)"
Why it belongs in this issue. The import path and the pack-format facts are this issue's subject; the requirement ("scales exact") is part of the same brief, and the loader currently satisfies it for the codes only. Recording it here rather than leaving it as a printed percentage nobody has to read is the point.
Found 2026-11-05 while measuring the import across four packs; the four-pack table and the pack-side facts are in the npu-re hub, docs/FACTS-oga-pack-weight-layout.md (commit 0f9dd0a).
Activity