Skip to content

model: qwen4exp placement sizes saved states and PLE readers for the load, and refuses a missing plan callback - #979

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-sa-q10-placement
Oct 29, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-sa-q10-placement

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 배치 계획이 저장 상태와 PLE reader 예약을 실제 load 크기로 계산하고, plan callback이 없으면 오류를 냅니다.

What and why

The Qwen3.8 placement planned a fixed number of saved-state checkpoints regardless of context, and reserved the PLE reader for a fixed width regardless of the serving ubatch. The load saves a context-dependent number of states and reads with the real ubatch, so the plan and the load disagreed. widen_card_route also accepted a successful callback that returned no plan.

  • Price::saved_points (runtime) is the one bound on the inner points a save can carry (first, anchors, last, capped by the host budget). state38 uses it for the checkpoint copies and for the MTP hidden rows. The load keeps using the real save_points.
  • runtime::stores::reader_columns(ubatch) is the one owner of the reader width (max(ubatch, PASS_ROWS)). The plan and the host reader both read it, and a ubatch of 0, above the context or above the supported width is PlaceError::Ubatch.
  • widen_card_route returns PlaceError::MissingPlan when a successful callback hands back no plan.
  • A two-plane NVFP4 PLE table now reserves 896 MiB less at U=512 than at U=4096 (assert_eq!(reserve(4096) - reserve(512), 896 << 20) in saved_state_and_reader_count_the_load_shape). No kernel or dispatch changes, and I claim no speed change.

Release notes: Fixed: Qwen3.8 placement now sizes saved sequence states and the PLE reader from the context and ubatch the load uses.

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

Unit tests (head ef3798b44 for the model and single-case runs, 585927823 for the placement module):

cargo test -p bloomery-model --lib arch::qwen35moe::place::tests
test result: ok. 38 passed; 0 failed; 0 ignored; 0 measured; 568 filtered out
cargo test -p bloomery-placement qwen38_cards
test result: ok. 30 passed; 0 failed; 0 ignored; 0 measured; 190 filtered out
cargo test -p bloomery-placement saved_state_and_reader_count_the_load_shape
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 219 filtered out

Each fix fails its own test on the old behavior. With the fixed checkpoint count, the fixed reader columns and the expect on the plan callback put back (head 333e10eb):

test result: FAILED. 35 passed; 3 failed; 0 ignored; 0 measured; 566 filtered out
FAIL-FIRST PASS: fixed checkpoint count, fixed reader columns and missing plan callback all rejected

Restoring the fixes returns the same command to test result: ok. 38 passed; 0 failed.

GB10 gate with the NVFP4 expert model (nvidia/Qwen3.8-Flash-Next-NVFP4, one F8 PLE plane), head ef3798b44, draft off, ctx 16385, U=512, q8 KV:

cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve-qwen38 --bin gate_qwen4exp_nvfp4 --bin gate_qwen4exp_e2e
bash tools/gpu-gate.sh --executable target/release/gate_qwen4exp_nvfp4 --placement
(placement) ubatch=512 reader_columns=512 parts=true q8=true row_reserve_bytes=67108864 expected=67108864 PASS
(placement) positions=1 checkpoint_copies=1 seq_save_bytes=148115264 arrays_bytes=148115264 planned_bound=148115264 expected=148115264 PASS
(placement) positions=16384 checkpoint_copies=4 seq_save_bytes=818888960 arrays_bytes=818888960 planned_bound=966988096 expected=818888960 PASS
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 55 s (exit 0)

The real server on the same model and flags answers a completion request:

target/release/bloomery-serve-qwen38 --ctx 16385 -ub 512 --parallel 1 --cache-ram 2048 --host 127.0.0.1 --port 17881
REAL-BINARY content=" Paris" tokens=[11751] tokens_predicted=1 tokens_evaluated=5
REAL-BINARY PASS

GB10 gate with the two-plane PLE table (nvidia/Qwen3.8-Flash-Next-FP4-Local, code plane U8 [2500012, 80], scale plane F8 [2500012, 10], 128 shards), head 585927823:

bash tools/gpu-gate.sh --executable target/release/gate_qwen4exp_nvfp4 --placement
(placement) ubatch=512 reader_columns=512 parts=true q8=true row_reserve_bytes=134217728 expected=134217728 PASS
(placement) positions=1 checkpoint_copies=1 seq_save_bytes=148115264 arrays_bytes=148115264 planned_bound=148115264 expected=148115264 PASS
(placement) positions=16384 checkpoint_copies=4 seq_save_bytes=818888960 arrays_bytes=818888960 planned_bound=966988096 expected=818888960 PASS
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 36 s (exit 0)

The checkpoint lines show the planned bound at or above the bytes the load actually saves (arrays_bytes) at both context lengths.

Hardware (if the change is for a machine)

  • Card: NVIDIA GB10 (sm_121a)
  • Driver: 595.84

AI help

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

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card placement Placement planning: crates/placement labels Oct 29, 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 saved-state bound and reader reservation follow the load dimensions, and missing callbacks return a named error.

Non-blocking

⚠ Run the placement check from the gate recipe: gate_qwen4exp_nvfp4.rs:758 selects the new checks only with --placement.
The gate-gpu-qwen4exp-nvfp4 recipe (justfile:1763) invokes the binary without arguments, so it skips these checks.
Append a second gpu-gate.sh gate_qwen4exp_nvfp4 --placement invocation to that recipe with its existing card selection and exit-code chaining. Wiring it now keeps recurrence prevention in routine runs.

Checked

Duplicates: 12 new functions/constants checked; no duplicated sizing rule. Dryer reported 0 pairs; GPU and gate code were searched manually.
Complexity: new placement = 21 covers planning, reader checks and save checks. Existing growth is argument-error propagation or gate clauses: props_engine, drafted_paged_run, NVFP4 run, serve-seat run; nvtier run/arm/stepunion_arm/slots_mid_arm/refuse_clauses/sitting_child; nodes measure/census_plan/run_history; e2e snapshot_prefix. No structural defect found.
Silent failure: 5 added/reformatted default or error-discard sites followed. Zero spacing and stateless pricing are defined inputs; failed test plans reach false assertions.
Tests (static mutation check): replacing the checkpoint count at place.rs:2050 with two copies breaks qwen38_state_bytes; restoring fixed reader width at place.rs:678 breaks the expanded source test. Dropping the MissingPlan checks at place.rs:1378 (also line 1398), or the ubatch guard at line 1063, breaks the expanded route test. Removing the budget cap at seqstate.rs:131 breaks the new bound test; removing the verify floor at stores.rs:33 breaks the new reader-reservation test. Fixing MTP hidden rows to one breaks props_engine. The new card check rejects the old bound at 16,384 positions. Other test edits pass the new argument through existing assertions.
Gates: the split-save equality is retained beside its new bound check; the changed clause carries a dated PIN. No tolerance was relaxed.
Performance: changes affect planning, loading and save-size accounting; no new per-token work, launch or copy.
Escape catalog: no matching pattern.

Notes

The PR supplies GB10 gate output, but omits the required nvidia-smi line and base revision for those runs. GPU evidence is false.
This review used source inspection; no build or card run was performed.

Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_nvtier.rs, crates/gpu-gates/src/bin/gate_qwen38_nodes.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 90c9f30 into midagedev:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card placement Placement planning: crates/placement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant