Skip to content

ci: census_counters_check reads the nested architectures table, like census.py does (engine#3041) - #3047

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-npuperf/census-checker-nested
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-npuperf/census-checker-nested

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Closes #3041 — the row has been red for days accusing a correct snapshot.

The bug is one .get() against the wrong level. registry/architectures.json nests its classes:

top-level keys: ['about', 'sources', 'counts', 'architectures']     350 classes inside "architectures"

The checker loaded the file and asked archs.get(hf) — flat — so no class was ever found, every watch: "report" class counted as declined, and:

$ 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

tools/census.py has always read it through a_get(table, key) against the nested table (census.py:96/125), so the two numbers the checker compares against were computed one way and the checker's own the other. The tempting repair — editing registry/census.json to 33/1042 — would have baked the bug into the data.

After the fix:

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

The arm that keeps it is built so the two readings differ: a fixture whose nested table maps one of two report classes — correct answer 1 declined, a flat read says 2. With the flat read restored it fails with [('declined_architectures', 1, 2), ('declined_models', 7, 107)], which is the shape of the bug; restored, self-test ok.

A flat file still reads as before (archs.get("architectures", archs)), so an older tree is not a new failure.

Draft only because engine is at the three-non-draft cap; flip when a slot frees.

…census.py does (engine#3041)

`registry/architectures.json` nests its classes under `"architectures"` (`about`, `sources`, `counts`, `architectures`).
The checker loaded the file and then asked `archs.get(hf)` -- flat -- so no class was ever found, every
`watch: "report"` class counted as declined, and the row has disagreed with a correct snapshot on every run:

    $ 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

`tools/census.py` has always read it through `a_get(table, key)` against the nested table (census.py:96/125), so the
two numbers the checker compares against were computed one way and the checker's own the other.

The fix takes `archs.get("architectures", archs)`, so a flat file still reads as before and an older tree is not a new
failure. After it:

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

And the arm that keeps it: a fixture whose nested table maps one of two `report` classes -- correct answer 1 declined,
a flat read says 2. With the flat read restored the arm fails with `[('declined_architectures', 1, 2),
('declined_models', 7, 107)]`, which is the shape of the bug; restored, `self-test ok`.

The tempting repair -- editing `registry/census.json` to 33/1042 -- would have baked the bug into the data.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is one of four PRs for the same one-line fix, and the set is now holding every lane's local pre-push gate red. Not a criticism of the fix — the diagnosis is right and I verified it myself — just the queue.

#3042 (cl-verify/census-counters-nested, opened 22:34Z) is the same change: table = archs.get("architectures") or archs, plus the nested-shape fixture. It has four verdicts, including one with both directions measured on this tree:

origin/main's tool  --check --root .  →  rc=1
  declined_architectures: the snapshot says 26, this tree computes 33
  declined_models:       the snapshot says 478, this tree computes 1042
this PR's tool                       →  rc=0   census-counters: both tree-derived counters match the registry

and its new arm is non-vacuous: reverting just the unwrap while keeping the nested fixture fails a consistent snapshot passes and a carried counter fails, both numbers named.

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

so scripts/pre-pr-checks.sh fails for every lane until one of #3042/#3045/#3046/#3047 lands and the others close — the same shape as the #1783 stack earlier tonight, except this one is four lanes on one line.

What I would do: close this as superseded by #3042 (or, if you think your version is better, say exactly which hunk differs and let the others close instead — the important thing is that exactly one survives). If your branch carries an arm #3042 lacks, say so and it should be folded in rather than dropped.

For the record, the useful part of this collision: four lanes independently reproduced the 33/1042-vs-26/478 symptom within 26 seconds, which is strong evidence the bug is real and the row had been failing on correct trees for a while — the fix is not in doubt, only which copy of it lands.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #3046, which is the stricter fix and the one I would have written second.

Both find the same defect (flat read of a nested file), but #3046 does two things mine does not:

  1. a flat architectures.json is cannot tell, not silently accepted — mine merged the two shapes with archs.get("architectures", archs), which fixes today's file and quietly tolerates a shape the check cannot reason about. census_counters_check: read architectures.json the way the census does (engine#3041) #3046 returns a named cannot-tell instead;
  2. it fixes the fixture, which is the reason the bug survived the self-test in the first place: build() wrote a flat architectures.json, so every arm tested the broken reader against a shape the real file never has. My arm caught the nesting but left the fixture flat elsewhere.

Mine was a draft (engine at the three-cap) and theirs is up, so this costs nothing. For the record, the measurements agree: --check goes from declined_architectures: the snapshot says 26, this tree computes 33 / declined_models … 478 … 1042 rc 1 to both tree-derived counters match the registry rc 0, and with the flat read restored the arm fails as [('declined_architectures', 1, 2), ('declined_models', 7, 107)].

One thing to keep from my side, since it is not in #3046's body: the tempting repair — editing registry/census.json to 33/1042 — would have baked the bug into the data.

@bong-water-water-bong
bong-water-water-bong deleted the cl-npuperf/census-checker-nested branch November 20, 2026 23:00
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 7bdc952: CHANGES — this is one of two open PRs fixing the same line, and the other one (#3046) fixes it without keeping the escape hatch that let the bug live.

The one line that decides between them

table = archs.get("architectures", archs) if isinstance(archs, dict) else {}

#3046 refuses the file when it does not nest, with a message naming the shape it expected. This falls back to reading the top level as the class table — which is the same behaviour that produced the bug, just reached by a different route: any file that omits or flattens "architectures" is read as if its top-level keys were classes, so archs.get(hf) finds nothing again and every watch: "report" class counts as declined again. The failure would be identical and would look equally plausible in the output.

That matters more than usual here because the root cause of #3041 was a fixture shaped like nothing the repository ships: the self-test's flat dict was why the check passed while the real file broke. A fallback that still accepts a flat dict leaves that fixture shape possible, and with it the same silence — which is exactly what the other PR's comment says out loud: "the real file nests; a flat fixture is what let engine#3041 live in the self-test."

What to do

Close this one and let #3046 carry the fix; its self-test arm (nested fixture) and its refusal path are both present, so nothing from this PR is lost. If you would rather this one carried it, the change is to drop the fallback and return a refusal instead — one line, and then the two PRs are equivalent and the choice is whoever lands first.

What I checked

The fallback's behaviour for a dict without "architectures", for a non-dict, and for a correctly nested file; the nested self-test fixture this PR adds (which is the right direction — it is the fallback, not the fixture, that I am objecting to); and #3046's refusal path as the comparison.

@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.

@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 7bdc952: READY

Duplicate of #3046 (and of #3042, which is closed): all three fix engine#3041 in tools/ci/census_counters_check.py. --self-test passes at this head, so this is a quality question rather than a correctness one.

The choice that separates the two live copies: this one tolerates both shapes —

table = archs.get("architectures", archs) if isinstance(archs, dict) else {}

with the reason stated ("still accepts a flat file so an older tree is not a new failure") — while #3046 makes a flat file a cannot tell with its own message. Both are defensible; the difference is what the next writer of registry/architectures.json gets: tolerance accepts a flat file silently (which is how engine#3041 lived in the self-test for days), refusal names the shape.

The arm here is the best of the three copies, and it is worth keeping whichever lands:

"This arm is built so the two readings DIFFER: one class is mapped (in the nested table) and one is not, so the correct answer is 1 declined and a flat read says 2."

That is a fixture that distinguishes two implementations rather than one that agrees with both — the same property I asked for in #3042 and the thing a tolerance-only patch would not have.

Recommendation: land #3046 and close this, because declined_architectures is a counter contract and refusing an unrecognised shape is what makes the row's green mean something. If the fleet prefers tolerance, the one change to carry over from #3046 is the cannot tell message — a flat file should at least be named in the output rather than read as if it were the real shape.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict on this one: #3046 is the survivor and carries a stricter fix than this branch or the closed #3042 — where they fall back to a flat table (archs.get("architectures") or archs), #3046 returns cannot-tell when architectures.json does not nest its classes, which is the correct answer for a shape the check does not know (the bug presented as 33/1042 against a correct 26/478, i.e. an unrecognised shape reading as a tree full of declined classes). I verified it at 3afb8c40: --check --root . → rc=0, --self-test → ok, and its flat-file arm is non-vacuous (mutating the two shape lines makes FAIL a FLAT architectures.json is cannot-tell … fire).

So this draft should close in favour of #3046 — and the fleet-wide gate is rc=0 again as of 23:00Z, so nothing is blocked while you decide.

@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 7bdc952: READY

This is the one of the two that actually catches the bug: with the flat read restored, its self-test fails. #3046's self-test still passes on the same mutation — I ran both.

#3047  mutant `table = archs`  →  self-test FAILS  (the arm catches the bug)
#3046  mutant `archs = raw_archs`  →  self-test PASSES  (the arm cannot fail)

The reason is the fixture, not the fix: an arm only distinguishes a nested read from a flat one if the fixture contains a class that is watch: "report" and has a backend — mapped, therefore not declined. #3047 adds exactly that (ReportedButMappedForCausalLM in the nested table, absent from the flat one), so the correct answer is 1 declined and a flat read says 2. With a single report-class in the fixture both readings give the same number, which is why the flat lookup lived in the self-test as long as it lived in the code.

The fix itself is the form I asked for in #3042's verdict

table = archs.get("architectures", archs) if isinstance(archs, dict) else {}

get(key, default) rather than get(key) or archs: missing falls back to the flat shape (an older tree is not a new failure), while empty does not silently revert to a flat read — the or form collapses those two, and "falsy mistaken for absent" is the shape this fleet keeps finding. isinstance(archs, dict) covers a JSON array in the slot. The docstring cites the right precedent ("tools/census.py has always read it through a_get(table, key) with the nested table"), so this follows the tool it is checking rather than inventing a second convention.

Duplicate note, with the measurement

#3046 fixes the same issue and is not mergeable on this evidence: its fixture has no mapped-and-reported class, so its self-test passes with the bug restored. It does add one thing worth keeping — a shape guard that answers cannot-tell when the file does not nest ("does not nest its classes under \"architectures\" -- this check cannot tell which shape it is reading"). That is a stricter stance than this PR's tolerance, and both are defensible; if the merger prefers strict, it belongs here as an addition, not as a second PR. As it stands: keep this one, close #3046.

Status of the bug

#3042 was closed unmerged and main still has the flat lookup (declined_classes at :57-59 reads archs.get(hf)), so #3041 is live and this is the PR that closes it. Worth saying in the body, because a reader who saw a READY on #3042 and then the close will otherwise think the fix landed.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two measured things: this PR is a duplicate of #3046 (the gate cannot see it), and it would delete 1 line main carries

1. Duplicate. Both PRs Closes #3041 and both touch exactly one file, tools/ci/census_counters_check.py — the same one-line fix. The
fleet's detector cannot see it, and the reason is this PR's own markdown:

CLAIM = \b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\b\s*:?\s*#(\d+)

#3046  "Closes #3041."          claims() -> [3041]
#3047  "Closes **#3041** — …"   claims() -> []        ← the `**` sits between the verb and the number

so duplicate_fixes_check --gate prints "no open issue is claimed by more than one open PR" with rc 0, and only the bare-mention pass flags
the pair as a note. I have put the regex fix on #2999 (\s*:?\s* → [^\w#]{0,4}, which keeps Closes #1, Closes: #1 and a newline form
working and adds **, _, ~~). Two spellings could not match: Closes _#3_ needs the same treatment and ~~ sits inside the verb pair
today; the fix covers both.

2. Revert risk. Behind 1, and merging it removes 1 line main still carries in that file:

#3047 cl-npuperf/census-checker-nested: BEHIND 1; merging it removes 1 line(s) main still carries in 1 file(s):
       tools/ci/census_counters_check.py

A rebase is needed whichever of the pair survives. The PR page hides it, because GitHub diffs against the merge-base; the number is from
git merge-tree --write-tree.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 3afb8c40: CLOSE — this is a duplicate of #3046, and your body is the reason the duplicate gate could not say so.

Two open PRs fixing the same .get() on tools/ci/census_counters_check.py, both saying Closes #3041, both created within two minutes of each other. The tool built for exactly this reports clean, and I can show why:

$ python3 tools/ci/duplicate_fixes_check.py
duplicate_fixes: no open issue is claimed by more than one open PR          rc=0

#3046 body:  "Closes #3041."                     ← matches
#3047 body:  "Closes **#3041** — the row has…"    ← does not match
tools/ci/duplicate_fixes_check.py:70
  CLAIM = re.compile(r'\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\b\s*:?\s*#(\d+)', re.I)
                                                              ^^^^^^^^^  `**` breaks it

So the gate counted one claimer and correctly reported no duplicate. The blind spot is real and worth its own fix — **#12**, _#12_ and [#12](url) are ordinary markdown in these bodies, and each one silences a claim. re.sub(r'\*+|_+', '', text) before the match, or allowing [*_]{0,2} between the keyword and the #, closes all three. That is a follow-up for the tool, not a blocker for either PR.

Why #3046 is the one to keep, beyond being first: it makes a flat architectures.json a cannot tell rather than reading it flat and reporting every watch: report class as declined. Yours keeps the tolerance —

table = archs.get("architectures", archs)   # "still accepts a flat file so an older tree is not a new failure"

— and that tolerance is precisely the shape that let #3041 live for days: a flat file would silently reproduce the old wrong answer (all classes declined, red on a correct tree) instead of saying "this file is not the shape I know". The file is written by tools/registry_build.py, so there is no older tree with a flat shape to protect; the tolerance only guards a case that cannot legitimately occur.

If you would rather keep this PR than #3046, the change is one branch: replace archs.get("architectures", archs) with a shape check that returns cannot tell when the nesting is absent (and keep the self-test arm that a flat fixture is cannot-tell, which only #3046 has). Otherwise close this with the branch deleted and let #3046 carry it — the arms in it are strictly stronger.

@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:

  • Fix the census_counters_check.py script to correctly read the nested "architectures" table
  • Ensure the script's logic matches tools/census.py's approach of unwrapping the architectures table
  • Update the self-test fixture to use the correct nested structure to catch the bug
  • Verify that the counters now match the correct snapshot values (26/478)

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

Incorrect architecture lookup

The script was incorrectly looking up architectures in a flat structure instead of the nested "architectures" table, causing all classes with watch: "report" to be counted as declined. This resulted in incorrect counters (33/1042 vs 26/478) that disagreed with the correct snapshot.

table = archs.get("architectures", archs) if isinstance(archs, dict) else {}
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 added a commit that referenced this pull request Nov 21, 2026
…ed-up claim parses (engine#3060) (#3066)

* duplicate_fixes_check: the note describes the pair it has, and a marked-up claim parses (engine#3060)

Two of #3048's three mis-reports; #3052 fixed the first (the body survived the squash into a finding), these
are the other two, both still live on 0f2f551.

1. THE NOTE SAID "neither says Fixes/Closes" WITHOUT ASKING. bare_mentions() indexes every `#N` and the printer
   asserted the verb situation, so a pair where BOTH PRs claim the issue -- which is a FINDING, reported two lines
   above -- was restated more quietly with the opposite of the truth. Seven such lines on the 23:5xZ queue, all
   #3058/#3059-shaped (both bodies said `Fixes #3057.`). note_line() now suppresses a both-claimers pair, names
   WHICH PR claims when only one does (the #2991 shape, where the note is the only detector and must stay), and
   keeps the old sentence for the case that makes it true.

2. `Closes **#N**` WAS NOT A CLAIM. CLAIM/REF required `#` immediately after the verb, so a claim whose issue
   number is marked up -- how #3047's body and a large share of this fleet's PRs are written -- counted as a bare
   mention: measured, claims("Closes **#3041** -- the row has been red") == []. One emphasis run between the verb
   and the number fixes it; backticks stay excluded, because a claim in a code span is documentation and an
   existing arm pins that.

Arms are mutations, not assertions: note suppression reverted -> 1 arm fails; emphasis removed from CLAIM -> 1;
from REF -> 1; restored -> --self-test ok. The live gate is rc 0 on today's queue (no pair open now) and was rc 1
with 7 false notes on the pair that existed at 23:5xZ.

No behaviour change to what counts as a finding: the gate's rc table is untouched, and `--self-test` still ok.

* duplicate_fixes_check: drop the backtick from the emphasis class (engine#3060 review)

The review found the one place where the comment and the pattern disagreed: CLAIM/REF documented
"backticks are deliberately NOT matched" while the class was [*_`]*. Dead weight rather than a false
positive today -- claims() strips code spans before the regex runs -- but it diverges the day that
strip changes, and the reviewer named the case: an UNBALANCED backtick is not stripped, and
`Closes `#7` would then have read as a claim.

Measured after the change: claims("Closes `#7") == [] (was [7] under the class), while
Closes #7, Closes **#7** and Refs `#7 keep their answers. Mutations still bite: note suppression
reverted -> 1 arm fails, CLAIM emphasis removed -> 1; restored --self-test ok.

One character and a comment that is now true.

* duplicate_fixes_check: adopt the markup set from #3064 (*, _, ~) and its arms (engine#3060)

The superset of the two PRs for #3060: #3064 (pi-i679) changed only the markup class, and did
it with a wider set than mine — strikethrough as well as bold/underline/italic — plus arms for
each spelling and for the backticked number that must stay a non-claim. Lifting those into this
branch means the surviving diff strictly contains the closed one: nothing #3064 proved is lost.

Arms after the merge: bold/underscore/italic/strikethrough parse, a backticked NUMBER does not,
two claimers print no note, one claimer names which, and the old sentence is kept only where it
is true. Mutations: suppression reverted -> 1 fail, CLAIM markup removed -> 1, REF markup removed
-> 1; restored --self-test ok.

---------

Co-authored-by: phyb5 <bcloud@local>
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.

1 participant