Skip to content

gpu, glm5next: a route trace's load views only the layers the host computes - #739

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:fix-load-refusals
Oct 23, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:fix-load-refusals

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 체크포인트 폴더의 MTP 층 때문에 서버 시작이 거부되던 문제와, route trace를 켜면 모든 카드 상주 로드가 거부되던 문제를 고쳤습니다.

Part of #565. Tracked in #699.

What and why

Two defects refuse a load that has nothing wrong with it. This PR fixes both in the shared owners and changes no output.

  1. A checkpoint folder's MTP layer could refuse the target. folder::open in crates/model-hf/src/arch/qwen35moe/folder.rs mapped and planned the mtp. tensors before it built the target header, and returned any error from that step as the folder's error. An MTP layer the draft cannot read (an F32 mtp.fc_embedding.weight, a second MTP layer, an unquantized expert stack) therefore refused server start even with BLOOMERY_DRAFT=off. The MTP preparation now lives in folder::mtp, and Opened::draft is a Result<Option<Split>, Error>, so the target opens whatever the MTP layer holds. The seat applies the existing BLOOMERY_DRAFT rule through a new Draft38Off::FolderMtp reason: a set mtp is refused with the layer's own refusal, an unset draft turns off and records why, and off is unchanged. docs/serving.md says so in one sentence. Introduced by 5b302b3 in qwen38: load the checkpoint folder MTP draft in its stored formats #682.
  2. A route trace refused every all-card load. The trace is written by the host service, so a traced load keeps every layer's host leg. Both bodies (gpu-glm5next/src/body.rs and gpu/src/arch/qwen3moe/body38.rs) then built a CPU host view of every layer. NVFP4 expert stacks have no CPU kernel, and a checkpoint folder's header-only split has no bytes behind a host view, so HostRun::build refused the load. The rule for which layers get a view now lives in one place, HostRun::viewed in crates/gpu/src/host/run.rs: a layer that has experts off the card, or any layer when the residency machine runs. The trace no longer counts. A host leg kept for a card-resident layer sends an empty expert list, and HostRun::zero_sum writes its sum as zero without a view. Lists that carry experts, calls with the wrong column count and an out of the wrong size are still refused by name. The sum of an empty list was already zero with a view, so the output bits, the handoff and the graph and launch counts do not change. Introduced by 4390628 in placement, model, gpu, gpu-glm5next, gpu-gates: glm5next's card leg runs its routed stacks by its arms, NVFP4 in its planes and the 32-value downs included; the leg's buffers hold the forms its layers' downs read #651, 0bd19ed in gpu: Qwen3.8's step and verify skip the host leg on a layer the host serves nothing, and the hc norm loads a chunk before it uses it #45 and bf49c4f in gpu, model, refset: Qwen3.8 served from the NVIDIA NVFP4 checkpoint on one card, every routed expert on the card, against its pinned oracle #561.

The HostCfg::route_trace, CardExperts::hostless and BLOOMERY_ROUTE_TRACE registry texts now describe this behavior.

Code shape

  • No second copy. The view rule had the same predicate and comment in two bodies; it is one function now. The GLM gate built a trace header in three places; attach_trace is the one owner.
  • Model code holds only architecture facts. The two bodies call HostRun::viewed and gained no per-model branch.
  • Dead code is gone. The inline copies of the predicate and of the trace header are removed.
  • No silent failure. The MTP layer's refusal is kept and returned by name when BLOOMERY_DRAFT=mtp asks for the draft. Malformed zero_sum calls are named errors.
  • Comments state what is true now.
  • No relaxed gate. One GLM gate assertion said a trace load keeps host views, which is the mechanism of the defect, so it now asserts the opposite. The traced_rel band is unchanged.
  • cargo fmt is clean on what I touched, and the lint run below is clean. The lint warning count did not go up.

Duplication found or removed (path:line): the two view-selection predicates in body.rs and body38.rs, and the three trace-header blocks in gate_glm5next_e2e.rs.

What I ran

All runs are on head 5bf6f0a17, with base b9dfc4a74 for the FAIL-first runs.

Unit tests, with each fix undone in turn

Three unit tests cover the changed code. The first block is their output at head. Each test then runs with its fix put back to the old behavior:

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 30 filtered out; finished in 0.01s
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 382 filtered out; finished in 0.03s
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 20 filtered out; finished in 0.00s
  • a_target_opens_whatever_its_mtp_layer_holds opens a small Qwen3.8 folder with a BF16 MTP projection, an F32 one and none. With folder::open returning the MTP refusal again, the F32 layer refuses the target and the test stops:
test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 30 filtered out; finished in 0.00s
  • a_sparse_set_serves_its_layers_and_refuses_the_gaps_by_name calls the host run for a layer without a view. With zero_sum removed, the old refusal comes back and the test stops:
test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 382 filtered out; finished in 0.01s
  • a_folder_load_refuses_a_set_mtp_draft_and_turns_an_unset_one_off checks mtp, unset and off. With the layer's refusal dropped from the mtp error, the test stops:
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 20 filtered out; finished in 0.00s

GLM hostless gate, with the old body

gate_glm5next_e2e --only hostless opens an NVFP4 and a Q4_K fixture as traced loads and checks host views 0, a complete trace, every slot on the card and the plain load's logits. At head:

hostless: NVFP4 no_host_views=true traced_no_host_views=true trace_positions=Some(4) trace_on_card=true traced_rel=0.000e0 PASS
hostless: Q4_K no_host_views=true traced_no_host_views=true trace_positions=Some(4) trace_on_card=true traced_rel=0.000e0 PASS

With the base gpu-glm5next/src/body.rs over head:

hostless: Q4_K no_host_views=true traced_no_host_views=false trace_positions=Some(4) trace_on_card=true traced_rel=0.000e0 FAIL
gpu-gate.sh: gate_glm5next_e2e ran 0 s (exit 1)

The NVFP4 line under the old body reads: the route trace's load FAILED: HostRun::build: host union: the gate must map embd -> ff: every expert of blk.0.ffn_gate_exps.weight (nvfp4, k = 256): no fused qdot kernel for weight type NVFP4 in this build.

Real checkpoints

The NVFP4 gate opens the real Qwen3.8 NVFP4 checkpoint as a traced load and runs the batch set's ids:

just gate-gpu-qwen4exp-nvfp4
(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
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 553 s (exit 0)

Serving both Qwen3.8 model folders (FP4-Local and NVFP4), I started bloomery-serve once per arm, sent one greedy request and stopped it. With BLOOMERY_DRAFT=off, BLOOMERY_PREFILL=steps, BLOOMERY_ROUTE_TRACE and BLOOMERY_DRAFT=mtp, both folders load and answer. The traced runs write a trace of every slot on the card:

TRACE trace-fl: positions=61 layers=48 slot kinds=[67] every slot on the card=True PASS
TRACE trace-nv: positions=61 layers=48 slot kinds=[67] every slot on the card=True PASS

For FP4-Local the four arms return the same text. For NVFP4 the off and mtp arms agree with each other, and so do steps and the traced arm. The base binary gives the same off and steps texts as head on this request, so the split between the prompt path and the step path does not come from this change.

The base binary with the route trace set refuses both folders at load:

SERVE fl-trace-base refused rc=1
SERVE nv-trace-base refused rc=1

For the MTP case I moved the NVFP4 folder's mtp.fc_embedding.weight into an F32 shard. The base binary refuses it with the draft off. At head, off and unset serve the target and give the same text as the unmodified NVFP4 folder, and the unset arm records why the draft is off. BLOOMERY_DRAFT=mtp is refused with the layer's name:

SERVE cf-off-base refused rc=1
SERVE cf-off ready request_rc=0 sha=22109bfce0cfed0f
cf-unset log: load draft=off (unset: the checkpoint folder's MTP layer is not one the draft reads: its MTP layer: mtp.fc_hidden.weight: BF16 in a stack whose first source mtp.fc_embedding.weight is F32)
SERVE cf-mtp refused rc=1
cf-mtp log: bloomery-serve: BLOOMERY_DRAFT=mtp with a checkpoint folder whose MTP layer the draft does not read (its MTP layer: mtp.fc_hidden.weight: BF16 in a stack whose first source mtp.fc_embedding.weight is F32), or set BLOOMERY_DRAFT=off (unset, the draft goes off by itself)

Lint

EXPECT lint PASS (want PASS) ok

This is the workspace clippy run (BLOOMERY_BOX_LOCAL=1 just lint) with every feature.

Not run

gate_qwen4exp_e2e at the fixture tier did not run: its fixture oracle set for this model is not on the machine I used, and it stopped at start. I changed one assertion there (with every host leg kept, the host view count is n_layer - whole). The view count of the same traced load on the real checkpoint is covered by the (rt) line above. The GLM gate is a workstation-card gate, so I ran it on an RTX 5090 machine; a GB10 card refuses to start it.

Hardware

DGX Spark (GB10) and an RTX 5090 machine.

NVIDIA GB10, 595.84, CUDA 13.3.1
NVIDIA GeForce RTX 5090, 595.99.02

The CUDA version on the GB10 line is the toolkit in the build container.

What I ran into

This does not block the PR. A GLM-5.3 model folder looks to have the same shape as the Qwen3.8 MTP case: placed_map in crates/model-hf/src/arch/glm5next.rs refuses the whole folder when the quantization planner refuses any NextN tensor, though a folder load builds no NextN part. I read it but did not reproduce it, and this PR does not touch that file.

Release notes: Fixed: a Qwen3.8 model folder whose MTP layer the draft cannot read serves its target again, and a route trace no longer refuses all-card loads.

AI help

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

`folder::open` mapped and planned the folder's `mtp.` tensors before the
seat chose a draft, and returned their refusal as the folder's: a folder
whose MTP layer the draft does not read (an F32 input projection, say)
refused the server even with `BLOOMERY_DRAFT=off`.

The MTP layer is now prepared on its own (`folder::mtp`), and its refusal
is held in `Opened::draft` beside a target that opens as before. A layer
the preparation takes is then read by the draft's own reader
(`MtpInputs::read`), so a partial layer the preparation passes is caught
too, before the image seat reads the draft's word. The seat applies the
existing draft rule to either refusal: a set `mtp` is refused with it, an
unset draft goes off with `Draft38Off::FolderMtp`, and `off` stays as set.
…mputes

A load made for a route trace keeps every layer's host leg, because the
host service writes the trace. On Qwen3.8 and GLM-5.3 that also built a
host view of each layer whose experts all sit on the card, and the host
kernels refuse an NVFP4 stack, so an all-card NVFP4 load with
`BLOOMERY_ROUTE_TRACE` set was refused.

The host run now views a layer only where the host can compute its
experts: one with an expert off the card, or any layer under a residency
machine. The trace's service of a card-resident layer lists no expert,
and `HostRun` writes that empty sum as zeros without a view, for the
step and both union calls. A list that names an expert there is still
refused by name.

`gate_glm5next_e2e --only hostless` now opens the NVFP4 and the Q4_K
fixtures for a trace, writes it, and holds every slot on the card and
the plain load's logits. `gate_qwen4exp_nvfp4` adds (rt), the same on
the NVFP4 checkpoint, and `gate_qwen4exp_e2e`'s whole-card plan counts
the host views with every host leg kept.
@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 labels Oct 23, 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: No behavior defect or proven quality defect remains in the reviewed changes.

Non-blocking

⚠ Complete the dispatch proof: crates/gpu/src/host/run.rs:391 adds an empty-list check per host service: [derived] H checks per decoded token across H serviced layers for single-row decode.
Supply the move/split class's identical PTX proof (just canon-check BASE or equivalent scans) and the host dispatch path's same-lease base/head A/B required by AGENTS.md, at the reviewed commits.

Checked

Duplicates: 13 new functions/constants checked. The dryer pair at run.rs:436/463 serves different union policies; extracting its short wrappers adds elements. No qualifying duplicate remains. Gate helpers were also searched manually.

Complexity: traced is a new load/trace/compare pipeline. hostless and card_whole add coverage checks; run adds a gate call; Draft38Off::fmt adds one match arm. No kernel body changed.

Silent failure: 3 paths followed. MTP preparation and reader errors reach named refusals or draft-off reasons. Missing-view calls write zero only for empty lists with valid shapes; listed experts and malformed shapes return errors.

Tests: static inspection shows that propagating the MTP error at qwen35moe/folder.rs:156, dropping the reader refusal at serve_seats/qwen38.rs:963, removing the zero path at host/run.rs:391, or restoring traced views at body38.rs:1890 or gpu-glm5next/body.rs:1687 would fail the corresponding unit/gate assertions. Tests were not executed here.

Gates: the changed GLM host-view clause has a dated PIN and FAIL-first output; numeric bands are unchanged. No gate was removed.

Escape catalog: no C1–C4 pattern matched. Residency loads retain every host view; step services reject invalid layers and non-finite activations before the new zero path.

Notes

GPU evidence is incomplete: the reported runs name head 5bf6f0a17 and base b9dfc4a, rather than the reviewed commits, and omit the exact checkpoint path. The unavailable Qwen fixture run is explained in the PR body.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_glm5next_e2e.rs, crates/gpu-gates/src/bin/gate_qwen4exp_e2e.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 a69b486 into midagedev:main Oct 23, 2026
7 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant