Skip to content

onnx EP: measure the A8W8 kernel on both legs — it is dispatch-bound, and slower than the host at decode - #853

Merged
bong-water-water-bong merged 6 commits into
mainfrom
1bit/onnx-ep-qdq-q8-probe
Nov 3, 2026
Merged

bong-water-water-bong merged 6 commits into
mainfrom
1bit/onnx-ep-qdq-q8-probe

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

The merged device leg (#702, #779) and the five-shape coverage in #848 are stated as correctness-only, and until now nothing had measured the kernel itself — the QDQ proof gates the graph against the CPU EP and prints no timings. This adds the instrument and reports what it says, which corrects this lane's own premise.

What is new

npu/ort/onebit_npu_gemm_q8_probe.cpp (+ a ctest entry that skips without a configured design):

  • runs C[m,n] = A[m,k] @ B[k,n] with int8 operands through gemm_q8_raw on the array, and through the EP's own host loop (onebit_ep_kernel.cpp's exact i-k-j int32 loop, copied byte for byte);
  • requires the two accumulators to be identical — an exact integer sum cannot differ, so a mismatch is a layout error or a truncated K, not rounding;
  • prints ms/call for both legs. Exit 3 (skip) when the shape has no design, 1 when they differ.

docs/onnx.md gains the measurement under the QDQ device paragraph, including why it is not a decode speedup.

The measurement (strixhalo, -O2, M=32 designs, npu-hold ticket, load 4.9–6.3 on 32 cores)

Every line below is also a correctness gate: all 12 configurations matched the host accumulators exactly.

shape rows device ms/call host ms/call
1024×2048 (q) 1 1.478 0.161 device 9× slower
2 1.967 0.346 5.7× slower
4 1.497 0.740 2.0× slower
8 1.883 1.318 1.4× slower
16 1.509 3.243 2.2× faster
32 1.497 5.796 3.9× faster
1024×1024 (k, v) 1 / 32 0.781 / 0.887 0.078 / 2.956
1024×3072 (gate, up) 1 / 32 2.246 / 2.618 0.239 / 8.400
2048×1024 (o) 1 / 32 1.441 / 1.469 0.158 / 5.686
3072×1024 (down) 1 / 32 2.153 / 2.552 0.248 / 8.071
M=128 xclbin, 2048×1024 1 1.606 0.159 vs M=32's 1.441 → M buys nothing

The call is dispatch-bound. q_proj costs 1.44–1.50 ms whether it is handed 1 row or 32, and an M=128 design at one row is not measurably slower than an M=32 one. Three consequences:

  1. A smaller design (m16/m32) does not help at decode; the padding was never the cost.
  2. A decode step pays one launch per projection — 196 of them on Qwen3-0.6B, ≈0.3 s/step of dispatch before any compute — and at one row that launch is ~9× the host loop it replaces. The device leg makes decode slower, not faster.
  3. What the array does give is a prefill leg: it crosses over between 8 and 16 rows and is 3.2–3.9× ahead at a full 32-row design.

So docs/onnx-pack.md keeps reading "correctness-only", and this PR says why in one place rather than leaving it implied. A decode-side win needs fewer, longer launches (one launch covering many projections, a batched kernel) — kernel work in the private repos, not an EP change.

Gates

# host, no CMAKE_BUILD_TYPE (/tmp/q8probe-host)
100% tests passed, 0 tests failed out of 6      (14.15 s)
# NPU config compiles (/tmp/q8probe-npu)
onebit_npu_gemm_q8_probe (Skipped)  onebit_npu_gemm_probe (Skipped)   # no design configured -> skip, not fail
tools/copyright.py --check → rc 0

The device numbers come from ~/wt/qdq-q8-timing.sh in three npu-hold -l qdq tickets (01793651439486673458.qdq, 01793651669799823526.qdq after a 502 s queue wait, …), with device-busy=0 and no amdxdma errors in journalctl -k. The M=32 designs were generated for this with the repository's own generator (n1_core_i8_v26.py, M % 32 == 0 is its rule — M=16 cannot be emitted) and live outside the repo in ~/qdq-elfs-m32/, like every other xclbin.

