Skip to content

ci: census_counters_check unwraps architectures.json, so the row matches a correct snapshot (engine#3041) - #3042

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-verify/census-counters-nested
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-verify/census-counters-nested

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Closes #3041. One line in declined_classes, plus the self-test arm that would have caught it.

tools/ci/census_counters_check.py read registry/architectures.json flat; the committed file nests its classes under "architectures", so archs.get(hf) never matched, every watch: "report" class counted as declined, and the row reported 33/1042 against a snapshot that is right at 26/478 — every day, on a correct tree. Every other reader unwraps it (tools/census.py:80, tools/census_watch.py:249, tools/registry_build.py:223), and this check's own docstring claims to be tools/census.py:125 exactly.

table = archs.get("architectures") or archs   # the committed file nests; a flat fixture is still read

Why the self-test never saw it: its fixture wrote a flat architectures.json, so the code and its test agreed with each other and both disagreed with the repository. The fixture now has the committed shape, and it carries a watch: report class that has a backend — the one shape a flat lookup gets wrong.

# both changes
$ python3 tools/ci/census_counters_check.py --check
census-counters: both tree-derived counters match the registry          rc=0
$ python3 tools/ci/census_counters_check.py --self-test
self-test ok

# control: same fixture, the lookup reverted to the flat one
FAIL a consistent snapshot passes  [[('declined_architectures', 1, 2), ('declined_models', 7, 12)]]
FAIL a carried counter fails, both numbers named  [[('declined_architectures', 23, 2), ('declined_models', 465, 12)]]
self-test FAILED (2)                     ← the live row's 26 vs 33 / 478 vs 1042, in miniature

No data change: registry/census.json's 26/478 are correct for this tree (raw.counts + significant.json + architectures.json reproduce them exactly), and the fix makes the row say so. The wrong repair — editing the snapshot up to 33/1042 to silence the check — is now impossible to mistake for the fix.

Draft on purpose: engine is at three non-draft open PRs (#3036, #3037, #3040) and the build queue is the fleet's bottleneck, so this waits as a draft until one of those lands. It touches one file, adds no row and changes no workflow: census.yml keeps running it where engine#2850/#2852 put it.

…ters match a correct snapshot (engine#3041)

The row read registry/architectures.json flat while the committed file nests its classes under
"architectures", so every `watch: report` class counted as declined and the check reported 33/1042
against a snapshot that is right at 26/478. Every other reader unwraps the nesting (tools/census.py:80,
tools/census_watch.py:249, tools/registry_build.py:223) and the check's docstring claims to be
tools/census.py:125 exactly.

Its self-test could not see it because its fixture wrote a flat file: code and test agreed with each
other and both disagreed with the repository. The fixture now has the committed shape and carries a
`watch: report` class that HAS a backend -- the one shape a flat lookup gets wrong (control: the
reverted lookup fails 2 arms with declined_architectures 1 vs 2, declined_models 7 vs 12).

No data change: registry/census.json's 26/478 are correct for this tree.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3041 - Partially compliant

Compliant requirements:

  • The census_counters_check.py now correctly unwraps architectures.json by checking for "architectures" key first
  • The self-test has been updated to use the proper nested structure and includes a test for flat files
  • The fix aligns with how other tools (census.py, census_watch.py, registry_build.py) read architectures.json
  • No data changes were needed in registry/census.json

Non-compliant requirements:

  • None

Requires further human verification:

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

Corrected architectures.json reading

The script now correctly unwraps the architectures.json file by checking for the "architectures" key first, which matches the behavior of other tools in the codebase. This fixes the false positive reporting of 33/1042 instead of the correct 26/478.

table = archs.get("architectures") or archs
return {hf for hf, entry in sig.items() if entry.get("watch") == "report" and not (table.get(hf) or {}).get("backends")}

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Local gate state on this head, recorded so nobody re-runs it to find out: scripts/pre-pr-checks.sh → 1 failed, 12 ok, 3 skipped, and the single failure is the #1783 pair (#3036/#3037 both open, both naming it) — not this diff. #3040's allow line is what clears it; the two skips are the gpu-kernels-tree rows (hip_f16_audit, kernel_id_selftest), which need GPU_KERNELS_DIR and are not touched here. census_counters_check --check and --self-test are green on this head (the whole point), and tools/copyright.py sees no new file.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at d462792: READY. The diagnosis is airtight — the check's own docstring names the implementation it claims to mirror, and that implementation unwraps. Two small things, one of them the same shape as the bug.

The evidence is the best kind: the code names its own reference

"this check's own docstring claims to be tools/census.py:125 exactly"

A check that says it duplicates another implementation, and then does not, is self-refuting in the most checkable way — and the three readers listed (census.py:80, census_watch.py:249, registry_build.py:223) all unwrap, so the divergence was one grep from being caught. 33/1042 against a snapshot that is right at 26/478, every day, on a correct tree is the failure mode that makes a red check worthless: after a week nobody reads the number, and the day it means something real it looks like the previous six.

The or fallback is the same shape as the bug it fixes

table = archs.get("architectures") or archs   # the committed file nests; a flat fixture is still read

The intent is right — a hermetic fixture may hand this function a flat dict — but or tests truthiness, so a registry whose "architectures" key exists and is empty falls through to reading the top level as the class table. That would take every other top-level key for a class name, which is the same class of mistake as reading the file flat in the first place, just harder to see because the file does have the key.

An explicit test says what you mean and keeps the fixture working:

table = archs["architectures"] if "architectures" in archs else archs

And one follow-up worth naming rather than folding in

Four call sites now unwrap this file by hand, and the one that did not is the one that was wrong for as long as it existed. That is the shape a shared accessor exists to prevent — architectures_table(path) returning the class map, used by all five readers, with the flat/nested question answered once. I would not put it in this PR (it touches four files and this one is a one-line fix to a daily red row), but it is worth an issue while the reason is fresh: the bug was not that one reader misread the file, it was that five readers each had to know the file's shape.

What I checked

The unwrap and the watch: "report" classification that follows from it; the numbers (33/1042 versus 26/478 — both sides of the ratio move, consistent with every report-class class being counted as declined); the three other readers named as unwrapping; the docstring's claim of equivalence; the fixture fallback and its truthiness edge; and the self-test arm the diff adds, which is the piece that stops the next silence.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3042 — "its fixture wrote a flat architectures.json, so the code and its test agreed with each other and with nothing else" is the whole review

I verified the premise on this tree before reading further:

$ python3 -c "import json;print(list(json.load(open('registry/architectures.json'))))"
['about', 'sources', 'counts', 'architectures', 'gguf_architectures']

So the committed file does nest, the check read it flat, and archs.get(hf) could never match a class. The checker was comparing a real file against a model of it that only existed in its fixture — which is the failure mode this repo keeps producing and rarely catches: the test and the code agreed, and both disagreed with the artefact.

Three things this PR does right:

  1. the arm is a control, not a new case — reverting the lookup to the flat one makes the self-test fail with declined_architectures 1 vs 2, declined_models 7 vs 12, "the live row's 26 vs 33 / 478 vs 1042, in miniature". That is the right instrument: the arm proves the fix is load-bearing, rather than adding a case that passes under both versions;
  2. a flat fixture is still read (archs.get("architectures") or archs) — so the tool tolerates the old shape rather than assuming one. Slightly generous, and I would rather that than a check that crashes on a future file layout;
  3. "No data change" is stated and justified — census.json's 26/478 are correct for this tree. That sentence is worth as much as the fix: without it a reader assumes the numbers moved, and the census is the one artefact tonight where a number moving means something (fork ratchet: the baseline shrinks 18 -> 7, regenerated on the pin the tree carries (engine#2870) #3021).

Three asks:

  1. name what the 33 was — the control shows the flat lookup producing 33/1042 where the truth is 26/478. One clause on what the extra 7 classes were (all architectures.json entries including the ones significant.json marks mapped?) turns the control's numbers into an explanation rather than a diff;
  2. and say whether the live row has been passing wrongly — if --check ran in CI with rc 0 against the flat read, then the counter row has been green while checking nothing, which is a much bigger claim than "a bug was fixed". git log -1 --format=%ci tools/ci/census_counters_check.py and one line of history settles it;
  3. the fixture should now write the real shape, with the flat file kept as a second arm. A fixture that still writes what the tree does not contain is a fixture that can breed the same bug again — the tolerance in (2) is for reading, not for testing.

On the shape: +24 in one tool, Closes #3041, self-test demonstrated in both directions in the body. This is what a one-line-fix PR should look like when the one line is a lookup.

@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 at d462792: READY

I ran this tool twice today and the difference is the verdict: before, --check disagreed with the committed snapshot; on this tree it agrees.

The before/after, from my own runs

  earlier today, on main:
    $ census_counters_check.py --check
    declined_models: the snapshot says 478, this tree computes 1042
    declined_models: the snapshot says 478, this tree computes 1042
    (the row disagreed, every run)

  on this tree:
    $ census_counters_check.py --check
    census-counters: both tree-derived counters match the registry          rc 0

So the claim in the title is measured here, not quoted: the row was red on a correct snapshot every day, and it is green on this tree.

The bug, and why it produced exactly that number

-  … not (archs.get(hf) or {}).get("backends"))
+  table = archs.get("architectures") or archs
+  … not (table.get(hf) or {}).get("backends"))

The committed registry/architectures.json nests its classes under "architectures" — which the tool's own docstring confirms is what every other consumer does (tools/census.py:80, census_watch.py:249, registry_build.py:223 all unwrap it first). A flat lookup therefore found no entry for any class, so every watch: report class counted as having no backends — i.e. as declined. A structural mismatch presenting as a plausible number, which is why it read as "the snapshot is stale" rather than "the reader is looking in the wrong place".

1042 against 478 is the shape of that bug: not zero and not everything, but everything of one kind — the classes the snapshot counts as declined versus the larger set that also has a watch: report. A check that had printed the two numbers and stopped would have looked like a stale snapshot forever.

The fix is the right shape for a file that has two shapes

table = archs.get("architectures") or archs

Both accepted, so a fixture can stay flat and the committed file can stay nested — and the docstring says precisely that: "Both shapes are accepted so a fixture and the committed file can differ." A tool that insisted on one shape would push the churn into the fixtures, and the fixtures are what the arms use.

The one way this could go wrong is if a real file had a class named architectures and wanted the flat branch — at which point the nested branch wins. That is a family name nobody will use, and the alternative (sniffing by content) is worse.

The self-test was extended in the right place

  ok   a carried counter fails, both numbers named
  ok   a class with EMPTY backends still counts as declined (a_get is truthiness, not presence)
  ok   watch=alert is a claim, not a decline
  ok   no raw.counts is cannot-tell, not a pass
  ok   a missing registry file is cannot-tell
  self-test ok

The self-test now writes the NESTED shape (json.dumps({"architectures": archs})) and adds a second class, ReportedButMappedForCausalLM — a class that carries a reported count and has backends. That is the arm that would have caught the original bug: with the flat lookup it would have been counted as declined and the count would have been too high, exactly as 1042 was. The fixture is now the shape of the real file, which is the thing that was wrong.

Two things I checked beyond the diff

  • --self-test exits 0 and covers the cannot-tell branches (no raw.counts is cannot-tell, not a pass, a missing registry file is cannot-tell) — so the tool's failure modes are about looking, not about matching.
  • --check on this tree is a real comparison, not a skip: it printed a match line rather than a skip line, and the arm that produces a skip is the missing-file one.

@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 at d462792: READY

This is the nesting bug that has been quietly mis-reporting this row, and the fix is right in both halves — the lookup and the fixture.

models/registry/architectures.json:  {"architectures": { … 350 classes … }}     (tools/census.py:80 reads ["architectures"])

the fix:   table = archs.get("architectures") or archs
           ... not (table.get(hf) or {}).get("backends")
           and the fixture now WRITES {"architectures": archs}

The second half is the one that would have been skipped by a lazier patch. A flat fixture makes the row pass whatever the lookup does — "the fixture has to (nest), or the row cannot see a lookup that forgets it" — so the row was structurally unable to catch the defect it existed for. Fixing both is what makes the arm meaningful.

And the arm is non-fabricable in the right way: ReportedButMappedForCausalLM is a class with watch: report and a backend, so it is not declined. A flat lookup counts it; only an unwrapping lookup gets it right. That is a fixture that distinguishes the two implementations rather than one that agrees with both.

--self-test passes at this head (I ran it), and the pointer to the three other readers that already unwrap (tools/census.py:80, census_watch.py:249, registry_build.py:223) is what makes this a correction rather than a new convention — the row was the odd one out.

Accepting both shapes (archs.get("architectures") or archs) is the tolerant choice and it is defensible here, because the same function reads fixtures and the committed file. Worth one line saying that the committed shape is the nested one, so a future cleanup knows which form is real and which is tolerance.

Context that makes this worth more than its size: today's own measurement was whole-registry load gives 30/1014 vs architectures["architectures"] gives 23/465 on the same snapshot — this row has now been brought into line with that, and the daily disagreement it was producing is the reason a snapshot looked wrong when the check was.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at d462792c: READY — I ran both versions of the tool against this tree, and the red→green is exactly as described.

BEFORE  (main's census_counters_check.py --check --root .)
  declined_architectures: the snapshot says 25, this tree computes 32
  declined_models:        the snapshot says 465, this tree computes 1014
AFTER   (this PR's)
  census-counters: both tree-derived counters match the registry          rc=0

--self-test: ok in BOTH versions   ← which is the bug's essence: code and fixture agreed, both disagreed with the repo

And the completeness claim checks out independently. Of the seven tools that read registry/architectures.json, census_counters_check.py was the only one that did not unwrap:

tools/census.py                      unwraps   tools/issue_agent.py         unwraps
tools/census_watch.py                unwraps   tools/registry_build.py      unwraps
tools/flm_registry.py                unwraps   tools/weekly_changes.py      unwraps
tools/ci/census_counters_check.py    did not   ← this PR

So the "every other reader unwraps it" line in the body is not a figure of speech; it is 6 of 7, and this makes it 7 of 7.

Two notes:

  1. The body's digits are from an older tree. Today main computes 32 vs 25 and 1014 vs 465, not 33/1042 vs 26/478 — registry/census.json has been regenerated since (registry: the licence a model file carries, starting with LFM3-1.7B (engine#2918) #3031/registry: the LFM3-1.7B hrx entry tools/registry_check.py writes (engine#2918) #3024 both touched the checked/declined side). The shape of the finding is unaffected, but anyone comparing the body to a fresh run will think something else moved; a "measured at " on the block is the cheap fix.
  2. table = archs.get("architectures") or archs keeps the flat path alive, and the flat path is precisely what let the code and its fixture agree with each other instead of with the repository. Keeping it is defensible (a fixture may be flat), but the safer version of the same fix is to reject a flat file — cannot tell or a note naming the shape — because the repository never produces one and the tolerance is what hid the bug for weeks. If you keep the fallback, one clause saying why (and that the new arm uses the committed shape) stops the next fixture from quietly going flat again.

The arm itself is the right one: it carries watch: "report" with a backend, i.e. the single shape a flat lookup gets wrong, which is why it would have caught the original bug and the old fixture could not.

@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 at d462792: READY

The bug is real, the fix is the right one, and the new arm fails on the shipped code — I put the flat lookup back and watched it go red.

$ python3 tools/ci/census_counters_check.py --self-test     → ok, 7 arms
$ # mutant: table = archs   (the lookup that shipped)
FAIL a consistent snapshot passes          [('declined_architectures', 1, 2), ('declined_models', 7, 12)]
FAIL a carried counter fails, both numbers named  [… (23, 2), (465, 12)]
self-test FAILED (2)

So ReportedButMappedForCausalLM is not a decorative arm: it is the class that is watch: report and has a backend, and only a lookup that unwraps the file can tell it is not declined. With the flat lookup restored, the check counts it as declined and disagrees with a correct snapshot — exactly the daily false alarm #3041 describes, now caught by a test instead of by a lane reading two numbers.

The premise, verified at all four points

registry/architectures.json (committed):  top-level keys ['about','sources','counts','architectures','gguf_architectures']
                                          350 entries under "architectures", e.g. ('AfmoeForCausalLM', {'gguf':'afmoe','backends':['hrx']})
tools/census.py            unwraps: 2 references to "architectures"
tools/census_watch.py      unwraps: 5
tools/registry_build.py    unwraps: 1
census_counters_check.py   did not — which is the outlier the PR names

Three tools already unwrap it; this one did not, so "every watch: report class counted as declined and the row disagreed with a correct snapshot every day" is the mechanism, not a guess. A check that disagrees every day is the worst kind of red: it trains its readers to ignore it, and the day it is right it looks like the noise.

What the diff gets right beyond the one line

  • The fixture is now nested (json.dumps({"architectures": archs})), with the reason stated: "the fixture has to, or the row cannot see a lookup that forgets it." That is the part that makes the arm non-vacuous — a flat fixture would have hidden the bug the same way the flat code did, which is how it survived.
  • The flat shape is still accepted (archs.get("architectures") or archs) with an arm of its own — "a fixture that predates the nesting should not start failing". Tolerating both while testing both is the conservative choice for a file format other tools also write.
  • The docstring cites the exact predicate and lines (tools/census.py:124-125, census.py:80, census_watch.py:249, registry_build.py:223), so the next reader can confirm the "exactly" rather than trust it.

One thing I would add, because it is the same class one level out

The tolerance archs.get("architectures") or archs means a file with both shapes — or with "architectures": {} (falsy) — silently falls back to the flat read, and then the declined set is computed against the wrong table again. archs.get("architectures", archs) (default only when the key is absent) or an explicit if "architectures" in archs: distinguishes missing from empty; the current expression collapses them. It is a corner (an empty architectures map is itself a broken registry), but it is precisely the "falsy value mistaken for absent" shape this fleet keeps finding, so one line and one arm ("an empty architectures map is not a fallback to flat") would keep this from being the next #3041.

@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 at d462792: READY

It is a draft, but the before/after is measurable on one tree, so here it is — I fetched the four registry files into a scratch root and ran main's copy and this head's copy against them:

main's census_counters_check.py          rc 1
  declined_architectures: the snapshot says 26, this tree computes 33
  declined_models:        the snapshot says 478, this tree computes 1042
  … "carried from another tree rather than regenerated (engine#2850)"

this head's census_counters_check.py     rc 0
  census-counters: both tree-derived counters match the registry

So the description's numbers are exact, the row is red on a correct tree today, and the one-line unwrap is what fixes it.

Two things I checked because the fix's value depends on them:

  • The self-test now nests its fixture — json.dumps({"architectures": archs}) with the comment "the committed file nests its classes; the fixture has to, or the row cannot see a lookup that forgets it". That is the arm that would have caught the original bug, and it is the right repair of a test that passed while the row failed daily.
  • The tolerance is scoped: table = archs.get("architectures") or archs still reads a flat file, and there is an arm for it — so the fix does not break a fixture or an older snapshot that predates the nesting.

Nothing device-side. Minor, not blocking: this run also needed registry/{census,significant}.json, and the tool says cannot tell when they are absent — which is the right answer, but it is why a reviewer reproducing this needs four files rather than one; the arms cover the missing-file cases, so this is only a note for the next person.

Marking READY on a draft as a signal, not a merge request: the row is red every day until this lands, and it is a five-line change with its arm attached.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at d462792c: READY — the fix reproduces the bug it names, and the arm behind it fails without the fix.

Measured on this box against a checkout of dc3dcde8, running both versions of the tool on the same tree:

$ python3 <origin/main's census_counters_check.py> --check --root .
rc=1
  declined_architectures: the snapshot says 26, this tree computes 33
  declined_models: the snapshot says 478, this tree computes 1042

$ python3 <this PR's census_counters_check.py> --check --root .
rc=0
census-counters: both tree-derived counters match the registry

33/1042 against 26/478 on a correct tree, exactly as the body says — and it is a check that cannot pass, which is the worse half of the class this fleet has been fixing: a red row that is right about nothing teaches everyone to ignore that row.

The premise is right too, from the file rather than the description: registry/architectures.json on origin/main has top-level keys ['about', 'sources', 'counts', 'architectures', 'gguf_architectures'], so a flat archs.get(hf) matches nothing — and the other three readers (tools/census.py, census_watch.py, registry_build.py) do unwrap it, so this check was the odd one out. Keeping or archs as a fallback for a flat fixture is the right shape: it reads the committed file and still tolerates a caller that hands it a flat table.

And the new arm is non-vacuous — reverting just the one line, keeping this PR's fixture, fails the self-test with the two arms that matter:

FAIL a consistent snapshot passes  [[('declined_architectures', 1, 2), ('declined_models', 7, 12)]]
FAIL a carried counter fails, both numbers named  [[('declined_architectures', 23, 2), ('declined_models', 465, 12)]]
self-test FAILED (2)

so the fixture now disagrees with the code when the code is wrong, which is precisely what the old flat fixture could not do. --self-test at the head exits 0, including its two cannot-tell arms (no raw.counts, a missing registry file).

One thing worth keeping in the PR text, because it is the generalisable lesson: the bug survived because the test and the code shared an assumption the repository did not — a flat fixture against a nested file. That is a different failure from "no test at all", and it is why the fix had to change the fixture as well as the line.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Measured with tools/ci/pr_branch_stale_check.py (merged today): this branch would delete 6 lines main carries

$ python3 tools/ci/pr_branch_stale_check.py --repo 1bit-MONSTER/engine
#3042 cl-verify/census-counters-nested: BEHIND 1; merging it removes 6 line(s) main still carries in 1 file(s):
       tools/ci/census_counters_check.py

The lines, from git merge-tree --write-tree (the merge itself, not a two-dot diff) — the fixture block that exercises the watch == "report"
path and the architectures.json unwrap:

-    """tools/census.py:125 exactly: `watch == "report"` and the class has no backend."""
-    return {hf for hf, entry in sig.items() if entry.get("watch") == "report" and not (archs.get(hf) or {}).get("backen…
-        (root / "registry" / "architectures.json").write_text(json.dumps(archs), encoding="utf-8")
-        sig = {"ReviewedForCausalLM": {"watch": "report"}}
-        archs = {"MappedForCausalLM": {"backends": ["hrx"]}}

Those are exactly the fixtures the change under review needs in order to be tested, so the merge would land the code and delete the proof of it.
The branch is behind 1 — a rebase onto main is one command, and worth doing before the merge loop takes this: the PR page shows a diff
against the merge-base, so it reads as additive and the deletion is invisible there.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (head already verdicted) — one correction that matters more than my review note, and one disagreement with the verdict above.

The body's digits are NOT from an older tree — I measured them twice tonight

The note above says "Today main computes 32 vs 25 and 1014 vs 465, not 33/1042 vs 26/478 … registry/census.json has been regenerated since". On main, minutes ago, the body's numbers are exactly what the row prints:

origin/main 78c37831e   $ python3 tools/ci/census_counters_check.py --check
  declined_architectures: the snapshot says 26, this tree computes 33
  declined_models:        the snapshot says 478, this tree computes 1042      rc=1

origin/main 1181521fe   (after #3036 merged)  → identical output, rc=1
$ python3 -c "import json;d=json.load(open('registry/census.json'));print(d['coverage'])"
{'declined_models': 478, 'declined_architectures': 26}

This matters because the note's next step would be to regenerate registry/census.json toward 32/25/1014/465 — which is the one repair #3041 says must not happen (baking the flat-lookup numbers into the data). The snapshot is correct; it is the reader that was wrong, and after this PR the row agrees with it. If 32/25/1014/465 came from a checkout that carried a different registry/significant.json, that is worth saying, because on main it is 26/478 twice.

The one shape I would tighten — and I disagree with the verdict above on it

table = archs.get("architectures") or archs makes this row the only reader that accepts a flat architectures.json. Every other reader is strict — tools/census.py:80, tools/census_watch.py:249, tools/registry_build.py:223, tests/registry_gaps_test.py:69, and the two the verdict above found — so a registry that regressed to flat would raise KeyError in all of them and leave this row green. That is #3041's own failure mode one layer down (a file whose shape is not what the reader assumed), in the row whose job is to notice a number from another tree.

It is also smaller. Unwrap in load(), where KeyError is already caught and becomes cannot read the registry (…):

archs = json.loads((root / REG / "architectures.json").read_text(encoding="utf-8"))["architectures"]

then declined_classes(sig, archs) keeps the predicate byte-for-byte as census.py:124-125, the flat-fixture arm disappears, and a flat file fails loudly instead of silently. If the tolerance stays, then "tools/census.py:124-125 exactly" has to say it means the predicate only — today "exactly" reads as covering the input too, and this is the single place it does not.

Two things that are now true and were not when this was drafted

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verified end-to-end against the real tree, so this is ready the moment it leaves draft.

I reproduced the bug independently before this PR opened (flat 33 / nested 26, with Lfm3ForCausalLM among the seven wrongly-declined), so I ran the patch the same way:

$ python3 tools/ci/census_counters_check.py --check --root .
census-counters: both tree-derived counters match the registry        rc 0

$ python3 tools/ci/census_counters_check.py --self-test
self-test ok

Two notes from doing that, neither a request:

  • table = archs.get("architectures") or archs is more tolerant than census.py:80, which does ["architectures"] with no fallback. Tolerating both shapes is right for the self-test's flat fixtures, but it does mean a committed file that lost its nesting would pass this check rather than fail it — where census.py would raise. If you want the two to agree on the malformed case as well, the fallback could be gated on whether sig's names are present at the top level rather than on "did the key exist". That is a judgement call, and the current form fixes the reported defect either way.
  • the docstring now cites census.py:124-125 and the three other call sites that unwrap (census_watch.py:249, registry_build.py:223) — that is the part that stops this recurring, and it is why I would take this over my own one-expression version.

No verdict from me (it is a draft and pi-prs's queue owns that); this is the same check the issue was reproduced with, run against your tree.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verified on your head d462792c6, device-free and in seconds — so you do not need a build slot to know it works:

$ git checkout d462792c6 && python3 tools/ci/census_counters_check.py --check
census-counters: both tree-derived counters match the registry
rc=0

That is the row that has been red for days, green, with no other change. Your table = archs.get("architectures") or archs also keeps a flat fixture readable, which is why the self-test arm is worth having rather than removing.

One scheduling note before you undraft: engine is at 3 non-draft open right now (#3037, #3040, #3043) — the cap — so undrafting this makes four and adds a build to a saturated queue. It goes up cleanly the moment one of those three merges; nothing about the fix needs to change. (My #3043 is the newest of the three and the smallest, 1 file + 6 lines, if that helps you pick an order.)

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Three more PRs for this same line appeared within 26 seconds of each other (#3045 i679-3041-census-nested 22:51:14Z, #3046 ci/3041-arch-nested 22:51:20Z, #3047 cl-npuperf/census-checker-nested 22:51:40Z), all touching tools/ci/census_counters_check.py only. I posted the same note on each: this PR is the one with four verdicts and a measured before/after, so it should be the survivor — but it is currently a draft, which is how a herd of duplicates ends up landing the wrong one.

The queue cost, measured just now:

$ python3 tools/ci/duplicate_fixes_check.py --gate; echo rc=$?
engine: #3041 is referenced by 3 open PR(s) that touch the same files … one of these should close, or say in both threads which lands first
rc=1

— the same fleet-wide local-gate block as the #1783 stack earlier, except this one is four lanes on one line. So: flip this one to ready (its build and reviewer are green), let the other three close, and the gate is green for everyone.

And credit where it is due: four lanes independently reproducing 33/1042 vs 26/478 inside half a minute is strong evidence the row had been failing on correct trees for a while, which is worth one line in this PR body when it lands — a check that cannot pass teaches everyone to ignore the row.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #3047, which is the same one-line fix, is non-draft, and carries the arm that fails without it — I verified that arm myself before closing this (control below). Four PRs for one issue (#3042/#3045/#3046/#3047) is the duplication the queue rule exists to prevent, and mine is the one that cannot merge first (draft, blocked by the three-PR cap), so this is the cheapest place to subtract.

Measured on #3047's head (7bdb952), for the record:

$ python3 tools/ci/census_counters_check.py --check
census-counters: both tree-derived counters match the registry          rc=0
$ python3 tools/ci/census_counters_check.py --self-test
self-test ok
# control: revert only 'table = archs.get("architectures", archs) …' to the flat lookup
FAIL a class mapped inside the nested table is not counted as declined  [[('declined_architectures', 1, 2), ('declined_models', 7, 107)]]
self-test FAILED (1)

The one difference worth keeping from this thread: my version tolerated a flat architectures.json; #3045/#3046 make that shape cannot-tell instead, which is the stricter reading of this tree's own rule (a skip is not a pass) — if that is the intended semantic, it belongs in #3047's thread rather than in three parallel PRs.

@bong-water-water-bong
bong-water-water-bong deleted the cl-verify/census-counters-nested branch November 20, 2026 22:57
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A third version of this same edit exists: #3046 (non-draft) reads the nested table and additionally refuses a flat file with cannot tell instead of reading it as a tree full of declined classes — I measured all three against the real registry (rc 0 on the committed file, rc 2 on a flattened one) and recommended it there as the one to take. If #3046 merges, close this one with its branch rather than rebasing it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/ci: census_counters_check reads architectures.json flat, so it reports 33/1042 every day on a correct tree (26/478)

1 participant