Skip to content

npu: make the quantiser header's speed figure one that a re-run reproduces (follow-up to #908) - #919

Merged
bong-water-water-bong merged 6 commits into
mainfrom
1bit/q8-comment-numbers
Nov 4, 2026
Merged

bong-water-water-bong merged 6 commits into
mainfrom
1bit/q8-comment-numbers

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Follow-up to the one thing #908's review asked for, on a PR that had already merged.

Root cause. The header comment in npu/forward/include/quant_i8.h quoted a single measurement
(3.96-4.05 ms/token scalar, 1.72-1.76 ns/element, 7.2-7.4x). The review measured the same mix on the same
box and got 6.56x (1.539 ns/element scalar -> 3.56 ms/token; 0.235 AVX2 -> 0.54 ms/token). The AVX2
side matches to 1 %; the scalar figure was ~12 % optimistic, so the next person to re-measure finds a
"regression" that is only a stale number.

Fix. Comment-only: the figure is now the range both runs measured, labelled as two independent measurements
on this box and mix.

before: 3.96-4.05 ms/token scalar (1.72-1.76 ns/element) vs 0.55 ms/token AVX2 (0.238), 7.2-7.4x
after:  3.56-4.05 ms/token scalar (1.54-1.76 ns/element) vs 0.54-0.55 ms/token AVX2 (0.235-0.238), 6.6-7.4x

The made 7x cheaper line at the top of the file becomes made 6-7x cheaper, so the summary does not contradict
the detail.

No behaviour change, so no gate and no device run: nothing outside comments changed
(git diff --stat = 1 file, +6/-5, every line a //).

…duces

#908's reviewer measured the same mix on this box and got 6.56x (1.539 ns/element
scalar, 0.235 AVX2) where the comment claimed 7.2-7.4x (1.72-1.76, 0.238). The
AVX2 side agrees; the scalar figure was ~12 % optimistic, so a later re-run would
look like a regression. The comment now carries the range both runs measured,
labelled as two independent measurements on the same box and mix.

Comment-only change: no code, no behaviour, no re-gate.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

@pi-prs #919 ready for review at f389e8a

@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 f389e8a7e — comment-only, and it now says what two independent runs measure. Mine is one of the two: in my #908 review I re-measured the shipping mix myself and got scalar 1.539 ns/element (3.56 ms/token) against AVX2 0.235 ns/element (0.54 ms/token), 6.56x, against the body's then-6.5x-to-7.4x spread. The new text (3.56-4.05 ms/token scalar (1.54-1.76 ns/element), 0.54-0.55 ms/token (0.235-0.238 ns/element), 6.6-7.4x) brackets both numbers exactly, so a re-run now lands inside the quoted range instead of contradicting it.

No code touched: the diff is five // lines in npu/forward/include/quant_i8.h. The 288-projection / 2,310,144-element/token arithmetic and the bit-identity argument are unchanged from the head I verified with 82,241 differential comparisons, and the quant_i8_row ctest still covers the identity independently of the comment.

@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
@bong-water-water-bong
bong-water-water-bong requested a balanced review from Copilot November 3, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated savings range still excludes the second measurement’s 3.02 ms/token improvement and should be corrected to approximately 3.0–3.5 ms/token.

1 open issue
What changed in this PR

This comment-only follow-up to #908 updates the NPU activation quantiser’s performance figures to reflect both independent measurements. Runtime behavior is unchanged.

Changes:

  • Broadens the documented scalar and AVX2 timing ranges and speedup range.
  • Records the measurement date and adjusts the headline to “6–7x cheaper.”
File Description
npu/​forward/​include/​quant_i8.h Updates benchmark figures and measurement context in the header comments.

Review effort: Balanced

Comment thread npu/forward/include/quant_i8.h Resolved
…points

Copilot's review of #919: the comment said 6.6-7.4x is 'about 3.4-3.5 ms' saved, but
the slower scalar run (3.56) minus the faster AVX2 run (0.54) is 3.02 ms, so the
range excluded the second measurement. Now stated as the subtraction it is:
3.0-3.5 ms/token (3.56-0.54 to 4.05-0.55), i.e. 0.73-0.85 % of a ~415 ms token.

Comment-only; no code, no behaviour, no re-gate.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

@pi-prs #919 ready for review at 4085d71 — Copilot's inline thread (the saving range excluded the second measurement) fixed in the commit rather than argued away, thread answered and resolved.

@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 4085d71f5 (re-verdict; my tprs-ready label was at f389e8a7e).

Delta is comment-only, 2 lines in npu/forward/include/quant_i8.h, and the arithmetic is now right: the two runs give 3.56 - 0.54 = 3.02 and 4.05 - 0.55 = 3.50, so "a saving of 3.0-3.5 ms in a ~415 ms decode token" is what the quoted ranges actually support. The previous wording ("about 3.4-3.5 ms") took the top of the range as if it were the range.

The rest of the comment — the 6.6-7.4x ratio, the 0.235-0.238 ns/element AVX2 figure, best-of-7 twice — is unchanged from the head I reviewed, where I traced it to the run logs behind #908.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit f6ce374)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

908 - Partially compliant

Compliant requirements:

  • Update the performance measurements in the header comment to reflect the actual measured performance
  • Ensure the measurements are accurate and reproducible
  • Maintain byte-identical output
  • No behavior change, only comment updates

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Outdated Performance Measurement

The header comment previously contained outdated performance measurements that were ~12% optimistic compared to actual measurements. This has been updated to reflect the correct range of measurements (3.56-4.05 ms/token scalar vs 0.54-0.55 ms/token AVX2) which aligns with the actual performance observed on the hardware.

// made 6-7x cheaper.
//
// Why it is worth a file: it runs once per projection -- 288 projections, 2,310,144 A elements per decode
// token on Bonsai-2 (the shipped container's own plan.json: 48 gdn layers x K = 5120, 5120, 6144, 5120,
// 17408 and 16 attention layers x 5120, 5120, 17408) -- and the engine builds at the baseline x86-64 GCC
// targets, where roundf() is a libm call.  Measured on strixhalo replaying exactly that mix, best of 7, twice
// independently (2026-11-03):
// 3.56-4.05 ms/token scalar (1.54-1.76 ns/element) against 0.54-0.55 ms/token on the AVX2 path
// (0.235-0.238 ns/element), 6.6-7.4x -- a saving of 3.0-3.5 ms in a ~415 ms decode token (scalar minus AVX2
// across the two runs: 3.56-0.54 to 4.05-0.55).  Same story as hadamard.h next

@bong-water-water-bong
bong-water-water-bong merged commit d468714 into main Nov 4, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/q8-comment-numbers branch November 4, 2026 07:10
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit f6ce374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 1/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.

2 participants