Not in this PR

  • No kernel or EP behaviour change: the probe is a harness, the EP still does what it did.
  • No tokens/s number. The per-call figures say a decode-side claim would be negative today, and a model-level run needs a Quark A8W8 export that is not on this box after the rebuild.
  • The two -O0 runs I took first are not quoted anywhere: their host column was 8.15 ms for a call that is 0.161 ms at -O2, so their ratios were upper bounds and their 82–96× "speedups" were an artifact of the build.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 85d2e32)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

702 - Partially compliant

Compliant requirements:

  • Added gemm_q8_raw in npu/ort for int8 operands
  • Implemented device path with shared epilogue
  • Fixed ONEBIT_EP_TRACE handling
  • Fixed repeated ELF rebuilding for failed shapes

Non-compliant requirements:

  • The PR description mentions that the device leg is correctness-only, but does not fully address the performance claims

Requires further human verification:

  • Verification of the performance measurements in the documentation

779 - Partially compliant

Compliant requirements:

  • Fixed the issue where one bad entry in ONEBIT_EP_NPU_ELFS would disable the whole device leg
  • Implemented recording of refused designs with reasons
  • Ensured remaining designs load correctly

Non-compliant requirements:

  • The PR does not address the runtime validation of designs (passing M=16 for an M=128 ELF)

Requires further human verification:

  • Verification of the runtime validation behavior

848 - Partially compliant

Compliant requirements:

  • Added proof cases for quark-kv and quark-gu
  • Corrected documentation to reflect 5 shapes on the array
  • Verified that 196 of 197 groups run on the array

Non-compliant requirements:

  • The PR does not include the actual kernel designs or runtime changes

Requires further human verification:

  • Verification of the actual kernel designs and runtime behavior
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Performance Misalignment

The measurement in onebit_npu_gemm_q8_probe.cpp shows that the device path is slower than the host path for most configurations, which contradicts the expectation that the device path should be faster. This could be due to the dispatch-bound nature of the kernel, but it's important to ensure that the performance characteristics are correctly interpreted and documented.

std::printf("q8 gemm m=%lld k=%lld n=%lld repeats=%d device %.3f ms/call host %.3f ms/call "
            "speedup %.2fx\n",
            (long long)m, (long long)k, (long long)n, repeats, dev_ms, host_ms,
            dev_ms > 0.0 ? host_ms / dev_ms : 0.0);
Incorrect Timing Calculation

The timing calculation in onebit_npu_gemm_q8_probe.cpp divides by repeats to get the average time per call, but the comment on line 26 says that repeats is the number of calls timed on each leg. This could lead to confusion about the actual timing being measured.

const auto d0 = std::chrono::steady_clock::now();
for (int r = 0; r < repeats; r++) {
    if (!onebit::npu::gemm_q8_raw(a.data(), m, k, n, b.data(), got.data(), &err)) {
        std::printf("NPU q8 gemm failed on repeat %d: %s\n", r, err.c_str());
        return 3;
    }
}
const auto d1 = std::chrono::steady_clock::now();
const double dev_ms = ms_per_call(d0, d1, repeats);

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: CHANGES — the measurement reproduces and the conclusion holds, but the instrument's device column is divided by the wrong count, so every number in the new table is ~5 % low.

What I re-ran (at 2a15e21)

Built the probe exactly as the PR describes (-DONEBIT_EP_NPU=ON -DONEBIT_NPU_RT_DIR=<private npu_rt>,
-DONEBIT_NPU_ENGINE_INCS=…/npu/forward/engine-src;…/npu;…/npu/forward/include, Release): rc 0, 0 warnings
from the new file
, onebit_npu_gemm_q8_probe links. With no design configured, ctest -R onebit_npu_gemm:
q8 gemm could not run: device busy: /tmp/1bit-npu-device.lock is held by another process → Skipped, i.e.
the skip wiring works and it does not redden a suite. Host config (-DONEBIT_ORT=ON, no build type), whole
suite: 70/70 passed (you quote 6 from a target-limited run; both are green). tools/copyright.py --check
→ rc 0.

Then, in an npu-hold -l "pi prs 853" ticket, the PR's own ~/wt/qdq-q8-timing.sh against the M=32 designs in
~/qdq-elfs-m32 and the M=128 iso-build xclbins: all 18 configurations ran and every int32 accumulator matched
exactly
(RESULT: every shape ran on the array and matched the exact host accumulators, rc 0), 5 s wall. The
table reproduces within noise at load 3.5 (mine → yours): q 1 row 1.471/0.161 → 1.478/0.161; q 32 rows
1.456/5.165 → 1.497/5.796; kv 0.769/0.766, 0.086/2.807 → 0.781/0.887, 0.078/2.956; gu 2.096/2.169, 0.261/7.657 →
2.246/2.618, 0.239/8.400; o 1.482/1.426, 0.189/5.265 → 1.441/1.469, 0.158/5.686; down 2.507/2.231, 0.280/8.060 →
2.153/2.552, 0.248/8.071. The two claims the conclusion rests on both hold here: a call is ~1.5 ms whether it is
handed 1 row or 32, and the M=128 design at one row is not faster for it (1.379 vs M=32's 1.482 on 2048×1024).

The blocker: the device column counts calls it did not time

    const auto d0 = std::chrono::steady_clock::now();
    for (int r = 1; r < repeats; r++) { onebit::npu::gemm_q8_raw(...); }   // repeats-1 calls
    const auto d1 = std::chrono::steady_clock::now();
    const double dev_ms = ms_per_call(d0, d1, repeats);                    // divided by repeats

The host leg times repeats calls and divides by repeats; the device leg skips r = 0 (it is the warm-up, so
it is outside d0 already) and then divides repeats-1 calls by repeats. Same shape, repeats=20:

rows=1  repeats=2   device 0.793 ms/call   (one call timed, divided by 2)
rows=1  repeats=5   device 1.254 ms/call
rows=1  repeats=20  device 1.454 ms/call   <- the table's 1.478 is this, so the true call is ~1.53
rows=1  repeats=21  device 1.579 ms/call
rows=1  repeats=1   device 0.000 ms/call  speedup 1538.23x   PASS
rows=32 repeats=1   device 0.000 ms/call  speedup 28176.66x  PASS

So the table's device column is (repeats-1)/repeats of the truth — 5.3 % low at the 20 repeats the timing
script uses, 20 % low at the 5 repeats the ctest entry passes
— and repeats=1 prints a meaningless 0.000 ms
and a four-digit "speedup" and still exits 0. The direction of every ratio is unchanged (9× slower at one row
becomes ~9.5×, 3.9× faster becomes ~3.7×), but the numbers as written are not the numbers measured, and this PR's
whole value is the number.

Fix is one line: either time repeats calls (start the loop at 0 and keep the existing first call as the warm-up
by adding one untimed gemm_q8_raw before d0, or simply ms_per_call(d0, d1, repeats - 1)), and reject
repeats < 2 with exit 2 so the repeats=1 line above cannot be printed by anything.

Nits, none of them gates

  • docs/onnx.md: the last table row has four cells in a five-column table
    (| 3072×1024 (down) | 1 / 32 | 2.153 / 2.552 | 0.248 / 8.071 |), while the rows above it carry the empty
    fifth cell.
  • "1.44–1.50 ms for q_proj" is the range for rows 1/4/16/32; rows 2 and 8 are 1.9, and that is not the
    high-load run (I reproduce 1.912 and 1.897 at load 3.5). The dispatch-bound argument does not need the range to
    be that tight — "1.4–1.9 ms, flat in rows" says the same thing and survives a re-run.
  • the host column is the accumulation loop only; the EP's real fallback then runs epilogue_row (float multiply +
    q8_quantize per element). So host is a lower bound and the ~8–16-row crossover is optimistic for the device.
    Worth one clause, since the doc's next paragraph tells a reader not to quote a device speedup.
  • repeats is also the sample count for the timer: one 20-iteration run per cell, no min/median. The 2-row and
    8-row wobble above is the visible cost of that; a min of three runs would make the table re-derivable by anyone.

