Skip to content

levers: --levers says whether each lever applies to the binary and seat; a lever read in place is checked by its kind at main, and one the binary does not read is named as not applied - #890

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-lever-applied
Oct 27, 2026

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

--levers가 각 lever를 이 binary와 seat가 실제로 쓰는지 보여 주고, 값 형식이 틀린 lever는 시작할 때 거절합니다.

Part of #565.

What and why

On upstream main, a lever that the code reads in place (the registry's "in place in" rows) is never checked at start. BLOOMERY_WEIGHTS=anon and BLOOMERY_QDOT_AVX512=2 both print - in the --levers table with no refusal, so a mistyped value goes through, and a lever set beside a binary that ignores it looks the same as one that works.

This change makes --levers print, for every lever, whether this binary (on bloomery-serve, this seat) applies it: yes, no or refused, then its value. At start, a lever read in place has its value checked by its registry kind, as a parsed lever already is. A value of the wrong form is refused by name with what the lever takes, and the process exits 1. A value of the right form that this binary or seat does not read does not stop the start, since one environment often holds levers for several models. It prints one line on stderr saying the lever is not applied and where it is read, and the table shows no with the value. A parsed lever outside a binary's list is still refused, as before.

Site::Direct rows in crates/levers/src/registry.rs gain a by field: Every for the four levers the host tier reads under any binary, Named for the rest, which the binary or seat that reads them lists in its acts_on. The lists name a lever through the reader's own constant (UBATCH_ENV, DRAFT_CARD), so the name has no second copy. The qwen38 seat's list test also breaks when the seat reads BLOOMERY_QWEN3_UBATCH through ubatch_rule without listing it. The Levers paragraph in docs/BUILD.md describes the new column and line.

Release notes: Fixed: --levers shows whether each lever applies to the binary and seat, a lever read in place is refused for a value of the wrong form, and one the binary does not read is reported as not applied.

Code shape

  • No second copy. The applies judgement uses the registry rows and each binary's acts_on, with no new table. Kind::taken is the one check of a value, and the override path's copy of its text branch calls it.
  • Model code holds only architecture facts. No model file changed. The change is in crates/levers and the startup lever lists of serve seats and gates.
  • Dead code is gone. not_parsed became not_named, and nothing it replaced is left.
  • No silent failure. A wrong value is refused by name, and an unread lever prints a not-applied line instead of staying quiet.
  • Comments state what is true now.
  • No relaxed gate. No band or tolerance moved. The tools/model-tax.tsv baseline for shared/routed_legs.rs goes from 21 to 22, under its limit of 24.
  • cargo fmt and cargo clippy on what I touched: I ran the format check on the later revision (below). I did not run cargo clippy on the head.

Duplication found or removed (path:line): none. The two copies of a lever's text branch (the main path and the override path) are now one call to Kind::taken.

What I ran

Head 54e1f3f20c5f404817ec563f869e79f6850e40b5, base 088286a775141f3de3c5c6f8f5473ac596ed1e11. The checks below ran on earlier revisions of this patch. The later revisions drop two list entries from gate binaries, add one command-line test and rebase; the lever logic is the same. I did not rerun the GPU-machine checks on the head itself.

Lever tests on an earlier revision:

cargo test -p bloomery-levers --lib
test result: ok. 54 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.50s

On the later revision, with the added command-line test, test-bloomery-levers and fmt finished with rc 0 in the repository's contributor checks. On the earlier revision, check-levers and check-model-tax both finished with rc 0.

Each new test breaks when its behavior is removed. Three one-line mutants of crates/levers/src/lib.rs, run against the tests:

every Direct lever counted as read:        52 passed; 2 failed
Direct rows skipped at main (no kind check): 51 passed; 3 failed
an unread Named lever refused:             50 passed; 4 failed

just gate-q38-serve-rules on an RTX 5090 machine includes these tests:

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 278 filtered out; finished in 0.00s
test tests::the_levers_list_is_the_levers_the_seat_reads ... ok
test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

To reproduce on the qwen38 seat, run bloomery-serve-qwen38 --levers with the environment named on each case. The table rows below are trimmed to the lever each case is about; the real output is one line per lever.

BLOOMERY_QWEN3_UBATCH=0
bloomery-serve-qwen38: BLOOMERY_QWEN3_UBATCH="0" is refused: it takes a whole number from 1 to 4096 (base 10, no sign or leading zero)
rc=1

BLOOMERY_WEIGHTS=anon BLOOMERY_HYBRID_NL=32
BLOOMERY_HYBRID_NL="32" is not applied: this binary (bloomery-serve-qwen38) does not read it; it is read in place in crates/gpu/src/hybrid.rs (v2fence)
BLOOMERY_WEIGHTS="anon" is not applied: this binary (bloomery-serve-qwen38) does not read it; it is read in place in crates/model/src/bin/bloomery-decode.rs (v2fence)
rc=0

BLOOMERY_WEIGHTS=bogus
bloomery-serve-qwen38: BLOOMERY_WEIGHTS="bogus" is refused: it takes one of anon, huge
rc=1

The qwen38 seat's list test fails when UBATCH_ENV is taken out of the list, with BLOOMERY_QWEN3_UBATCH is read by the seat but not in ACTS_ON. Two gate binaries that start a seat list the lever their seat reads, so --levers on them shows it as applied:

BLOOMERY_QWEN3_UBATCH=512 gate_qwen3_dspark --levers
BLOOMERY_QWEN3_UBATCH      C setting load     yes     set 512      in place in crates/gpu/src/arch/qwen3moe/ubatch.rs ([03])

With the old empty list, the same command printed is not applied: this binary (gate_qwen3_dspark) does not read it.

Not run: a timed measurement, since the change only reads environment variables at start and touches no decode or prefill path; the repository's verify profile, which this checkout does not have; and a GB10 compile, since no device code changed.

Hardware

NVIDIA-SMI 595.99.02              Driver Version: 595.99.02      CUDA Version: 13.2
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0 Off |                  N/A |

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…at; a lever read in place is checked by its kind at main, and one the binary does not read is named as not applied

A Direct row now says who reads it: every binary (the host tier's POISON, STEAL, PROFILE and
QDOT_AVX512, read below any main as the pool's two are), or the binaries that name it among the
levers they act on. A binary's reading parses every Direct lever set by the row's kind, as a
Parsed one (a Text value stays its owner's), so a value its kind does not take is refused at the
start instead of where a load reads it. A well-formed Named one the binary does not read does not
stop the start, since one environment may carry the levers of several models: a line on stderr
says it is not applied and where it is read. A Parsed lever left out of the list is refused as
before.

--levers prints every line even when the reading refuses, with a column for whether this run
applies the lever (yes, no, refused) and the value set, then returns the refusals as a start
without it would.

The binaries and seats whose path reads BLOOMERY_QWEN3_UBATCH (the qwen3, qwen38 and decide
seats, generate_qwen3moe and the gates that open a qwen3moe body) and BLOOMERY_DSPARK_CARD (the
ds41 seat and its gate and soak, generate_ds41, gate_deepseek41_twocard) name it.
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: I built no failure path for the lever reading that survived a check, and I found no proven duplicate, unneeded element or relaxed gate.

Non-blocking

⚠ The "seat list breaks" test covers one spelling: bloomery_serve_qwen38.rs:400. DIRECT_READS is a hand-made list and the check is src.contains("ubatch_rule(a."). If the seat reads a second Direct lever, or reads UBATCH_ENV through ubatch_asked(), nothing turns red, and --levers prints no for a lever the seat applies. The PR body says the test breaks when the seat reads the lever "through ubatch_rule without listing it"; that holds only for this call text. Direction: say so in the body, or scan the seat source for each Readers::Named row's reader function.

⚠ Nothing guards the gate-binary lists: for example gate_qwen38_nodes.rs:1717. Each repeats ubatch::UBATCH_ENV. A bin that starts to read the lever later prints a false "is not applied" line. A bin that stops keeps a stale entry. Both are non-fatal. Also shared/routed_legs.rs:660 is common code, and it now names a qwen lever (tools/model-tax.tsv qwen 21 to 22, limit 24). The PR does not say which architecture fact forces this.

Checked

  • Duplicates: 4 new items checked (Readers, Reading, Kind::taken, not_named); none duplicated. dryer found 0 pairs; it did not search crates/gpu-gates, so I grepped it by hand.
  • Complexity: crapper flagged reading (new, 46) and table_is_a_line_per_lever (8 to 13). reading is the old read with the Direct arms added to one match: one owner, no split asked. The test growth is mild.
  • Silent failure: 5 sites followed (Direct Kind::Text value None; unset acts: false entry; --levers with a refusal; _ => continue for other scopes; Every levers now refused for a wrong form). No script under tools/ or the justfile sets a value the kinds refuse.
  • Tests: mutants run in my head. Direct skipped at main, unread Named refused, Every counted as unread, and swapped table cells each turn a test red.
  • Gates: no band or tolerance moved.
  • Hot path: none (start-up only). Escape catalog: no pattern matched.

Notes

  • The PR body's hashes (54e1f3f, 088286a) are not the head (03a5613) or base (2f27e83). The GPU checks ran on earlier revisions, and cargo clippy was not run on the head. I set evidence to false in gpu.json.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_deepseek41_twocard.rs, crates/gpu-gates/src/bin/gate_gemma_embedding2_serve.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 34f9d2d into midagedev:main Oct 27, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant