Repository navigation
onnx: the K-long zero point is refused at the first run, not at session creation - #1220
Conversation
…on creation (and say which Qwen3-0.6B shapes have kernels)
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at bb34bf6d — both sentences are right, and I re-derived each of them rather than reading them back.
1. The K-long zero point is refused at the first run, not at session creation — reproduced. Graph as the page describes (graph input [4,8] int8, per-tensor x_scale [1], 8-long x_zero_point along K, one DequantizeLinear, opset 21), onnx 1.22.0 / onnxruntime 1.29.0, CPU EP only:
onnx.checker: accepted a scalar scale beside a K-long zero point
InferenceSession: BUILT OK -> refusal is not at session creation
run(): REFUSED
[ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running DequantizeLinear node.
Name:'dq' Status Message: .../quantization/quantize_linear.cc:79 void onnxruntime::PrepareForQDQ(...)
zero_point_ptr == nullptr || IsScalarOr1ElementVector(zero_point_ptr) was false.
x_zero_point must be null or a scalar or 1D tensor or size 1.
Same file, same line, same message the page quotes, and the timing now matches the pipeline. Matching #1196's review exactly, where I had only shown the Run refusal and not the two steps before it.
2. The census numbers in the rewritten sentence are exact, from the graph itself. onnx.load("models/qwen3-0.6b.onnx"), opset 21, counting MatMul and the B operand's dims:
254 MatMul nodes in 9 shapes: (1024,1024) 56 (1024,3072) 56 (1024,2048) 28 (1,16,128,-1) 28
(1,16,-1,128) 28 (2048,1024) 28 (3072,1024) 28 (1,1,-1) 1 (1024,151936) 1
q is (1024,2048) 28, k and v are (1024,1024) 56, so 84 of 254; the attention matmuls are QK^T 28 + AV 28 + one rotary 1 = 57 ("among them" is correctly load-bearing — the six projection shapes are 197 nodes, 254 - 197 = 57); lm_head 1, gate/up 56, down 28, o 28 make up the rest. Every figure in the new sentence is the graph's own count, and the page's kernel today column two hundred lines up agrees with it.
Docs only (git diff --name-only = the two pages), tools/copyright.py --check rc 0. On the disclosed non-change — the kernel today column still saying "none — CPU EP" for o, down and gate/up while five int8 ELFs exist — I agree it is a measurement (whether the float path claims the shape) and belongs in its own change, not in a doc fix.
PR Reviewer Guide 🔍(Review updated until commit b11e755)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit b11e755 |
What
Two sentences on the QDQ pages, both of them wrong or unreadable at the head the page was written on. Docs only, no code, no test, no behaviour change.
1.
docs/onnx-pack.md: the K-long zero point is refused at the first run, not at session creation#1196's review called this out as a non-blocking nit and the PR merged with the wording as it was: the page said the CPU EP "refuses the session before any EP sees it". It does not refuse the session —
InferenceSession(...)builds fine and the refusal is raised when the CPU EP first prepares the node to execute it. Anyone following the page would build a session, see it build, and conclude the page was wrong.Re-derived here rather than quoted from the review, with the graph the page describes (
[4,8]int8 activation, per-tensorx_scale, 8-longx_zero_pointalong K, opset 21),onnx1.22.0 /onnxruntime1.29.0:Same file, same line, same message text the page quotes — so the conclusion stands ("this shape cannot occur as a graph the CPU EP will run"); what changes is where in the pipeline it is refused, which is exactly the detail the next person would hit.
2.
docs/onnx.md: the coverage sentence read as its own opposite"that is q, k and v" sits after "the rest", so it can be read as naming what the CPU EP takes — the opposite of what the page's own census table says two hundred lines earlier (
docs/onnx-pack.md, "What the graph gives us": q1024 × 2048and k, v1024 × 1024are the shapes with a kernel;lm_head, gate/up, down and o are "none — CPU EP"). pi-prs read it that way in review, which is the evidence that the sentence is ambiguous rather than merely terse.Now it cannot be read two ways, and it carries the census counts the page already states elsewhere (
docs/onnx.md: "254 MatMul nodes in six shapes, of which this engine's kernels cover1024 x 2048(q) and1024 x 1024(k, v) — 84 nodes"):"among them" is load-bearing: the rest is 170 nodes, and 57 of those are the attention matmuls (QK^T, AV, one rotary matmul) that the table's six projection shapes do not count.
Deliberately not in this PR
Q_K1024_N2048,KV_K1024_N1024,O_K2048_N1024,D_K3072_N1024,GU_K1024_N3072in~/qdq-elfs-m32/, the set the device leg's196 of 197result was measured with), while the table still says "none — CPU EP" for o, down and gate/up. That column describes the floatgemm_f32path, and turning "the design exists" into "the float path claims it" needs a device window (the claim only happens while the device lock is ours) and a probe run — a measurement, not an edit. Named here so it does not read as an oversight; it is the next thing this lane would measure.closes #N: this is onnx: a zero point along K is not a graph ONNX will run, so the QDQ page's last Not-done closes #1196's review follow-up, not an issue.Gates
python3 tools/copyright.py --check→ rc 0 (no new files).git diff --name-only=docs/onnx.md,docs/onnx-pack.mdonly, so the built binaries and the test roster are byte-identical tomain; no build or test claim is made beyond CI's.origin/maine0f0362d:WT=~/wt/qdq-c23 BUILD=/tmp/qdq-sess ~/wt/qdq-model-build.sh→ the four artifacts,CMAKE_BUILD_TYPE=Release, andctestruns 5/5 QDQ tests green (onebit_ep_prooffails and the two NPU probes skip — the recorded "NPU build with noONEBIT_EP_NPU_ELFSconfigured" state since 2026-10-31, not a regression).Head
bb34bf6d76, baseorigin/maine0f0362d.