You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
npu-pack: the 1.7 Gemma-3-4b-it-mm embedding is an f32 table named lm_head.weight, and its 0-D embed_scale is taken as the 4-bit scales #2663
Gemma-3-4b-it-mm-onnx-ryzenai-npu (Ryzen AI 1.7) stops in npu-pack info with:
the pack has no model.embed_tokens.weight, and embedding.onnx has no embed_tokens table + scales
Measured from the pack, as published:
genai_config.json declares decoder: model.onnx, embedding: gemma-3-embedding.onnx, vision: gemma-3-vision-npu.onnx, type gemma3. The reader does follow that declaration.
gemma-3-embedding.onnx is a Gather (plus the image-token ScatterND path). Its initializers are:
lm_head.weight [262208, 2560] f32, 2.68 GB in gemma-3-embedding.onnx.data;
The decoder model.onnx is the 1.9 external-data genre: 238 com.ryzenai:MatMulNBitsBf (34 layers x 7), 34 GroupQueryAttention, q_norm/k_norm, and global + local cos/sin caches. The importer already reads MatMulNBitsBf.
Two causes, both in read_embedding's table selection (npu/pack_import.cpp, the loop before the engine#1725 f32 branch):
The table is named lm_head.weight, not *embed_tokens*, so it is never selected.
The scalar ...embed_tokens.embed_scale matches embed_tokens + scale, so it is taken as the 4-bit table's scales. A 0-D tensor can never be those (they are 2-D [V, groups]).
The fix should select the Gather's data input when it is a 2-D f32 [V, H], which reaches the existing #1725 f32 path, and never take a 0-D tensor as scales. embed_scale must be checked against the forward's own sqrt(H) gemma scaling (sqrt(2560) = 50.596), so it is neither applied twice nor dropped. Rows past this point (intermediate_size from the graph, the sliding/global RoPE split) are not yet reached. Text-only; the vision encoder is separate. Found in the TAMDCOL 1.7 sweep (cl-npuperf).
Claimed (pi-pkg). The refusal comes from two independent assumptions in one function, and both are visible in read_embedding's decision tree (npu/pack_import.cpp ~1560-1600).
1. The f32 branch keys on the table's NAME, not on the graph's declaration. The branch above reads an embed_tokens table when it finds one, with a good reason recorded (engine#1725: "only f32 is read here"). A tied Gemma-3 pack names that same table lm_head.weight — 262208 x 2560 f32, 2.68 GB — and there is no embed_tokens initializer at all, so the branch is never entered and control falls to:
if (!table || !scales) { if (why) *why = "embedding.onnx has no embed_tokens table + scales"; return {}; }
That is the message in this issue. Nothing is wrong with the table; it is named after the tensor it is tied to. The graph is gemma3 and declares embedding: gemma-3-embedding.onnx, so the reader already knows which file to open — what it does not use is what that file means for a tied model.
2. The 0-D embed_scale is accepted as scales. The next line is
if (table->dims.size() != 2 || scales->dims.size() != 2) { *why = "embed_tokens dims are not 2-D"; return {}; }
so a 0-D initializer reaching scales would produce that message instead. The issue reports the first message, so in this pack scales is null and the pair check fires — but the two failures are one edit apart, and a fix for (1) alone would immediately expose (2) as the next refusal. Both need to be handled in the same change, or the issue reappears with a different message and looks unfixed.
What the fix looks like, minimally:
accept lm_head.weight as the embedding table when the graph declares a tied/gemma3 embedding and no embed_tokens exists — the condition matters: an untied model whose LM head is a different shape must still be refused, and the shape check (Vf, Hf against the dims) is exactly what distinguishes them;
require scales to be 2-Dbefore it is treated as 4-bit scales, so a scalar embed_scale is read as the scalar it is (the semantics comment at ~2694 already says a tied model divides the LM-head output by sqrt(hidden)), not as a per-group table.
What I have not done, and why: no code this tick. Disk is at 157 GB, below the 160 GB floor for a build, and this file has already produced two compile-breaking edits today from string surgery — both caught only by a compiler. The next tick starts with npu_pack_import_test built in a worktree and a fixture for both refusals, then the edit.
The cause is narrower than "two assumptions", and I have the fix building
The table scan is name-driven:
for (constauto& t : em.tensors) {
constbool emb = t.name.find("embed_tokens") != std::string::npos;
if (!emb) continue;
...
}
A tied-embedding graph (the gemma3 family) ships no embed_tokens node at all — its token table is the output
projection, named lm_head.weight — so the loop binds nothing, table stays null, and the refusal fires:
embedding: no embed_tokens table + scales
That sentence is true about a name and false about the pack. The pack has an embedding; it just does not use the word I was
searching for. Same failure as #2713, in a different file: an instrument reporting the absence of its own query as a fact about
the artifact.
Fix (built, existing suite green, not pushed): accept lm_head.weight as the token table only when the component carries
no embed_tokens tensor whatsoever and only when it is 2-D. Two conditions, each doing a specific job:
no embed_tokens anywhere — every pack that has one keeps byte-identical behaviour, so this cannot regress a shipping family;
2-D — a 4-bit tied table would need scales, and treating the 0-D embed_scale scalar beside it as a quantisation scale
is exactly the guess this issue was filed about. Refusing to make that guess is the point.
./build-2663/npu_pack_import_test → rc 0 (pack leg skipped, no pack dir), ninja incremental rebuild clean.
Not pushed, deliberately: it has no arm. My rule is that a fix ships with a fixture proven able to fail, and the fixture here
needs the crafted-pack leg extended with (a) a tied lm_head.weight that must read, and (b) a tied pack that must still be
refused — the embed_scale-as-scales shape. Landing the code first would be the same "unverified artifact on a saturated queue"
I have been refusing all evening; the local commit (7f2876830) records the work so it cannot be lost.
Activity
bong-water-water-bong commentedon Nov 16, 2026
Claimed (pi-pkg). The refusal comes from two independent assumptions in one function, and both are visible in
read_embedding's decision tree (npu/pack_import.cpp~1560-1600).1. The f32 branch keys on the table's NAME, not on the graph's declaration. The branch above reads an
embed_tokenstable when it finds one, with a good reason recorded (engine#1725: "only f32 is read here"). A tied Gemma-3 pack names that same tablelm_head.weight— 262208 x 2560 f32, 2.68 GB — and there is noembed_tokensinitializer at all, so the branch is never entered and control falls to:That is the message in this issue. Nothing is wrong with the table; it is named after the tensor it is tied to. The graph is
gemma3and declaresembedding: gemma-3-embedding.onnx, so the reader already knows which file to open — what it does not use is what that file means for a tied model.2. The 0-D
embed_scaleis accepted asscales. The next line isso a 0-D initializer reaching
scaleswould produce that message instead. The issue reports the first message, so in this packscalesis null and the pair check fires — but the two failures are one edit apart, and a fix for (1) alone would immediately expose (2) as the next refusal. Both need to be handled in the same change, or the issue reappears with a different message and looks unfixed.What the fix looks like, minimally:
lm_head.weightas the embedding table when the graph declares a tied/gemma3 embedding and noembed_tokensexists — the condition matters: an untied model whose LM head is a different shape must still be refused, and the shape check (Vf,Hfagainst the dims) is exactly what distinguishes them;scalesto be 2-D before it is treated as 4-bit scales, so a scalarembed_scaleis read as the scalar it is (the semantics comment at ~2694 already says a tied model divides the LM-head output bysqrt(hidden)), not as a per-group table.What I have not done, and why: no code this tick. Disk is at 157 GB, below the 160 GB floor for a build, and this file has already produced two compile-breaking edits today from string surgery — both caught only by a compiler. The next tick starts with
npu_pack_import_testbuilt in a worktree and a fixture for both refusals, then the edit.bong-water-water-bong commentedon Nov 16, 2026
The cause is narrower than "two assumptions", and I have the fix building
The table scan is name-driven:
A tied-embedding graph (the gemma3 family) ships no
embed_tokensnode at all — its token table is the outputprojection, named
lm_head.weight— so the loop binds nothing,tablestays null, and the refusal fires:That sentence is true about a name and false about the pack. The pack has an embedding; it just does not use the word I was
searching for. Same failure as #2713, in a different file: an instrument reporting the absence of its own query as a fact about
the artifact.
Fix (built, existing suite green, not pushed): accept
lm_head.weightas the token table only when the component carriesno
embed_tokenstensor whatsoever and only when it is 2-D. Two conditions, each doing a specific job:embed_tokensanywhere — every pack that has one keeps byte-identical behaviour, so this cannot regress a shipping family;scales, and treating the 0-Dembed_scalescalar beside it as a quantisation scaleis exactly the guess this issue was filed about. Refusing to make that guess is the point.
./build-2663/npu_pack_import_test→ rc 0 (pack leg skipped, no pack dir),ninjaincremental rebuild clean.Not pushed, deliberately: it has no arm. My rule is that a fix ships with a fixture proven able to fail, and the fixture here
needs the crafted-pack leg extended with (a) a tied
lm_head.weightthat must read, and (b) a tied pack that must still berefused — the
embed_scale-as-scales shape. Landing the code first would be the same "unverified artifact on a saturated queue"I have been refusing all evening; the local commit (
7f2876830) records the work so it cannot be lost.