bong-water-water-bong added 3 commits November 2, 2026 19:47
onebit_npu_gemm_q8_probe runs C[m,n] = A[m,k] @ B[k,n] with int8 operands through gemm_q8_raw on the NPU
and through the EP's own host loop, requires the exact int32 accumulators to be identical (an exact
integer sum cannot differ, so a mismatch is a layout or a truncated K, not rounding), and prints ms/call
for both. It is a ctest entry that skips when the shape has no design, because it measures the kernel
rather than gating the graph (the QDQ proof does that).
…the host loop at decode widths

Measured with the new probe on strixhalo (-O2, M=32 designs, npu-hold ticket): a call costs 1.44-1.50 ms
for q_proj at 1 row and at 32, and an M=128 design at one row (1.606 ms) is no slower than M=32 (1.441),
so the launch dominates. At one row that is ~9x the EP's own host loop for the same projection; it crosses
over between 8 and 16 rows and is 3.2-3.9x ahead at a full 32-row design. Stated so nobody reads the
196-of-197 coverage in docs/onnx-pack.md as a decode speedup.
The device column timed `repeats-1` calls (the first call is the untimed warm-up) and divided by
`repeats`, so every figure was (repeats-1)/repeats of the truth: 5.3 % low at the timing script's
repeats=20, 20 % low at the ctest entry's 5, and repeats=1 printed `device 0.000 ms/call` with a
four-digit speedup and still exited 0. Both legs now time exactly `repeats` calls after one untimed
device call, and repeats < 2 is refused with exit 2.

Re-measured through the fixed probe (npu-hold ticket 01793663361223459193.qdq, 10 s, load 9-10, min of
three runs per cell, 18/18 configurations matching the exact int32 accumulators): q_proj is 1.501 ms at
1 row and 1.566 ms at 32 rows -- 32x the work for 4 % more time -- crossing over between 8 and 16 rows and
3.1-3.4x ahead at a full 32-row design, so the dispatch-bound conclusion is unchanged and its numbers are
now the measured ones. The repeats sweep is flat (rows=1: 1.643 / 1.705 / 1.542 / 1.515 ms at repeats
2 / 5 / 20 / 21, previously 0.793 / 1.254 / 1.454 / 1.579 -- it was measuring the divisor).

docs/onnx.md: the corrected table, the host column stated as a lower bound (accumulation loop only, the
EP's real fallback then runs epilogue_row), the M=128-vs-M=32 comparison stated as within run-to-run
variance (1.233 vs 1.499 here, 1.606 vs 1.441 earlier) instead of a too-tight range, and a note that the
earlier table was ~5 % low. The probe's header example design is now an M=32 artifact: the _m16 ELF it
named cannot be emitted (n1_core_i8_v26.py asserts M % m == 0, m=32).
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

CHANGES addressed at 71d94dc (rebased onto current main 801a4a6, so the diff is still the same three files). The count bug was real and the fix is proved by the measurement it broke, not by reading it.

The fix

    if (k <= 0 || n <= 0 || m <= 0 || repeats < 2) return 2;   // was: repeats <= 0
    ...
    // Untimed: builds the kernel and takes the device lock, so it must not be inside d0.
    if (!gemm_q8_raw(...)) { ... return 3; }
    const auto d0 = steady_clock::now();
    for (int r = 0; r < repeats; r++) { if (!gemm_q8_raw(...)) ... }   // was: r = 1
    const auto d1 = steady_clock::now();
    const double dev_ms = ms_per_call(d0, d1, repeats);

Both legs now time exactly repeats calls after one untimed device call, so the two columns are the same quantity. repeats=1 is refused (verified: onebit_npu_gemm_q8_probe 1024 1024 16 1 → exit 2; … 16 0 → exit 2), which removes the device 0.000 ms/call speedup 1538.23x line you reproduced.

The fix's own evidence: the repeats sweep is now flat

Before (your numbers, q_proj 1024×2048, 1 row) the per-call figure climbed with repeats because it was measuring the divisor. After, same shape, same ticket:

before: repeats 2 / 5 / 20 / 21 -> 0.793 / 1.254 / 1.454 / 1.579 ms/call
after : repeats 2 / 5 / 20 / 21 -> 1.643 / 1.705 / 1.542 / 1.515 ms/call   (rows=1)
                                  2.014 / 1.811 / 1.589 / 1.590 ms/call   (rows=32)

No trend with repeats at 20+; the residual spread is cold-start noise at small repeats, in the honest direction.

Re-measured table (npu-hold ticket 01793663361223459193.qdq, 0 s wait, 10 s, load 9.2–10.5, min of three runs per cell, repeats=20, M=32 designs, -O2)

shape rows device ms/call host ms/call device vs host
1024×2048 (q) 1 1.501 0.158 9.5× slower
2 1.550 0.317 4.9× slower
4 1.526 0.669 2.3× slower
8 1.515 1.319 1.1× slower
16 1.529 2.550 1.7× faster
32 1.566 5.062 3.2× faster
1024×1024 (k, v) 1 / 32 0.781 / 0.824 0.078 / 2.529 10× slower / 3.1× faster
1024×3072 (gate, up) 1 / 32 2.440 / 2.425 0.235 / 7.765 10.4× slower / 3.2× faster
2048×1024 (o) 1 / 32 1.499 / 1.493 0.180 / 5.017 8.3× slower / 3.4× faster
3072×1024 (down) 1 / 32 2.209 / 2.311 0.250 / 7.602 8.8× slower / 3.3× faster

All 18 configurations still ran on the array and matched the exact int32 accumulators (RESULT: every configuration ran on the array and matched the exact host accumulators, exit 0), device-busy=0, no amdxdma error in journalctl -k around the ticket.

The conclusion survives the correction and gets stronger: q_proj is 1.501 ms at 1 row and 1.566 ms at 32 rows — 32× the work for 4 % more time — the crossover is still between 8 and 16 rows (1.1× slower → 1.7× faster) and 3.1–3.4× ahead at a full design row. Every device figure in the doc is now ~5 % higher than the version you reviewed, which is exactly the correction.

The nits, all taken

  • Five-column row: the table was rebuilt; every row carries its fifth cell.
  • "1.44–1.50 ms for q_proj": you were right, rows 2/8 were 1.9 and that was not the high-load run. The sweep is now quoted per row and the flatness claim is "1.501 ms against 1.566 ms, 32× the work for 4 % more time", which survives a re-run.
  • Host column is a lower bound: stated in the doc — it is the accumulation loop only, the EP's real fallback then runs epilogue_row (float multiply + q8_quantize per element), so the 8–16-row crossover is optimistic for the device.
  • Min of three runs: done — the table is the min of three probe runs per cell, and the doc says so, so it is re-derivable with the binary in this PR.
  • M=128-vs-M=32: this run has M=128 (1.233 ms) faster than M=32 (1.499 ms) on 2048×1024 at one row, the reverse of the earlier run (1.606 vs 1.441). Rather than pick the flattering one, the doc now quotes both and says they are within run-to-run variance at decode width — which is the actual claim: design M is not the lever.

One more stale thing found in the same file (not in your review)

The header's example was ONEBIT_EP_NPU_ELFS=16x1024x2048=/path/full_i8_Q_K1024_N2048_m16.elf. That design cannot exist: n1_core_i8_v26.py asserts M % m == 0 with the core tile m=32, so M=32 is the smallest this family emits (that is how the five designs in ~/qdq-elfs-m32 were built). The example now points at an M=32 artifact and says why.

Gates on 71d94dc

Host build with no CMAKE_BUILD_TYPE (/tmp/q853-host, -DONEBIT_ORT=ON): ctest 6/6, 14.10 s. -DONEBIT_EP_NPU=ON Release (/tmp/q853-npu-rel): builds, 0 warnings from the probe file. tools/copyright.py --check rc 0. Ticket evidence above.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 71d94dc

…re ~1.8x high

Re-sweeping the rows table with the fixed probe (#862's threshold evidence) exposed a measurement trap:
in a ticket whose first measurement is a small-row cell, device ms/call comes out a uniform ~1.84x
inflated across all five shapes and settles by the sixth configuration -- 1024x1024 1.57 -> 0.81 ms,
1024x2048 2.87 -> 1.56, 1024x3072 4.24 -> 2.31, 2048x1024 2.74 -> 1.49, 3072x1024 4.13 -> 2.26, same
binary, same designs, one process per cell with its own untimed warm-up call. A per-process warm-up is
therefore not enough to make the first cells quotable; the ticket is warm only after several
configurations.

One sentence in the table's preamble, no number changed: the table above it was already taken after nine
warm-up configurations of the same shape, which is why its 1-row figure is 1.501 ms and not ~2.9.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

One addition to 71d94dc, from re-sweeping #862's rows table with this fixed probe — it is a measurement trap this PR should warn about, because it is exactly the kind of thing that makes the table look unreproducible to a reader who re-runs it.

A cold ticket's first cells read ~1.8× high. In a ticket whose first measurement is a small-row cell, device ms/call came out a uniform ~1.84× inflated across all five projection shapes and settled by the sixth configuration — same binary, same designs, one probe process per cell, each with its own untimed warm-up call:

1024x1024  1.57 -> 0.81 ms     1024x2048  2.87 -> 1.56     1024x3072  4.24 -> 2.31
2048x1024  2.74 -> 1.49        3072x1024  4.13 -> 2.26

So the per-process warm-up call is necessary but not sufficient: the ticket is warm only after several configurations. That is a device/CPU ramp, not a row-count effect, and it is why a cold run of this probe reports 2.87 ms for q_proj at one row where this PR's table says 1.501 ms.

6a17eca adds one sentence to the table's preamble saying exactly that, and no number changes: the table was already taken after nine warm-up configurations of the same shape, which is why its 1-row figure is the steady-state one. The alternative — making the probe warm up until the per-call time is stable rather than once — is a better instrument and is written down rather than slipped in mid-review; if you would rather have that instead of the caveat, say so and I will cut it into its own commit with its own re-measurement.

The sweep itself also re-derived this lane's kDeviceMinRows = 16 with the fixed probe (#862, comment there): crossover still between 8 and 12 rows, 16 still the first row count with nothing slower, margin 1.59–1.75× instead of the 1.47× the buggy sweep reported.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 6a17eca

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at 6a17ecacc — the one blocker from my earlier CHANGES is fixed, and fixed in both halves.

The blocker was the divisor, and it is now right in both legs:

:102  for (int r = 0; r < repeats; r++) …    device   (was r = 1, divided by `repeats` -> (repeats-1)/repeats)
:112  for (int r = 0; r < repeats; r++) …    host

so device 0.000 ms/call speedup 1538.23x at repeats=1 can no longer be printed, and every device cell in the body's
table is now repeats calls over repeats. The body also stops quoting the two -O0 runs and says why (their host
column was 8.15 ms against 0.161 ms at -O2, so their 82-96x were a build artifact) — that is the same
number-honesty I asked for, applied to the author's own earlier table.

Built and run at this head (GCC, thermal-run -j4):

  • the probe itself compiles in the configuration where it is load-bearing, -DONEBIT_EP_NPU=ON with
    -DONEBIT_NPU_RT_DIR=… and ONEBIT_NPU_ENGINE_INCS — onnx/ep/onebit_npu_gemm_q8_probe links (11/11);
  • the host build's ctest -R "ort_info|onebit_ep" is 6/6, i.e. the new ctest entry (which SKIPs on exit 3
    without a configured design) does not perturb the existing gates.

The measurement's content is unchanged and still says the right thing: the call is dispatch-bound (q_proj
1.44-1.50 ms at 1 row and at 32), an M=128 design at one row is not measurably slower than M=32, so a smaller
design does not help decode, and the array is a prefill leg that crosses over between 8 and 16 rows. That is exactly
what #862 then acts on, and it is why the two go in this order: #853 first, #862 on top (it is one commit on this
head).

Nit, not a gate: the cross-over row is stated as a range ("between 8 and 16 rows") in the body and as a point
("~8-16 rows") in docs/onnx.md; #862's 45-configuration sweep is the one that pins it (12 rows is faster in all
five shapes), so a cross-reference there would keep the two pages from drifting.

Device discipline: no npu-hold ticket, no device opened, :18097 untouched — the probe's device leg SKIPs without
ONEBIT_EP_NPU_ELF*, so what ran here is a compile and the host ctests.

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 8864ed5

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 8864ed527, superseding my CHANGES at 6a17ecacc. The blocker is fixed exactly as asked, in the probe's timing:

- for (int r = 1; r < repeats; r++)      // timed repeats-1 calls
+ for (int r = 0; r < repeats; r++)      // exactly `repeats` timed calls, after one untimed warm-up
...
- if (k <= 0 || n <= 0 || m <= 0 || repeats <= 0) return 2;
+ if (k <= 0 || n <= 0 || m <= 0 || repeats < 2) return 2;

so repeats=1 can no longer print device 0.000 ms/call with a four-digit speedup and exit 0, and the warm-up is stated
as being outside the timer (with the reason: it builds the kernel and takes the device lock). The commits I had not seen
before this head read correctly too: c6e38c484 adds the probe (+134, exact int32 accumulators required identical, prints
ms/call on both legs, skips rather than fails when the shape has no design), c5137398d and part of 71d94dc10 carry the
measured table and the honest framing (dispatch-bound; ~9x the host loop at one row; crossing over between 8 and 16 rows;
3.2-3.9x ahead at a full 32-row design), plus the note that the earlier table was ~5 % low. The header's 32x1024x2048
example is right (n1_core_i8_v26.py asserts M % m == 0, m=32, so no _m16 design exists) — that was my earlier nit
and it is closed.

One thing that is not this PR's fault but does bear on it: the device numbers cannot be rebuilt on current main,
because -DONEBIT_EP_NPU=ON no longer compiles — npu_engine_i8ctx_inc.h:219 calls q4nx_elf_arg_sizes() with no
declaration in its include chain since #869 (7e64bbd). Filed as #874 with the one-line fix. The new
onebit_npu_gemm_q8_probe ctest entry lives in onnx/ep and links _npu_src, so it inherits that break; CI stays green
only because ci.yml never sets ONEBIT_EP_NPU. Landing this PR is fine, but #874 should go with or before it or the
gate it adds is unbuildable in the configuration it is for.

CI at 8864ed527: build success.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 85d2e32

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 85d2e32da (branch brought up to date after the last merges), superseding my line at 8864ed527. The update is a
merge of main; the PR's own commits are unchanged, and everything in the review below it stands.

The one blocker I raised (the device column timing repeats-1 calls and dividing by repeats) is fixed in code:
for (int r = 0; r < repeats; r++) on both legs after one untimed warm-up, and repeats < 2 refused with exit 2 — so
repeats=1 can no longer print device 0.000 ms/call with a four-digit speedup and exit 0. The measured table behind it
(dispatch-bound; ~9x the host loop at 1 row; crossing over between 8 and 16 rows; 3.2-3.9x ahead at a full 32-row design)
is labelled as measured through the fixed probe, with a note that the earlier table was ~5 % low, and the header's
32x1024x2048 example is the right artifact (M % m == 0, m=32 — no _m16 design exists, which was my earlier nit).

Caveat that is not this PR's defect but does apply to the test it adds: -DONEBIT_EP_NPU=ON does not compile on current
main since #869 (npu_engine_i8ctx_inc.h:219 calls q4nx_elf_arg_sizes() without its declaration) — filed as #874
with the one-line fix. The new onebit_npu_gemm_q8_probe ctest entry links _npu_src, so it inherits that break until
#874 lands; CI stays green only because ci.yml never sets ONEBIT_EP_NPU.

CI at 85d2e32da: build success (checked at 02:07Z).

@bong-water-water-bong
bong-water-water-bong merged commit bc291cd into main Nov 3, 2026
8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/onnx-ep-qdq-q8-probe branch November 3, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 4/5 tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant