Skip to content

npu-pack: the attention payload does not decompose into whole tiles for any family except the 0.5B (Llama-3.2-1B, Qwen3-1.7B, Qwen3-4B) #979

Closed

Description

@bong-water-water-bong

Three of the four real OGA NPU packs on this box still refuse to import, all at the same place: the per-layer
attention payload between the layer block's first .fconst header and the post-attention header. The 0.5B pack
divides that payload into whole tiles exactly; the other three do not, and for two of them the whole-tile row count
does not even equal q+k+v+o. This is brief item 4 of the OGA-pack lane ("record which pack features the loader does
not yet understand as issues, not as silence"), filed now that the importer converts the 0.5B pack whole (#844).

Measured, on the shipped packs

1bit npu-pack import <pack> today exits 3 and writes nothing. Tile geometry is
tile(k) = (2*(k/128) + 2) * subv(64) with subv(rows) = 64*(rows/2) + 64 + rows = 2,176 at 64 rows, so
tile = 2,176 * (2*k/128 + 2):

pack hidden k tile B attention payload B whole tiles stray bytes
Qwen2.5-0.5B 4K 896 34,816 1,114,112 32 exactly 0
Llama-3.2-1B 4K 2,048 73,984 5,921,024 80 2,304
Qwen3-1.7B 4K 2,048 73,984 4,737,280 64 2,304
Qwen3-4B 4K 2,560 91,392 8,776,960 96 3,328

Predicted tile sizes match the importer's arithmetic on all four (73,984 for k=2,048, 91,392 for k=2,560), so the
tile formula itself is not in question — the payload decomposition is.

What the row counts say, and where it stops adding up

64 rows per tile, and q+k+v+o rows from each pack's own config.json dims:

pack q k v o q+k+v+o rows in whole tiles agree?
Qwen2.5-0.5B 896 128 128 896 2,048 2,048 yes
Llama-3.2-1B 2,048 512 512 2,048 5,120 5,120 yes (+2,304 B stray)
Qwen3-1.7B 2,048 1,024 1,024 2,048 6,144 4,096 no
Qwen3-4B 4,096 1,024 1,024 2,560 8,704 6,144 no

So Llama's whole-tile count is right and only the trailing 2,304 B is unexplained, which is the cleanest lead: if
that stray run is a third sub-stream at the section's end (it is present in exactly the same size on two packs with
the same k), Llama would decode with a one-line change. Qwen3's row counts fit q+k+v (4,096 and 6,144) rather than
q+k+v+o, which suggests either a different tile row count for those families or that o_proj is not in this section
— both are guesses at this point and neither is being coded.

The stray bytes do not fit a simple per-k or per-group law: 2,304/2,048 and 3,328/2,560 are not proportional, and as
a + b*k the two points give a negative a. Both are multiples of 128 (18 and 26 groups of 128 B), which is
suggestive and nothing more.

Not doing

No guessed layout. This lane has already paid for guessing on this exact file format: five attacks on the 0.5B tile
order (guessed layouts, ground-truth scale arrays, exact-code block matching) all came back at noise before the vendor's
own preformat routine gave the answer as a transpose. A partial layout that decodes "plausibly" is worse than a refusal,
which is why the importer refuses and names the tensor instead.

What would close it

  1. The pack is the oracle: Llama-3.2-1B is a different family with a public upstream checkpoint
    (meta-llama/Llama-3.2-1B), so the same tie-break the 0.5B used applies — the pack's fp16 embed_tokens is already
    read and self-checks at corr 0.999999, and a recovered ground truth makes a candidate decomposition falsifiable
    instead of plausible.
  2. The vendor writer (libdyn_dispatch_core.so, restored under ~/ryzenai-1.8/) calls
    matmulnbits_preformat and the tile writer directly from Python — that is how the 0.5B tile order was closed
    (transpose [N,K] -> [K,N], out = code - 8), and it needs no device.
  3. Failing both, the trailing run can be measured: locate the section's last q/k/v/o row group and read what the
    stray 2,304 B actually is on Llama before changing the tile arithmetic.

Pack features understood today, for the record: 4-bit MatMulNBits decode (verified against the pack's own tied
embedding), the attention tiles and their bias subvolumes, the MLP gate|up fused unit and down_proj groups, all 48
layer-norm anchors, and the final norm in the tail envelope (#844). The attention payload for hidden != 896 is the
remaining blocker for a second family end-to-end.

Activity

  1. bong-water-water-bong commented on Nov 4, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Root cause found and fixed (measured, not guessed): #986 now carries both facts.

    The "attention payload does not decompose into whole tiles" symptom had two causes in the loader, not in the packs:

    1. The payload's offset was the constant 1,856 instead of 64 + 2*hidden → every pack except the 0.5B was read 2*(hidden-896) bytes early. That is where the stray runs in this issue's table came from, and it is why 2,304 and 3,328 fitted no law: 2,304 = 2*(2048-896) and 3,328 = 2*(2560-896). The stray run was the block's input_layernorm weight.
    2. The section is not always one uniform run of q/k/v/o. The Qwen3 packs carry four epsilon headers per layer block (Qwen2.5/Llama carry two), and the three sections between them decompose exactly as [k,q,v tiles @ K=hidden] [header + per-head k_norm] [header + per-head q_norm + o_proj tiles @ K=q_proj's width].

    So this issue's "Qwen3's row counts fit q+k+v — a hypothesis, not a finding" was right, and it is now a finding with two independent confirmations:

    • The pack's own cache/*_meta.json op_list for layer 0 runs k_proj, q_proj, v_proj, attn/k_norm/MLADFRMSNORM, attn/q_norm/MLADFRMSNORM, FLATMHA, o_proj — matching the file's section order — and declares o_proj N=2560 K=4096 on the 4B, i.e. K is q_proj's output width, not hidden.
    • The arithmetic closes to the byte on both packs, and the 320 B between the norms is identical in both although hidden differs by 512 (it is 64 + 2*head_dim, a per-head gain):
    pack k/q/v section between the norms q_norm + o_proj
    Qwen3-1.7B (hidden 2,048) 64 × 73,984 = 4,734,976 ✓ 320 ✓ 320 + 32 × 73,984 = 2,367,808 ✓
    Qwen3-4B (hidden 2,560) 96 × 91,392 = 8,773,632 ✓ 320 ✓ 320 + 40 × 143,616 = 5,744,960 ✓

    Which 256-byte run is q and which is k was settled against the public checkpoints, by range-fetching only those two tensors: Qwen/Qwen3-1.7B and Qwen/Qwen3-4B give 0 of 128 bf16 values differing at k_norm → header 1+64 and q_norm → header 2+64, and 127-128 of 128 differing on the swap. The container the importer writes is bit-identical to the same tensors, so the write path is verified end to end.

    Result with #986 + #844 in the tree: all four real packs on this box convert whole — 0.5B 291 tensors, Llama-3.2-1B 147, Qwen3-1.7B 311 (210,016 tiles, 2,688/2,688 byte-exact), Qwen3-4B 399 (491,000 tiles, 4,896/4,896 byte-exact). No device time was used for any of it.

    What this issue does not close — the two things that remain, named rather than left as silence:

    • The Qwen3 family has not been run on the array. Import is not inference: the container side (npu/pack.cpp fill_i6) and the forward (sem_.qk_norm) already carry and apply per-head q/k norms, but no Qwen3 pack has produced a token on our kernels. That is this lane's step-5 work and it is parked behind the amdxdna abo->dying race fix, not behind anything in the loader.
    • The _hybrid pack (model.bin flavour) still refuses with 240 tensors: it has no dd_metastate_*.fconst and no cache/, so there is nothing to read the layer blocks from. It is a different container flavour, not an attention-layout problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions