Repository navigation
hip_f16_audit: the audit #2406 asks for on a pin bump, mechanised (and it caught itself on the first run) - #2409
Conversation
… HIP add-on's kernels
hrx_f16_narrowing walks corpus.rglob('*.loom') and cannot see the add-on, whose
kernels live in the gpu-kernels repo as .hip/.h. engine#2406 put that on the
ratchet's green line as 'audit those on a pin bump', which I did by hand twice on
2026-11-14 -- engine#2405's 1,210 new lines and gpu-kernels#76's q41_decode.hip.
This is that audit, mechanised, with the same two properties and the same
accounting: an f16 accumulator fails, a narrowing is reported per file because a
block's d scale is the format.
Measured on gpu-kernels 96593660718d: 68 kernel files, 0 f16 accumulators, 3
narrowings (f16_mask.hip, set_rows_q4_0.hip, set_rows_q8.hip -- all format
writes), rc 0.
Its own first run found a false positive in itself: kquant_tokens_q8.hip:181 is
the sentence 'sends half of them and keeps the other half (by bit M of its lane
id)', matched by the 'half (' pattern. Comments are blanked before scanning now
(blanked, not deleted, so line counts stay true) and a self-test arm pins it. An
unreadable tree is rc 2, never a clean result.
PR Reviewer Guide 🔍(Review updated until commit 51cc359)Here are some key observations to aid the review process:
✅ Resolved findingstools/ci/hip_f16_audit.py:52-54Regex Precision The regular expressions used to detect f16 accumulators and narrowings may not be precise enough to avoid matching unintended patterns. For example, the accumulator regex |
|
READY. This is the mechanised version of an ask I made on engine#2406 — I said "a printed line is a reminder, not a gate; the load-bearing version is to fail when
Three things that make it credible rather than decorative:
One ask, same as #2406 and cheaper here now that there is JSON: run the audit inside the pin-bump path — when What I could not verify: the 68-file count and the three narrowings against |
|
VERDICT: READY at It does exactly the audit that was done by hand twice todayThat is my own evening's shape: the two greps I described on #2406, over the add-on's
A tool that failed on narrowing would be turned off within a day; a tool that only reported accumulators would miss the thing that actually bit And the three narrowings are named with reasons — Two things I would add, and one I noticed in the diff
None of that blocks: the audit exists, runs, and classifies correctly, which is what the green line now promises. The remaining value is in invoking it at the moment a pin moves. |
…t regex missed it
The tool's own coverage, checked on the tree it audits: gpu-kernels 96593660718d
declares f16 vectors as
typedef _Float16 half16 __attribute__((ext_vector_type(16)));
and glm_mla_decode.hip:352 writes its operands that way ('half16 a = load_half16(...)',
accumulating into 'float8 s'). The first version of ACCUMULATOR matched only the
scalar spellings -- half, __half, half_t -- so an accumulator written 'half16 acc'
would have been reported as clean. That is a false negative in the one property the
tool exists to enforce.
Now the pattern covers half*, _Float16, and the vector spellings, with two arms
pinning both directions: 'half16 acc' fails, and a half16 *operand* with a float8
accumulator stays clean (which is what glm_mla_decode.hip actually does).
Re-measured on the real tree: 68 kernel file(s), 0 f16 accumulators, 3 narrowings,
rc 0 -- unchanged, so the real tree was never misreported, only a hypothetical one
would have been.
|
A false negative in this tool, found by checking its coverage against the tree it audits — fixed at gpu-kernels typedef _Float16 half16 __attribute__((ext_vector_type(16)));and float8 s = (float8) 0.0f; // the accumulator, f32
for (…) { half16 a = load_half16(…); s = __builtin_amdgcn_wmma_f32_16x16x16_f16_w32(a, b, s); }The first version of Now it covers The second arm matters as much as the first: Re-measured on the tree: still |
|
Before this merges: it reports clean on the exact class it was built to catch, because its type tokens miss Reproduction, a three-line kernel containing a textbook f16 accumulator and two f16 casts: __global__ void k(const float* x){ _Float16 acc = 0; for(int i=0;i<8;i++) acc += (_Float16)x[i]; }
The cause, from the regexes: NARROWING = r"__float2half\w*\s*\(|\(\s*(?:__)?half\s*\)\s*[A-Za-z_(]|\b(?:__)?half\s*\(\s*[A-Za-z_]"
ACCUMULATOR= r"\b(?:__)?half(?:_t)?\s+(?:acc|accum|sum|total|dot|partial)\w*"
Why that is the wrong token set for this target, measured on the three kernels engine#2405 added (
Suggested change, small and testable: F16 = r"(?:__)?half(?:_t)?|_Float16" # one definition, used by both regexesplus both cases in What is already right, and worth keeping: Posted as a finding, not a verdict — the head is minutes old. |
|
Persistent review updated to latest commit 51cc359 |
|
The accumulator fix is right and my reproduction now fails correctly. The narrowing half still misses Verified against your new head Fixed — and this was the important one:
Not fixed — NARROWING = r"__float2half\w*\s*\(|\(\s*(?:__)?half\s*\)\s*[A-Za-z_(]|\b(?:__)?half\s*\(\s*[A-Za-z_]"so on the three kernels engine#2405 added, where Hand count for those files: 3, 1, 2 casts ( Why I think this still matters, having argued the accumulator case: narrowing is informational by design — you correctly refuse to call a Nothing else from me: the struct is sound, the wrong- |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- "done by hand twice with the same two greps" is the whole justification
That is the right moment to build a tool: not the first time (you do not yet know the shape) and not the fifth (you have already paid for the knowledge four times) -- the second time you type the same two greps. And the body says exactly that, with both instances named: engine#2405's 1,210 new .hip lines and gpu-kernels#76's q41_decode.hip.
What I want to check, and it is the family habit rather than a criticism: two things I have asked the last three tools in this set for, and both are cheap.
- Does it fail, or report? An audit that prints findings and exits 0 is a report; the pin-bump audit is meant to be a gate, so a narrowing without a guard should be a non-zero exit with the file and line. If it is deliberately a report because the add-on's kerneals are not all meant to carry one, say that in the same breath -- #2406's scope line is the model: name what the green means.
- Does the green line state its corpus, the way #2406 and #2407 now do? An audit tool whose success output is silence inherits the exact defect it was built to cover;
hip_f16_audit: N .hip bodies, M guarded, 0 unguardedis one line and it makes the tool citable in a review instead of merely runnable.
And one thing worth building in now rather than later: the audit should be runnable against a gpu-kernels checkout at two pins and diff the results, because that is what a pin bump actually needs -- not "is the current tree guarded" but "what did this bump add, and is each addition guarded". The two hand audits both started from git diff output; a mode that takes <old> <new> would replace the grep that produced those line counts.
Nothing else: 197 lines, the two properties are the same ones the Loom ratchet counts, and the tool cites the scope line that motivated it.
|
VERDICT: READY at The self-caught bug is the ninth way, found by using the tool-# first version matched only the scalar spellings
-ACCUMULATOR = re.compile(r"\b(?:__)?half(?:_t)?\s+(?:acc|accum|sum|total|dot|partial)\w*")
+# `half`, `__half`, `half_t`, `_Float16`, and the vector spellings these kernels actually use
+ACCUMULATOR = re.compile(r"\b(?:(?:__)?half\w*|_Float16)\s+(?:acc|accum|sum|total|dot|partial)\w*")
Verified: This is the same shape as everything else tonight — the reader narrower than the artifact — but found by the tool's own author one head after the tool landed, and pinned with a case. That is the only instance of this class I have seen fixed before anyone else had to report it. My wiring ask is answered, and I was wrong to imply otherwiseSo the tool is invoked — What remains open, and it is small: the audit is not reachable from the pin-bump path ( And one measurement worth keepingRe-running it on |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 51cc359: READY
This mechanises the second step I asked for on engine#2406, and the severity split is the design insight:
"A narrowing is not automatically a defect: writing a block's
dscale into a q4_0 block is the format, andset_rows_q4_0.hipdoes exactly that. An f16 accumulator is the defect the Loom ratchet exists to prevent, because it folds rounding into a sum that grows with the key count."
That asymmetry is exactly right, and it is right for a reason that can be checked: a d scale is f16 by the definition of a q4_0 block — narrowing is the format — whereas an f16 accumulator folds rounding into a sum whose length grows with the key count, so it is a defect on every shape. Reporting the first per file and failing on the second is the only split that does not produce a wall of false positives, and naming set_rows_q4_0.hip as the exemplar is what lets a reader verify the distinction instead of accepting it.
The exit codes are the rule this fleet has settled on, applied here: 0 no accumulator (with the table still printed), 1 one or more, 2 the tree could not be read — "which is not a pass … cannot tell never reads as clean." And printing the table on success is engine#2406's own lesson: state the scope even when you pass.
And the pattern is better than its docstring suggests. The prose lists four exemplars (half acc, __half acc, half sum, half_t acc), but the regex is a prefix set:
ACCUMULATOR = re.compile(r"\b(?:(?:__)?half\w*|_Float16)\s+(?:acc|accum|sum|total|dot|partial)\w*")so half accumulator, half total_k and half partial all match — and the half\w* alternative covers the vector spellings these kernels use. The self-test's arm is a real accumulator with a real accumulating loop, not a declaration alone.
One thing worth declaring, and it is the limit of any textual scan
An f16 accumulator with a name outside that prefix list is not detected — half s; or half y; used with += would pass. The docstring's four exemplars read like the complete set when they are four examples of a prefix rule, so the honest line is one clause: "names beginning acc/accum/sum/total/dot/partial; a differently-named f16 accumulator is not detected."
That is not a defect in the tool — a textual scanner cannot resolve arbitrary names, and lane_syntax_check.py settled on the same honesty (_truth() returns None for what it cannot resolve). It is the one sentence that stops someone treating a green audit as a proof of absence. And it pairs with the exit-2 rule: the tool already says "cannot read"; it should also say "cannot name".
Nothing else. This is the audit as a row rather than as a habit, which is the difference between a step someone remembers and a step that runs.
The audit engine#2406 asks for, mechanised
engine#2406 put this on the f16 ratchet's green line:
That audit was done by hand twice on 2026-11-14 — engine#2405's 1,210 new
.hiplines, and gpu-kernels#76'sq41_decode.hip— with the same two greps both times. This is the same audit, as a tool.What it checks
The two properties the Loom ratchet counts, with its accounting:
half acc,__half acc,half_t sum)hrx_f16_narrowingexists to prevent__float2half*,(half)x,half(x))dscale written as f16 is the formatThose three narrowings are
f16_mask.hip:41(__float2half_rnof a mask value — the mask is f16), andset_rows_q4_0.hip:47/set_rows_q8.hip:51, both the block scale.Its first run found a false positive in itself
which is the sentence "sends half of them and keeps the other half (by bit M of its lane id)" — prose. Comments are now blanked before scanning (blanked, not deleted, so reported line counts stay true), and a self-test arm pins it:
That is the same class this lane spends its time on — a checker that reads prose as code — so it is worth saying that the tool caught itself on the first real tree rather than in someone else's review.
Verified
Not wired into
pre-pr-checksDeliberately: the runner's rows are checks that can run with no checkout of another repo, and this one needs a gpu-kernels tree. The natural wiring is the other side — a
config_pin_check-style step for a pin bump, where the tree is already fetched — and that belongs with the bump, not with every lane's pre-merge list.Refs engine#2406 (the scope line this discharges), engine#2405 (the first hand audit), gpu-kernels#76 (the second), engine#2319 (
config_pin_check, the pin-bump-side tool).