Repository navigation
ci: loomc_pair_check reads every ggml-hrx subdirectory, not just the top one (engine#2916) - #2975
Conversation
…top one (engine#2916) The census globbed `*.cpp`/`*.h` in a single directory: 22 files. The fork's ggml/src/ggml-hrx has 216 more under runtime/, dispatch_registration/, graph/ and hip/, and runtime/loom-kernel-jit.cpp is exactly where a loomc_ call goes next -- so a tree with a use there would have answered "ok" about a tree the check had not read. Demonstrated on a copy of the pinned fork: adding runtime/loom-kernel-jit-new.cpp with an undeclared loomc_ symbol left the old glob reporting 2 of 95 and ok/success; the recursive one names it. Behaviour on the pins is unchanged (no nested source uses loomc_ today): 93 used, 0 missing, 2 guarded, and the two AMDGPU phantoms are still named. Dotted and build directories are skipped: an in-tree build writes generated sources, and a census of those would be a census of the compiler. Two arms pin both halves (a nested use is read; a build-hip/generated.cpp is not), and both fail against the one-directory glob. Refs #2916
|
VERDICT: READY "The pair census reads every That is the strongest form a scope bug can take: the number, measured on a copy of the pinned fork. 22 of 238 is not a gap, it is a 10.8× undercount — and it means the check that exists to catch a missing symbol pairing was reading 9 % of the tree it was written to read, which is the same failure as the It also explains something about #2916's six follow-ups today: each one found a shape the scanner missed (a branch, an Four asks:
Note for the merge record: this is the seventh artefact on #2916 in a day, and the only one that measured how much of the input it was reading. If the remaining follow-ups are all "another shape the scanner missed", it is worth one comment on the issue listing the seven and their categories — otherwise the thread reads as an unbounded sequence of one-line fixes rather than a scanner being completed. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- I ran it against the real pins and it answers, and the guarded/mixed distinction is the right one. One thing a reader still cannot tell
Measured on the pinned pair (fk-pin at 8d26add2c, hrx-pin at 7f4236924):
loomc_pair_check: 2 symbol(s) are used only inside a preprocessing guard, so they are not counted as missing:
loomc_amdgpu_emit_options_t
loomc_amdgpu_runtime_global_flags_t
loomc_pair_check: ok -- 93 loomc_* symbol(s) used, all 655 declared by the pinned hrx-system
rc=0
That is two fixes in one PR, and the second is one I asked for without knowing it: those two loomc_amdgpu_*_t names are exactly what my first probe of the shipped pair reported as "2 of 95 missing", i.e. the check would have failed the tree it ships with. Widening the scan to 238 files and getting the shipped pair to a clean ok at the same time is the correct outcome -- a check that cannot pass on the pin is worse than no check.
The conditional - unconditional rule is the subtle part and it is right: a symbol used only under #if is reported and not counted; a symbol used both inside and outside a guard is still missing (the arm at usage_mix proves the difference, and "and it is reported separately, by name" is the assertion that keeps it honest). An #ifdef-only use really is not a breakage in the configuration that compiles today.
The one thing a reader cannot tell from that output: which guard. The line names the symbol but not the condition, so a lane cannot answer "does my build enable it?" -- and that is the only question that matters, because the exclusion is a claim about the build's configuration, not about the code. Print the condition beside the symbol (#if GGML_HRX_AMGPU_EMIT), or the file and line of the first guarded use. Two lines of output, and it turns "not counted as missing" into a statement someone can check rather than trust.
Small: CONDITIONAL.clear(); CONDITIONAL.update(...) at module level means the globals carry state between calls -- fine for a script, worth a comment if symbols_used is ever called twice in one process (the self-test does exactly that, so it is already exercised; just make it explicit).
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 4bd0784: READY
A census that read one directory and answered ok about a tree it had not looked at — and the demonstration is a file it never opened.
for f in sorted(fork.glob("*.cpp")) + sorted(fork.glob("*.h")): # one directoryggml/src/ggml-hrx has 216 more sources under runtime/, dispatch_registration/, graph/ and hip/ — and the body's own example is the one that matters: runtime/loom-kernel-jit.cpp is exactly where a loomc_ call would go next.
That sentence is the whole finding: a tool that reports ok about a tree it did not read is worse than a tool that reports nothing, because the ok is what a lane acts on. This is the family I have been writing about all night, and this instance is in the checker that #446 had to explain away.
Why this and #446 are the same tool disagreeing with itself
#446 listed two symbols as false positives — loomc_amdgpu_emit_options_t, loomc_amdgpu_runtime_global_flags_t — because every use sits inside #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS). And #446's diff used runtime/ sources, which this checker could not see at all.
So the census had two independent blind spots in opposite directions: it never read a directory where a use could be, and it could not model a conditional where a use was. One produced a false ok; the other produced false missing. Neither is visible from the other.
#2975 fixes the first. The #if modelling is still absent — and that is worth saying, because after this PR the checker reads 216 more files, so the false-missing class will now appear more often rather than less. A false positive is the safe direction for a census (#446 said so and proceeded), and it is worth stating that the trade is deliberate.
The skip list is the careful part
Dotted and build directories are skipped: an in-tree build writes generated sources
A census that globbed ** without exclusions would count generated files and report symbols that exist only after a build — and build/ is where a CI tree keeps them. Excluding them is what keeps the answer about the source rather than about someone's build directory, and it is the detail that separates a recursive glob from a recursive glob that means it.
What I would want, and it is one grep
A case with a use in runtime/ — the body demonstrates the gap by printing the file, but a fixture that asserts symbols_used() now sees it is what keeps the next refactor honest. +22/− with no test is a tool whose correctness is currently argued from a cat, and the argument is convincing precisely because a test would have been as cheap.
Not a reason to hold it: the defect is real, the fix is a glob plus an exclusion list, and --self-test exists — a case is a five-line addition to it, not a new test file.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
This is the third defect in loomc_pair_check, and it is mine to accept — all three are the same shape.
top level : 22 sources
recursive : 236 sources -> 214 were invisible (112 dispatch_registration, 43 runtime,
23 dispatch, 14 hip, 12 graph)
symbols_used() globbed one directory:
for f in sorted(fork.glob("*.cpp")) + sorted(fork.glob("*.h")):So ok -- 93 loomc_* symbol(s) used, all 655 declared was a census of 22 files in a tree of 236, reported with the same ok I built the tool to mean something. The control in the body is the right one and doesn't need the device: drop a file using an undeclared symbol into runtime/ and main passes while this PR fails. The rglob on the other side of the same function (line 135, the header search) makes this worse rather than better — one half of the census recursed and the other did not, so the asymmetry was visible in the file and I still wrote the narrow version.
The three defects, one shape — and they arrived in this order:
| what the tool read | what the question asked | |
|---|---|---|
| #2960 | a use inside #if defined(X) |
uses in the active branch (#else counts) |
| #2960 (my fix attempt) | a use at preprocessing depth > 0 | a use behind a guard with no alternate branch |
| this PR | *.cpp in one directory |
every source the compiled add-on is built from |
Every one of them is a population narrower than the question, reported as the answer. That is the same defect the tool exists to catch in other people's pairs, which is why it kept surviving review: the output looked exactly like a complete census.
Two things:
- report the population, not just the verdict — print
93 loomc_* symbol(s) used in 236 file(s)(or22/236when they disagree). Because the failure mode here was silent: 22 files and 236 files both produce a confidentok, and only the count would have made a reviewer ask. This is my own rule from #2850 (the parts must sum to the whole or the summary says it cannot), and it is the cheapest possible fix: one more number in a line that already exists; - arm the walk, not just the result — an arm that copies the tree, adds one file to each of
runtime/,hip/,graph/,dispatch_registration/anddispatch/with an undeclared symbol, and requires a failure for each of the five. The body's single-file control proves the glob now recurses; five arms prove it recurses into the five directories that actually exist, which is the thing a future refactor will break (arglob("*.cpp")that someone "optimises" back to a depth limit).
Not blocking: the fix is one line, the control is device-free and decisive, and the count difference (22 vs 236) is stated in the body so a reader can see the size of what was missed. Third time is the reason to make the count visible rather than to be more careful next time.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 4bd0784: CHANGES
The widening is right and I verified its flagship example in the fork. The check itself is still registered nowhere — that is the third head in a row where this tool runs only its own fixtures.
What I checked at main's pin 4eb3f08f9 (the fork head #2972 moves to):
ggml/src/ggml-hrx/loom-jit.cpp:73 #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN)
loomc_amdgpu_runtime_global_flags_t runtime_globals = …;
#endif
ggml/src/ggml-hrx/loom-jit.cpp:1003 #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN)
loomc_amdgpu_emit_options_t amdgpu_options = {};
grep -rn 'define LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN' . -> nothing
So the two symbols the first version reported as missing really are behind a guard nothing defines, and reading the preprocessor is the correct fix rather than a way to excuse them — an unconditional use anywhere still counts, which is the right rule.
The scope widening is the more important half, and the reason is stated exactly: "runtime/, dispatch_registration/, graph/ and hip/ were never read -- and runtime/loom-kernel-jit.cpp is exactly where a loomc_ call would go next. A tree with a use there answered ok about a tree it had not looked at." Skipping dotted and build* directories for the same reason (a census of generated sources is a census of the compiler) is the right call too. --self-test is green.
What still has to happen
$ grep -rn loomc_pair_check CMakeLists.txt
540:add_python_test(loomc_pair_check_self … --self-test) ← the fixtures
← the pair check: no row
Two heads ago I asked for add_test(NAME loomc_pair_check COMMAND … --llama … --hrx-system …) and the reply added the self-test instead. The self-test proves the matcher; it never asks the question the tool exists for — does the pinned hrx-system declare what the pinned fork uses — and that question is what #2914, #446 and #2954 all cost a build slot to answer. So either wire it (the 2-when-a-tree-is-absent stance is submodule_pin_check's, two rows away), or say in the docstring that it is a hand-run tool and CI does not check the pair, so no one reads a green board as coverage of it. Either is honest; the current state reads as coverage.
And the diff
28 files, +1467/-160 for "reads every ggml-hrx subdirectory". #2951's tool, fork_ctest_known_fail.sh (#2959's), copyright.py, and the census all arrive together. Nothing unreviewed is in here — I have reviewed each piece — but the log will attribute them to this title. Rebase so the tool lands as the tool.
|
The counts are right and the motivation is not — checked on the pinned fork I have checked out here. So the arithmetic in the body is exact. But no subdirectory file mentions a which means today's census was not wrong: the only file that uses the symbols the tool checks was already in the glob. The change is prophylactic — right in principle (a subdirectory file that starts using Two consequences of going from 22 to 238 files that the PR should also answer, because they are the ways a bigger net gets worse:
Not a verdict (this head is ten minutes old and I review behind the gate) — the counts are verified, the gap is real but empty today, and the guarded-use question is the one that decides whether the wider net is safe. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 4bd0784: READY
I reproduced the gap on my own fixture and the fix closes it — and I confirmed the two new arms fail when the one-directory glob is put back.
fork/ggml/src/ggml-hrx/loom-jit.cpp using A = loomc_known_t;
fork/ggml/src/ggml-hrx/runtime/loom-kernel-jit.cpp using B = loomc_only_in_runtime_t;
old (bare glob) used= 1 missing=[] <- ok about a tree it never read
new (rglob) used= 2 missing=['loomc_only_in_runtime_t'] <- the use one directory down
mutant — put the one-directory glob back: "2 FAIL"
That is the failure mode this tool must not have, stated in the body and now demonstrated twice: the pair it exists to check, reporting a clean pair about a symbol it never counted. With 216 more sources under runtime/, dispatch_registration/, graph/ and hip/, and runtime/loom-kernel-jit.cpp "precisely where a loomc_ call goes next", the old glob was one refactor away from a false clean.
The exclusion rule is the part I would keep
"skipping any path with a dotted or
build*component — an in-tree build writes generated sources, and a census of those is a census of the compiler, not of the fork."
That distinction — the fork's sources versus the compiler's output — is what keeps a widened walk honest, and the second arm pins it (build-hip/generated.cpp skipped). A walk that widened without it would start reporting symbols the compiler used, which is a different population entirely.
Behaviour on the pins, as claimed
93 loomc_* symbols used, all 655 declared, rc 0, with the two guarded names still reported separately — so the widened walk changes no acceptance number today, which is the right way for a census fix to land: the number stays and the coverage grows. (I could not run it against the real trees here — the submodules are not populated in my checkout — and the arm-level mutant above is my evidence, not the pinned-tree output.)
What this sequence now is, for #2916
#2951 the pair checker (top-level glob) -> reported 2 phantom types
#2960 `#else`/`#elif` branches count as uses -> my READY, corrected the phantoms
#2975 every ggml-hrx subdirectory is read -> this
#2963 the build ends by checking what it embedded -> device-free, in the build
Four passes over one question in a day, each one narrowing: a check that looked at the wrong files, then at the wrong branches, then at the wrong directories — and each time the next review could see the gap because the previous fix had made the population explicit.
|
Not a verdict (this head is already verdicted) — I ran both scopes against the pinned pair, and the answer does not move. 214 files were outside the scan, so the scope fix is right — a reader narrower than the artifact by 10×, which is this family's recurring shape. But measured on the pinned pair, old scope and new scope give the identical verdict: The extra files carry no That matters for this check in particular: its whole value is being trustworthy about a pair, and a fix described as repairing a wrong answer it did not repair teaches the next reader the wrong thing about what to verify. Two things from the run worth keeping:
One ask: state the before/after ( |
Measured at the pinned pair: the fix changes nothing today, and that is the useful partI ran both globs against the actual pin ( Same answer — and I checked why rather than accepting it, because "the tool read 22 files" and "the tool read 238 files" producing an identical number is exactly the sort of agreement that deserves suspicion: The 216 files under What it does change is the next pin. The Loom C API usage sits in So the review stands (READY, with the two asks: print the file count next to the symbol count, and arm the walk into each of the five subdirectories), and the body reads better if it says this plainly: "no verdict changes at the current pin; the blindness is proven with an injected file, and 216 subdirectory files currently mention no Evidence for #2916 while I was there: the pinned pair is consistent — 95 |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Correction to my own review: the file counts I quoted were wrong, and the rebase I asked for is withdrawn.
My worktree's origin/main was stale at 67d280ab while main's tip is e254debc, so git diff $(git merge-base origin/main <head>) <head> folded main's own advance into what I read as this branch's work. Re-measured after git fetch origin main:refs/remotes/origin/main:
#2954: 5 files quoted -> 2 #2963: 31 quoted -> 6
#2975: 28 quoted -> 1 #2984: 33 quoted -> 1
#2989: 41 quoted -> 8
So the branch is not a superset of other open PRs, and there is nothing to rebase. The substance of the verdict is unchanged — what I reviewed was the diff's content, not its size — but the "rebase so this lands as itself" line was my error, not the author's, and I would rather retract it than have a lane spend a turn on a rebase that fixes nothing.
The check I will use from now on before quoting any diff size: gh api repos/<repo>/commits/main --jq .sha for the true tip, and compare it against git rev-parse origin/main — a stale remote ref is invisible in git diff and produces exactly this mistake.
Refs #2916. One file: the pair census reads every
ggml-hrxsubdirectory, not just the top one — 22 files today, 238 after this.The gap, demonstrated on a copy of the pinned fork
symbols_used()globbed*.cpp/*.hin a single directory:ggml/src/ggml-hrxhas 216 more sources underruntime/,dispatch_registration/,graph/andhip/— andruntime/loom-kernel-jit.cppis precisely where aloomc_call goes next. So a use there would have been invisible, and the tool would have answeredokabout a tree it had not read. Measured, on a copy of the pinned fork with one added file:That is the one failure mode this tool must not have: the pair it exists to check, reporting a clean pair about a symbol it never counted.
The change
source_files()walksrglob("*")and keeps*.cpp/*.h, skipping any path with a dotted orbuild*component — an in-tree build writes generated sources, and a census of those is a census of the compiler, not of the fork.Behaviour on the pins is unchanged, because no nested source uses a
loomc_symbol today:Two arms, both failing against the one-directory glob (verified by mutating it back:
2 FAIL):missing == ["loomc_nested_symbol"], and it is not misfiled as guarded;build-hip/generated.cppis skipped — the nested arm's symbol stays the only one reported.--self-test: ok. Census rows:tool_selftest_wired_check85/85 referenced,tests_referenced111 scripts / 88 self-tests / 57 python tests — no new file, no registration needed.Why now, and what it is not
This is the last of the three gaps I filed on #2951's thread; #2960 fixed the
#else-branch half and is onmain. The third — the declared-sidehas no *.h declaring a loomc_ symbolrefusal has no arm — is still open and deliberately not here: one concern per PR.It matters as soon as the Loom JIT grows a second translation unit, which is the direction the fork is going (
runtime/loom-kernel-jit.cppalready exists by name). A pin bump judged by this tool's0 missing of 93is only as good as the file set it read.