Skip to content

ref, qwen4exp: the NVFP4 oracle reads a cut only under the # fixture line of its first shard - #1122

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1121
Nov 2, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1121

Conversation

@juliankang4

@juliankang4 juliankang4 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Qwen3.8 NVFP4 oracle이 cut의 첫 shard에 적힌 # fixture 줄과 맞지 않는 --fixture-line을 거부하도록 고쳤습니다.

What and why

Fixes #1121. For a cut, tools/ref/qwen4exp-nvfp4-oracle.py checked only the first shard's source and revision and took --fixture-line as given. A resume with the line of an earlier cut generation at the same path therefore kept an equal identity and mixed generations. --fixture-line must now state every bloomery.fixture.* key of the first shard except card_budget, each once and with the shard's value; a missing key, an extra key, a duplicate, a malformed token or a different value is refused with an error that names the key. The line is now the shard's real identity, so a regenerated cut changes the resume identity and --resume refuses. The check lives once in check_fixture_line in tools/bloomery/manifest.py, and both Python writers of a cut's sets call it: the NVFP4 oracle and tools/ref/mm31/dump_tf.py, which held a second copy of the same rule. The writers changed, so the HARNESS pin in crates/refset/src/arch/qwen4exp/nvfp4.rs moves to the new md5 a6612dbf9b703308d86474a5963e426d and the BUILD pin in crates/refset/src/arch/minimaxm31/mod.rs to dump_tf-f9d49797b776. The oracle test gets a case that pauses on layers 0,1,2,3, regenerates the shard as 0,1,6,7, and resumes with the previous line (refused), plus a line without the layers key (refused).

Release notes: Fixed: the Qwen3.8 NVFP4 oracle writer no longer resumes a saved state that belongs to another cut of the model.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none.

What I ran

Upstream base e68409b95f80af8d73cec49f193b444145c0501d, PR head 1941ee1f2528a22d54579ffbc4dd82df11d8db62.

Oracle self-test (two cases, including the new one):

$ python3 tools/ref/qwen4exp-nvfp4-oracle-test.py --self-test
test_a_resume_continues_only_the_cut_generation_it_paused_on (__main__.Resume.test_a_resume_continues_only_the_cut_generation_it_paused_on) ... ok
test_the_fixture_line_is_held_to_the_cut_it_names (__main__.Resume.test_the_fixture_line_is_held_to_the_cut_it_names) ... ok
Ran 2 tests in 0.013s

OK

Writer pin and format check:

$ cargo test -p bloomery-refset --lib qwen4exp::nvfp4 && cargo fmt --check -p bloomery-refset && echo FMT-OK
test arch::qwen4exp::nvfp4::tests::the_oracle_writer_pin_is_the_source_in_the_tree ... ok
test arch::qwen4exp::nvfp4::tests::the_family_takes_a_set_of_its_folder_and_writer ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 314 filtered out; finished in 0.01s
FMT-OK

Shared check and the MiniMax-M3.1 writer's tests, on a CPU host (torch 2.14.1+cpu, transformers 5.12.1):

$ OMP_NUM_THREADS=4 $V/bin/python tools/ref/mm31/test_dump_tf.py Refusals Oracle.test_a_cut_states_refsets_fixture_line_and_its_first_shard 2>&1 | tail -8
Ran 15 tests in 1.001s

OK
$ python3 tools/bloomery/manifest.py --self-test
manifest: self-test ok

Card gate on the restamped fixture sets (build a6612dbf), none refused as stale:

$ nvidia-smi
Mon Nov  2 02:42:04 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   49C    P8              4W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84
$ BLOOMERY_TIER=fixture just gate-gpu-qwen4exp-nvfp4-cut
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
(l) plan card=GB10 ctx_max=3072 ubatch=3072 host_experts=0 card_experts=2048 layers short of 512 card experts: [] PASS
(p) the batch set by one pass: last argmax ours=74470 oracle=74470 logits_rel=2.570e-2 kld=0.000079326 (printed) PASS
(g) the batch set by one ubatch: last argmax ours=74470 oracle=74470 logits_rel=7.003e-2 kld=0.000578758 (printed) PASS
(s) the split load: the plan splits true, the oracle's band held true; last argmax 74470 the all-card run's 74470, logits_rel to it 5.583e-3 (printed) PASS
transform: 6 admitted experts, 0 parts differ from a static load: PASS
(rs) mid-p389-s1, each layer reseeded to its highest ids: 6 host experts staged onto the card, the oracle's band held true PASS
(rt) the load for a route trace: host views 0 (want 0), trace positions Some(5) (want 5), every slot on the card true, logits the plain load's bit for bit true PASS
(c) FP4-Local: 5 steps, route taps not the top 10 of their own logits 0, every logit finite true PASS
clauses: 11 ran, 0 left to the real tier

Hardware (if the change is for a machine)

NVIDIA GB10, driver 595.84, CUDA 13.3 (nvidia-smi above).

AI help

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

@github-actions github-actions Bot added host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Nov 2, 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: MUST_FIX: fixture-line validation duplicates the MiniMax oracle's rules.

Must fix

1. Give fixture-line validation one common owner

tools/ref/qwen4exp-nvfp4-oracle.py:201 repeats tools/ref/mm31/dump_tf.py:1045: token parsing, duplicate rejection, budget exclusion and key/value comparison. These are shared fixture rules, with no architecture difference (R14, kind B).
Sharing them now prevents later validation fixes from reaching only one writer. The replacement removes 23 nonblank lines and adds 19, including imports and calls.

Add this definition to the existing tools/bloomery/manifest.py:

def check_fixture_line(meta, line, refuse):
    """Check an already prefixed fixture line against the first shard's metadata."""
    keys = {k: v for k, v in meta.items() if k.startswith("bloomery.fixture.") and k != "bloomery.fixture.card_budget"}
    held = {}
    for token in line[len("# fixture\t"):].split(" "):
        k, sep, v = token.partition("=")
        if not sep or not k.startswith("bloomery.fixture.") or k in held:
            raise refuse(f"--fixture-line: {token!r} is not one bloomery.fixture.* key=value, once")
        held[k] = v
    for k in sorted(keys.keys() | held.keys()):
        if held.get(k) != keys.get(k):
            raise refuse(f"--fixture-line states {k}={held.get(k, 'nothing')}, the first shard has {keys.get(k, 'nothing')}")

After Qwen's standard-library imports, add:

import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "bloomery"))
from manifest import check_fixture_line

Replace Qwen lines 200–210 with:

    check_fixture_line(meta, line, SystemExit)

After MiniMax's standard-library imports, add:

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "bloomery"))
from manifest import check_fixture_line

Delete MiniMax's local keys assignment at line 1037 and replace lines 1045–1055 with:

    check_fixture_line(folder.meta(), given, Refusal)

Refresh both writer pins after these edits.

Checked

Duplicates: 2 new functions checked; the shared validation block is finding 1. Dryer reported no pairs.
Complexity: crapper flagged no Rust functions; Python growth adds input-validation branches.
Silent failure: 4 new dictionary lookups followed; missing values produce named errors before checkpoint loading.
Tests: the validator compared the existing and proposed validation for both callers on 15 cases in memory: exact and reordered lines accepted, 13 invalid cases rejected. All three proposed modules parse. Resume assertions cover changed and missing layer metadata. Rust and GPU runs were not repeated.
Gates: the writer md5 matches the new pin; its dated reason is present. No tolerance moved.
Escape catalog: no matching patterns.

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

…olds a cut's `# fixture` line to its first shard

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

Since the last review: finding 1 is fixed. Both writers now delegate fixture-line validation to tools/bloomery/manifest.py:157.

Verdict: CLEAN: the shared validator preserves both writers' rejection rules, and both updated writer pins match their sources.

Checked

Duplicates: 1 new function checked by Grep; the earlier validation copies are removed. Dryer reported no pairs.
Complexity: crapper flagged no functions. The extracted Python validator retains the existing validation branches; its self-test adds cases.
Silent failure: 4 dictionary lookup sites followed. Missing, extra and changed keys produce named errors before saved state is consumed.
Tests: fixture self-test assertions passed in memory. Removing newline rejection (manifest.py:163), duplicate rejection (:170), or value comparison (:174) turns assertions red; including the budget (:166) rejects a valid fixture. Fourteen isolated MiniMax boundary cases preserve base acceptance and returned text. Vendor folders reject fixture lines; Qwen rejects stale, partial, absent, multiline and duplicate lines.
Gates: both writer hashes match their pins and carry dated reasons. No tolerance moved.
Escape catalog: no matching patterns. The changed production paths are tools, outside inference hot paths.

Notes

Full oracle suites, Rust tests and GPU gates were not rerun by the validator. The PR supplies a GB10 gate run with card, driver, commit hashes, command and output.

🔨 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 d76d5fb into midagedev:main Nov 2, 2026
7 checks passed
@midagedev

Copy link
Copy Markdown
Owner

On the box, gate-refset is red after this PR and #1118. The writer pin moved, so the old sets are refused by name:

  • ref_minimaxm31_{a..e}: build ...dump_tf-8c04e4e88124, the family wants ...dump_tf-f9d49797b776
  • fx_hf-qwen4exp-nvfp4/*: no MANIFEST.tsv (also gate-gpu-qwen4exp-nvfp4-cut)

Nothing for you to do. We are re-dumping these sets on the box now and will post the gate lines here.

@midagedev

Copy link
Copy Markdown
Owner

Re-dump done on the box. The data files are byte-identical to the old sets; only the # build line moved.

  • gate-refset (real): 254 set(s) in place, 0 failed, 1 deferred
  • refset-check: 418 set(s), 0 failed, 1 deferred (was 10 failed)
  • The six ref_minimaxm31_* sets now read build ...dump_tf-f9d49797b776.

Nothing needed from you.

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

Labels

host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen4exp oracle: stale fixture lines allow cross-cut resume

2 participants