Skip to content

model::arch::qwen35moe::fixture: the recorded card budget plans with the load's own activation stack, so q38dense holds 256 routed experts a layer again - #1093

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-q38dense-budget
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-q38dense-budget

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 fixture 예산을 실제 load와 같은 activation stack으로 계산하도록 고쳐, q38dense가 층마다 routed expert 256개를 다시 카드에 둡니다.

What and why

The Qwen3.8 fixture budget planned a card with a fixed q8 activation stack (Stack::q8_blocks32), while a real load plans it with PlanInputs::stack(), which counts the file's own tensor types. The two reserved different amounts on the card, so the recorded budget picked a different expert count than the load. budget_machine and the hw_fixture_q38_budget machine now use inputs.stack(), and the stale comment that said the fixture sets wait for a regeneration is rewritten. No kernel, launch or load-plan code changes.

Release notes: Fixed: the Qwen3.8 fixture card budget plans with the load's own activation stack, so the q38dense fixture keeps 256 routed experts on the card in every layer.

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": removed the fixed-stack copy in crates/model/src/arch/qwen35moe/fixture.rs (budget_machine) and in crates/model-hf/tests/fixture.rs (hw_fixture_q38_budget); both now use the load's inputs.stack().

What I ran

Base 9f35aa59b2c472382f496cdab681b472f13c1dac, head 18d767144c964096a71106957b8e195c8ea062b1.

New test the_budget_machine_uses_the_loads_stack, before the fix (it checks F32, Q4_K and Q8_0 dense types with the integrated card false and true; the first failing case is shown):

$ cargo test -p bloomery-model --lib the_budget_machine_uses_the_loads_stack -- --nocapture
running 1 test
assertion `left == right` failed: the file's dense type F32, integrated=false
  left: Some(2855857152)
 right: Some(2819976192)
test arch::qwen35moe::fixture::tests::the_budget_machine_uses_the_loads_stack ... FAILED

After the fix, with clippy:

$ cargo test -p bloomery-model --lib arch::qwen35moe::fixture::tests -- --nocapture && cargo clippy -p bloomery-model --lib --tests -- -D warnings
running 3 tests
test arch::qwen35moe::fixture::tests::qwen38s_one_dimensional_fills_are_unmoved ... ok
test arch::qwen35moe::fixture::tests::a_fixture_whose_trunk_is_not_the_map_is_refused ... ok
test arch::qwen35moe::fixture::tests::the_budget_machine_uses_the_loads_stack ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 616 filtered out; finished in 0.01s

GPU gate on the q38dense fixture variant (qwen38-fixture-q38dense-00001-of-00001.gguf, derived from Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf), on the head above:

$ BLOOMERY_BOX_LOCAL=1 BLOOMERY_TIER=fixture BLOOMERY_FIXTURE_VARIANT=q38dense BLOOMERY_MODEL=qwen4exp BLOOMERY_FIXTURE_ROOT=/models/fixtures just gate-gpu-qwen4exp-e2e
card leg plan: 4 of 4 layers hold routed experts on the card, a layer's count Some(256)..Some(256) (want 256 on every layer: half the experts, the header's budget) PASS
clauses: 27 ran, 9 left to the real tier
gpu-gate.sh: gate_qwen4exp_e2e ran 93 s (exit 0)

The recorded card budget of this variant moved from 9230614528 to 9204400128 bytes when the fixture CLI replanned it.

Hardware (if the change is for a machine)

$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GeForce RTX 5090, 595.99.02

nvidia-smi header line: NVIDIA-SMI 595.99.02 Driver Version: 595.99.02 CUDA Version: 13.2

AI help

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

…the load's own activation stack, so q38dense holds 256 routed experts a layer again

The fixture budget's machine counted the walk's quantized forms as
Stack::q8_blocks32 while the load plans with PlanInputs::stack, so the
budget it recorded was short of what the load reserves and the q38dense
card leg held 252 or 253 routed experts a layer. budget_machine and the
hw_fixture_q38_budget test now take inputs.stack(); a test holds the
recorded reserve to the load's for F32, Q4_K and Q8_0 on integrated and
discrete cards.

@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: Fixture budgeting now uses the load's activation stack, with no merge-blocking defect found.

Checked

Duplicates: 1 new item checked, the budget-stack regression test; no equivalent test found. Dryer reported 0 pairs.
Complexity: crapper flagged no changed function. The new test adds bounded loops over tensor types and card integration.
Silent failure: 0 new sites. Planning errors propagate; set-aside overflow and an invalid card adjustment remain named errors.
Tests: restoring Stack::q8_blocks32 at fixture.rs:311 makes the new F32 equality assertion fail. The PR supplies FAIL-first output. Restoring the fixed stack at fixture.rs:2744 reintroduces the reserve mismatch guarded by the half-expert assertion.
Gates: no bands, tolerances or pins moved; the hardware test retains its ignore attribute.
Escape catalog: C1–C4 do not match.
Adversarial: mixed tensor types use the shared stack calculation; unified-card adjustments cancel the shared scratch term; foreign architectures are refused. Remaining fixed-stack uses are synthetic or explicitly pinned metadata tests.
Performance: fixture planning and tests only; no decode, prefill or kernel path changes.
Fix layers: shared-owner closure, regression coverage and existing fixture variant-budget/gate plan output are present.

Notes

Tests were reviewed statically and were not rerun. The supplied CPU/GPU logs quote head 18d767144c964096a71106957b8e195c8ea062b1; the reviewed head is 079f45d1b2da357da351538aa4b4a43c052ae614.

🔨 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 547a846 into midagedev:main Nov 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant