Skip to content

registry check: a one-prompt "passed / said Paris" row is not a decode verification - the row now states the measured agreement and KLD - #3466

Merged
bong-water-water-bong merged 1 commit into
mainfrom
fix/3340-registry-decode
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
fix/3340-registry-decode

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

engine#3340's last unfixed surface was the registry record, not the route. registry/checked.json said
MiniCPM4-8B "passed" on hrx (engine b9812e0ca35e, "said Paris") while the bug that lost the last
layer's attention term was live. tests/serve_e2e.sh asks one question under temperature 0, and that
prompt agrees on the broken engine too, so the row could never see the class (2 of 8 prompts, 25 %
greedy agreement, mean KLD 0.305 nats). The cause -- common.get_rows_scale.f32 compiled MiniCPM's
residual_scale 0.2475 through an int64_t-only to_config_value, multiplying the layer-31 attention
term by 0 -- is already fixed on main by the pin bump 0dcf0647 (llama.cpp#493). What main still
carried was a row that reads as verification, and no place that makes a route state what was measured.

  • registry/decode_agreement.json (new): each entry is one tools/logprob_agree.py run -- the
    hrx/llama.cpp and Loom arms against the CPU arbiter, same GGUF, greedy, thinking off -- with its
    engine, llama.cpp commit, date, source link and known answers. MiniCPM4-8B: 75 % greedy agreement /
    0.649 token-id match / 0.0266 nats mean KLD / same top token 100 %, 391 and the primes; 25 % / 0.252
    / 0.305 before the fix. The numbers are copied from the issue's own measurement comment (named in
    source), not re-measured by CI, and the file says so.
  • registry/checked.json:43-84: the MiniCPM4-8B row carries it as its decode object, beside the
    serve pass it already had, so the row states what was measured rather than only what it said.
  • tools/registry_check.py: --annotate-decode copies the record onto the checked rows and runs no
    model; --check-decode fails when a checked row loses its measurement or states one nothing
    recorded; every sweep write re-applies the record (sync_decode in the run loop, :498), so a re-run
    cannot erase it. The record's shape is checked, not just its JSON: commit/date/source, each number in
    the range logprob_agree prints it in, the row's own backend arm present, and the file present --
    annotate refuses a missing record instead of reading it as "record nothing" and stripping rows.
  • --self-test: a scratch registry driven through the stale row, the annotation and every refusal, so
    the check's firing behaviour is pinned by something a machine runs.
  • CMakeLists.txt:1742: ctest rows registry_decode (--check-decode) and registry_check_self
    (--self-test).
  • docs/registry.md:81: what a pass does and does not clear, and the record's format.

Evidence

$ python3 tools/registry_check.py --check-decode          # this branch
ok: 1 recorded decode measurement(s), every one stated on its row                          [rc 0]

# CONTROL: origin/main's checked.json, which states no decode block
$ git show origin/main:registry/checked.json > registry/checked.json
$ python3 tools/registry_check.py --check-decode
registry_check: hrx MiniCPM4-8B-Q4_K_M.gguf: the checked row does not state this measurement [rc 1]
$ python3 tools/registry_check.py --annotate-decode      # restore
set      hrx    MiniCPM4-8B-Q4_K_M.gguf
1 row(s) changed, 1 measurement(s) recorded
# the restored file is byte-identical to the committed one
$ python3 tools/registry_check.py --check-decode
ok: 1 recorded decode measurement(s), every one stated on its row                          [rc 0]

$ python3 tools/registry_check.py --self-test
ok   --check-decode fails a checked row that carries no decode measurement (rc 1, row named)
ok   --annotate-decode writes the recorded measurement onto the row
ok   --check-decode passes once the row states it, and a second annotate changes nothing
ok   --check-decode refuses a row that states a measurement no record holds
ok   --check-decode range-checks a fraction recorded as a percentage
ok   a missing record fails --check-decode and annotate refuses instead of stripping the rows
ok   a sweep's rewritten row keeps the recorded decode block
registry_check --self-test: ok                                                            [rc 0]

$ ctest --test-dir build -R 'registry_decode|registry_check_self' --output-on-failure
100% tests passed, 0 tests failed out of 2

$ scripts/pre-pr-checks.sh --tree-only --base origin/main
pre-pr-checks: all 16 check(s) green, 2 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)

The two skips are the gpu-kernels add-on rows (hip_f16_audit, kernel_id_selftest): no
$GPU_KERNELS_DIR and no third_party/gpu-kernels on this box, each printed with its own SKIPPED
reason. Nothing exited 77 or 2.

What is not verified

  • Not re-measured here. The decode numbers are the issue's recorded run (engine 1c195c45 +
    llama.cpp fork commit edf7f11bc, i.e. with llama.cpp#493), copied into a reviewed record. No
    device/model run was made for this PR, and registry/decode_agreement.json says in its about
    that the numbers are recorded, not re-measured by CI. A re-run on the current pin (f36c1e825) is
    the remaining issue verification (triage expects 75 % / KLD 0.027); this PR does not claim it.
  • The Loom route gate: gated A/B (Loom vs fallback) per shipped model, with the accuracy gate #3158 gate row for MiniCPM4 (the fallback arm becoming a usable reference) is another
    lane's row; this PR only makes the fallback's registry provenance honest.
  • Recorded provenance is that run: engine 1c195c45, llama_cpp edf7f11bc; the fix is carried on
    main by pin bump 0dcf0647. The why field spells that out so llama_cpp not being the current
    pin does not mislead a reader.

Review risk

decode_problems() is the new gate over a reviewed data file: every recorded measurement must be
stated on its row and every stated one recorded, plus commit/date/source/range checks and the row's
own backend arm. The one judgement call to read is the deliberate "a missing record is a FAIL, and
annotate refuses instead of stripping rows" behaviour, pinned by the self-test.

Refs #3340

…on - the row now states the measured agreement and KLD

engine#3340's registry record was the last place still claiming a verification that was never made.
registry/checked.json said MiniCPM4-8B "passed" on hrx (engine b9812e0, "said Paris"), and
tests/serve_e2e.sh asks one question: that prompt agrees on the engine that dropped the last layer's
attention term too (2 of 8 prompts, 25 % greedy agreement, mean KLD 0.305 nats). The cause --
common.get_rows_scale.f32 compiled MiniCPM's residual_scale 0.2475 through an int64_t-only
to_config_value, so the layer-31 term was multiplied by 0 -- is fixed on main since the pin bump
0dcf064 (llama.cpp#493). What main still carried was a row that cannot catch the class, and nowhere
for a route to state what was measured.

- registry/decode_agreement.json (new): one entry per tools/logprob_agree.py run -- the hrx/llama.cpp
  and Loom arms against the CPU arbiter, the same GGUF, greedy, thinking off -- with its engine,
  llama.cpp commit, date, source link and the known answers. MiniCPM4-8B: 75 % greedy agreement, 0.649
  token-id match, 0.0266 nats mean KLD, same top token 100 %, 391 and the primes; before the fix
  25 % / 0.252 / 0.305. The numbers are copied from the issue's measurement comment (its source), not
  re-measured here: CI has no device and the GGUF is not in the tree, and its "about" says exactly that.
- registry/checked.json:43-84: the MiniCPM4-8B row carries that record as its "decode" object, beside
  the serve pass it already had, so the row states what was measured rather than only what it said.
- tools/registry_check.py: --annotate-decode copies the record onto the checked rows and runs no model
  (sync_decode, :144); --check-decode fails when a checked row loses its measurement or states one
  nothing recorded (decode_problems, :182), and every sweep write re-applies the record so a re-run
  cannot erase it (:498). The record's shape is checked, not just its JSON: commit/date/source, each
  number in the range logprob_agree prints it in, the row's own backend arm present, and the file
  present at all -- annotate refuses a missing record instead of reading it as "record nothing" and
  stripping the rows.
- --self-test (:276): a scratch registry driven through the stale row, the annotation and every
  refusal, so the check's firing behaviour is pinned by a row that runs (ctest registry_check_self).
- CMakeLists.txt:1742: ctest registry_decode (--check-decode) and registry_check_self (--self-test).
- docs/registry.md:81: what a pass does and does not clear, and the new record's format.

Evidence
  $ python3 tools/registry_check.py --check-decode     # this branch, checked.json committed
  ok: 1 recorded decode measurement(s), every one stated on its row                          [rc 0]

  # CONTROL: origin/main's checked.json, which states no decode block
  $ git show origin/main:registry/checked.json > registry/checked.json
  $ python3 tools/registry_check.py --check-decode
  registry_check: hrx MiniCPM4-8B-Q4_K_M.gguf: the checked row does not state this measurement [rc 1]
  $ python3 tools/registry_check.py --annotate-decode  # restore
  set      hrx    MiniCPM4-8B-Q4_K_M.gguf
  1 row(s) changed, 1 measurement(s) recorded
  (the restored file is byte-identical to the committed one)

  $ python3 tools/registry_check.py --self-test
  ok   --check-decode fails a checked row that carries no decode measurement (rc 1, row named)
  ...
  registry_check --self-test: ok                                                            [rc 0]

  $ ctest --test-dir build -R 'registry_decode|registry_check_self'
  100% tests passed, 0 tests failed out of 2

  $ scripts/pre-pr-checks.sh --tree-only --base origin/main
  pre-pr-checks: all 16 check(s) green, 2 skipped (no gpu-kernels tree), 0 could not be told,
  2 open-PR row(s) not run (--tree-only)

Co-Authored-By: bong-water-water-bong <[email protected]>
@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 24, 2026 08:00
@bong-water-water-bong
bong-water-water-bong merged commit 71f5042 into main Nov 24, 2026
10 of 11 checks passed
auto-merge was automatically disabled November 24, 2026 08:12

Pull Request is not mergeable

@bong-water-water-bong
bong-water-water-bong deleted the fix/3340-registry-decode branch November 24, 2026 08:12
bong-water-water-bong pushed a commit that referenced this pull request Nov 24, 2026
…o, and draft the freeze RFC (engine#3448)

Security review (cl-flm lane, 24 Nov). Issue #3448 has two halves. The rollback half is fixed by #3454
(69bb03f): --latest reads the release identity from inside the verified image and refuses anything that
is not the tag asked for and strictly newer. The freeze half is open, and it is a release-trust decision
(CONTRIBUTING.md: anything touching security is an RFC), so this commit does NOT invent a fix for it: it
stops the tool from claiming the freshness it cannot prove, and puts the decision on record.

Rebased onto origin/main a95beca (after #3465/#3466/#3467); the line references below are that tree's.

The mechanism, as it stands (os/v3/puppy/embed/usr/local/bin/1bit-update):
- update_pick decides which release is the channel's newest and whether it is newer than the running one,
  from GitHub's release list (:257-302). That list is not signed; the first signature is checked at
  :453-455, after the "is it newer" decision, and the early exit says "up to date" without checking any
  signature (:430-438). So a release host that keeps serving the current release also keeps the machine
  answering "up to date" (freeze).

What changed:
- update_pick prints ahead=yes when the RUNNING release is newer than the channel's newest (a final against
  its own -rcs, or a channel that has not caught up), which used to be folded into newer=no (:291-295).
- update_check and update_latest answer that case "up to date: running X is newer than the CHANNEL's newest
  Y" and print one note that the answer is the unsigned release list's word, so a host that hides a newer
  release is not detectable (:328-336, :430-438). A plain "up to date" line is kept for the same-tag case,
  so the console, the notice and the board rows keep reading it.
- docs/update-trust.md (new): what the signature covers today (tools/release_sign.py), the exact order
  --latest decides in with file:line, what #3454 closed and what it leaves open, the freeze threat model
  (adversaries, in/out of scope, P1-P3), and the draft RFC body: options A (signed, expiring latest per
  channel reusing release_sign.py), B (TUF-style metadata), C (signed tag -> commit), D (tag+channel in the
  signed SHA256SUMS), E (accept the risk), each with its trust assumptions and cost, the test plan and the
  NOTICE impact, and the open owner questions.
- docs/os-v3.md, "In-system updates": a paragraph after the trust order saying what the order does not
  prove - freeze, with the release-list/commit/rollback facts - and pointing at the draft.
- tests/update_check_test.sh: two arms (the ahead wording, the note), and the existing "a final release
  sorts after its own release candidates" arm now asserts the ahead wording, which is what the tool says
  there now. os/mini/release-check.sh --self-test gains that same output as a PASS fixture, so the
  update-check row still recognises the answer on the board.

What remains open, and is the RFC's first question: is a compromised release host (freeze) in the threat
model? If yes, option A is the recommendation; if no, record that in docs/os-v3.md and close #3448. No code
in this commit closes it - the honest wording says exactly that.

Evidence:
- Control (new test, PRE-FIX updater from origin/main a95beca):
    c=~/.cache/scratch-3448/control; mkdir -p $c/tests $c/os/v3/puppy/embed/usr/local/bin
    git show origin/main:os/v3/puppy/embed/usr/local/bin/1bit-update > $c/os/v3/puppy/embed/usr/local/bin/1bit-update
    cp tests/update_check_test.sh $c/tests/
    (cd $c && sh tests/update_check_test.sh)
  FAIL a final release sorts after its own release candidates (v2026.49 > v2026.49-rc1)
  FAIL a running release newer than the channel's newest is said as ahead, not as a flat 'up to date'
  FAIL the up-to-date answer names the unsigned release list it rests on, and what that cannot detect
  update_check_test: FAIL
- Branch: sh tests/update_check_test.sh -> "update_check_test: ok" (12 arms).
- Sanity: the same control tree with origin/main's own test and updater -> "update_check_test: ok" (only the
  arms this change adds or re-words differ).
- ctest --test-dir build -R 'update|release_check_selftest|release_sign' --output-on-failure --timeout 600:
  "100% tests passed, 0 tests failed out of 12" (update_e2e_loop skipped: needs root/loop, unchanged).
- scripts/pre-pr-checks.sh --tree-only --base origin/main:
  "pre-pr-checks: all 15 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run
  (--tree-only)"; skips: submodule_pin (0 submodules initialised), hip_f16_audit and kernel_id_selftest
  (no gpu-kernels tree).

Refs #3448.
bong-water-water-bong added a commit that referenced this pull request Nov 24, 2026
…o, and draft the freeze RFC (engine#3448) (#3474)

Security review (cl-flm lane, 24 Nov). Issue #3448 has two halves. The rollback half is fixed by #3454
(69bb03f): --latest reads the release identity from inside the verified image and refuses anything that
is not the tag asked for and strictly newer. The freeze half is open, and it is a release-trust decision
(CONTRIBUTING.md: anything touching security is an RFC), so this commit does NOT invent a fix for it: it
stops the tool from claiming the freshness it cannot prove, and puts the decision on record.

Rebased onto origin/main a95beca (after #3465/#3466/#3467); the line references below are that tree's.

The mechanism, as it stands (os/v3/puppy/embed/usr/local/bin/1bit-update):
- update_pick decides which release is the channel's newest and whether it is newer than the running one,
  from GitHub's release list (:257-302). That list is not signed; the first signature is checked at
  :453-455, after the "is it newer" decision, and the early exit says "up to date" without checking any
  signature (:430-438). So a release host that keeps serving the current release also keeps the machine
  answering "up to date" (freeze).

What changed:
- update_pick prints ahead=yes when the RUNNING release is newer than the channel's newest (a final against
  its own -rcs, or a channel that has not caught up), which used to be folded into newer=no (:291-295).
- update_check and update_latest answer that case "up to date: running X is newer than the CHANNEL's newest
  Y" and print one note that the answer is the unsigned release list's word, so a host that hides a newer
  release is not detectable (:328-336, :430-438). A plain "up to date" line is kept for the same-tag case,
  so the console, the notice and the board rows keep reading it.
- docs/update-trust.md (new): what the signature covers today (tools/release_sign.py), the exact order
  --latest decides in with file:line, what #3454 closed and what it leaves open, the freeze threat model
  (adversaries, in/out of scope, P1-P3), and the draft RFC body: options A (signed, expiring latest per
  channel reusing release_sign.py), B (TUF-style metadata), C (signed tag -> commit), D (tag+channel in the
  signed SHA256SUMS), E (accept the risk), each with its trust assumptions and cost, the test plan and the
  NOTICE impact, and the open owner questions.
- docs/os-v3.md, "In-system updates": a paragraph after the trust order saying what the order does not
  prove - freeze, with the release-list/commit/rollback facts - and pointing at the draft.
- tests/update_check_test.sh: two arms (the ahead wording, the note), and the existing "a final release
  sorts after its own release candidates" arm now asserts the ahead wording, which is what the tool says
  there now. os/mini/release-check.sh --self-test gains that same output as a PASS fixture, so the
  update-check row still recognises the answer on the board.

What remains open, and is the RFC's first question: is a compromised release host (freeze) in the threat
model? If yes, option A is the recommendation; if no, record that in docs/os-v3.md and close #3448. No code
in this commit closes it - the honest wording says exactly that.

Evidence:
- Control (new test, PRE-FIX updater from origin/main a95beca):
    c=~/.cache/scratch-3448/control; mkdir -p $c/tests $c/os/v3/puppy/embed/usr/local/bin
    git show origin/main:os/v3/puppy/embed/usr/local/bin/1bit-update > $c/os/v3/puppy/embed/usr/local/bin/1bit-update
    cp tests/update_check_test.sh $c/tests/
    (cd $c && sh tests/update_check_test.sh)
  FAIL a final release sorts after its own release candidates (v2026.49 > v2026.49-rc1)
  FAIL a running release newer than the channel's newest is said as ahead, not as a flat 'up to date'
  FAIL the up-to-date answer names the unsigned release list it rests on, and what that cannot detect
  update_check_test: FAIL
- Branch: sh tests/update_check_test.sh -> "update_check_test: ok" (12 arms).
- Sanity: the same control tree with origin/main's own test and updater -> "update_check_test: ok" (only the
  arms this change adds or re-words differ).
- ctest --test-dir build -R 'update|release_check_selftest|release_sign' --output-on-failure --timeout 600:
  "100% tests passed, 0 tests failed out of 12" (update_e2e_loop skipped: needs root/loop, unchanged).
- scripts/pre-pr-checks.sh --tree-only --base origin/main:
  "pre-pr-checks: all 15 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run
  (--tree-only)"; skips: submodule_pin (0 submodules initialised), hip_f16_audit and kernel_id_selftest
  (no gpu-kernels tree).

Refs #3448.

Co-authored-by: bong-water-water-bong <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3158 - Partially compliant

Compliant requirements:

  • The PR introduces a mechanism to record and verify decode measurements for models
  • The registry/decode_agreement.json file stores the accuracy measurements
  • The registry_check.py tool now supports --annotate-decode and --check-decode modes
  • The registry/checked.json now includes a "decode" object that records the measured agreement and KLD

Non-compliant requirements:

  • The performance gate with interleaved rounds and memory caps is not implemented in this PR
  • The toolchain blocker for schema_version: 2 cards is not addressed in this PR

Requires further human verification:

  • The actual performance measurements (interleaved rounds, load average, power mode) need to be verified
  • The accuracy measurements (greedy agreement, mean KLD, same-top-token) need to be confirmed on hardware
  • The decision rule implementation for Loom routing needs to be validated
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Decode measurement validation

The new decode validation logic in tools/registry_check.py introduces strict validation of the registry/decode_agreement.json file structure and content. While this is good for data integrity, the validation is quite strict and may fail on minor formatting issues in the JSON file. Specifically, the validation of mean_kld_nats field requires it to be either null or a number >= 0, but the current implementation does not handle the case where mean_kld_nats is present but not a number or null. This could cause the validation to fail on valid JSON data.

if "mean_kld_nats" in nums:
    value = nums["mean_kld_nats"]
    if value is not None and (not isinstance(value, (int, float)) or isinstance(value, bool) or value < 0):
        problems.append(f"{name}: {where}.mean_kld_nats {value!r} is not null or a number >= 0")
Self-test validation

The self_test() function in tools/registry_check.py creates a test case for the decode record validation. However, the test case uses hardcoded values for the before_fix field, which may not accurately reflect the expected behavior in all scenarios. The test should be more robust to ensure that the validation logic works correctly for various edge cases.

model = "MiniCPM4-8B-Q4_K_M.gguf"
record = {
    "backend": "hrx", "model": model, "arbiter": "cpu",
    "check": "tools/logprob_agree.py --thinking off --text-only --match-by text",
    "arms": {
        "hrx": {"greedy_agreement": 0.75, "token_id_match": 0.649,
                "mean_kld_nats": 0.0266, "same_top_token": 1.0},
        "loom": {"greedy_agreement": 0.75, "mean_kld_nats": None},
    },
    "before_fix": {"greedy_agreement": 0.25, "token_id_match": 0.252, "mean_kld_nats": 0.305},
    "measured": "2026-11-23", "engine": "1c195c45", "llama_cpp": "edf7f11bc",
    "source": "https://github.com/1bit-MONSTER/engine/issues/3340#issuecomment-7093204931",
    "why": "a one-prompt serve check said Paris on the engine that dropped the last layer's attention term",
}

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