Skip to content

placement: Qwen3.8's restated stage counts the rope rows its load copies to the card - #821

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-placement-fixture-gap
Oct 26, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-placement-fixture-gap

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 배치 시험이 쓰는 카드 계산에서 빠진 rope rows 항목을 채워, 시험이 실제 배치 계획과 같은 값을 확인하게 합니다.

What and why

The Qwen3.8 placement fixture in crates/placement/src/placement/qwen38_cards.rs restates the model crate's cache terms, because the placement crate cannot read the model crate. Its Kv38 left out stage_position_bytes, so the trait default of 0 applied. The real planner counts it: KvLayout::stage_position_bytes in crates/model/src/arch/qwen35moe/place.rs returns the rope row (64 rope dims of f32, 256 B) times the context, and the planner charges it to layer 0's card. The serve load copies those rows to the card (RopeRows::new in crates/gpu/src/arch/qwen3moe/body38.rs), so the planner's count is the right one.

With the term missing, the fixture's A6000 plan kept 1,048,576 B more expert room at 4,096 positions than the engine's plan. That is less than one granule, so the plans differed by a single expert on layer 30 instead of by a visible amount, and the fixture no longer matched the box gate's CARD_PLANS row.

Kv38 now implements stage_position_bytes(ctx_max) = ctx_max * 64 * 4. Two assertions follow from it, each re-pinned with PIN(2026-10-26) and its derivation:

  • q4_on_one_96gb_card_holds_every_routed_expert asserts the box gate's A6000 row: 263 experts on the first 30 layers and 262 on the rest, 39,505,100,800 B of experts and 593,981,952 B of rounding. It had asserted 263 on the first 31 layers and 39,508,684,800 B. The rounding bytes are now part of the assertion.
  • two_slots_at_252416_stay_within_the_margin is a boundary the fixture derives for itself, not a box gate value. The rope rows (256 B a position, one copy shared by both slots) move the last step that holds from 254,208 to 252,928 positions a slot, with 505 experts on every layer and 336 on the host. The test name is unchanged, as in its earlier re-pins.

Release notes: internal: the Qwen3.8 placement fixture counted no rope rows, so it disagreed with the planner it restates.

Code shape

  • No second copy. The change adds one trait method to the existing Kv38; I found no other Qwen3.8 cache restatement in the placement crate. Kv in nodes_scale.rs is a synthetic cache and does a different job.
  • Model code holds only architecture facts. The only production-side file touched is a placement test fixture; no common owner gained a branch, flag or trait method.
  • Dead code is gone. Nothing was left unused; the old comment that said the fixture holds one expert more than the box gate is removed.
  • No silent failure. No input boundary or Result is new. The multiplication ctx_max * 256 lives inside the test restatement, with test contexts only.
  • Comments state what is true now. The two PIN(2026-10-26) lines follow the file's existing re-pin format.
  • No relaxed gate. The A6000 assertion now equals the box gate row and is stricter (it adds rounding bytes). The boundary test moved because the plan changed, with a derivation.
  • 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

cargo test -p bloomery-placement
test result: ok. 197 passed; 0 failed

cargo fmt -p bloomery-placement --check and cargo clippy on bloomery-placement are clean.

I did not run just gate-qwen4exp-meta or gate_qwen38_residency; the change does not touch crates/model.

Hardware (if the change is for a machine)

Not a machine change. The tests are CPU only.

AI help

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

…ies to the card

The restated Qwen3.8 cache (Kv38) counted every layer's stores but not the
rope rows the stage keeps beside them, 64 rope dims of f32 a position,
which qwen35moe's KvLayout counts through stage_position_bytes and the
load copies to the card. The restated A6000 plan so kept 1,048,576 B more
expert room at 4,096 positions than the engine's and held one expert more
on layer 30 than the box gate's CARD_PLANS row.

Kv38 now counts them. The A6000 plan is the CARD_PLANS row, its rounding
bytes included in the assertion, and the two-slot boundary moves from
254,208 to 252,928 positions a slot.
@github-actions github-actions Bot added the placement Placement planning: crates/placement label Oct 26, 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: The fixture now counts the shared rope rows and matches the existing model gate's A6000 plan.

Checked

Duplicates: 1 new method checked; the model implementation cannot be reused by its dependency's fixture. No duplicate owner exists in placement. Dryer reported 0 pairs.

Complexity: crapper flagged no function; the new method adds straight-line arithmetic.

Silent failure: 1 former zero-default path followed through the slot wrapper into the card budget and public stage_rows_bytes total. No new error suppression.

Tests: static mutation analysis of crates/placement/src/placement/qwen38_cards.rs:219: returning 0 restores the old budget, which the changed A6000 tuple and two-slot next-step margin assertions reject. This mutation was not executed.

Gates: both changed expectations have dated PIN comments, reasons, and derivations. The A6000 expert counts, bytes, and rounding equal the existing CARD_PLANS row.

Adversarial checks: slots share one rope table; only the card running layer 0 is charged; fixture contexts fit the new multiplication. The changed module is test-only and adds no runtime hot-path work.

Escape catalog: no C1–C4 pattern matched.

Notes

Rust tests and runtime mutations were not executed during this review. The PR reports 197 passing placement tests.

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

Labels

placement Placement planning: crates/placement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant