Repository navigation
qwen38: the plan counts a native FP4 card route by the bytes it holds - #1033
juliankang4 merged 2 commits into
Conversation
…planes Qwen3.8's card route reads its run's normed rows in the native FP4 form alone when one native launch runs the gate, the up and the SwiGLU (every card layer NVFP4 on a native FP4 build). Its input scratch still allocated the 32-value Q8 planes, which the input quantizer then skipped and no reader took: 3,200 B a column at K = 2,560, 6,553,600 B at a run of 2,048 tokens. GemmAct32::new_native_input makes that scratch with the native form and empty Q8 planes (GemmAct32::new's scratch on a build without the native products or at K not a multiple of 64). Every launch that stores the Q8 planes takes its shape from GemmAct32::quant_launch, which now refuses such a scratch by name; the input quantizer, which stores them only where the scratch holds them, takes the same shape without that check.
A card-experts machine counted the ubatch walk's card route at 170,360 B a run token, the q8_1 input form and the gate and up f32 rows. A load whose card layers run the gate, the up and the SwiGLU as one native FP4 launch holds neither: its input is the native FP4 form alone (1,444 B a column at K = 2,560) and it writes no gate or up rows, so the plan held back 54,628 B a run token that no buffer took (111,878,144 B at a run of 2,048 tokens), and the card's experts, cache and slots could not use them. place::RouteForm names the two forms, and PlanInputs::route_form reads a load's from the file and the build: Native where every routed stack of the file's layers is NVFP4 on a build with the native FP4 products, which every card layer then runs fused. place::machine_for_route counts the card route in that form (115,732 B a run token in Native; machine_for_experts keeps Rows), and widen_card_route and card_route_run size and check the whole-ubatch run's reserve in it. The Qwen3.8 seat, generate_qwen3moe, the gates' shared open and the load itself read the form the same way, so the reserve a plan widens by is the one the load reads back.
There was a problem hiding this comment.
Verdict: CLEAN: The changed allocation and placement paths agree, and invalid Q8 consumers receive named errors.
Non-blocking
⚠ Complete the verification evidence: crates/gpu/src/gemm/act32.rs:301. The unchanged-speed claim uses model placeholders and revisions other than the reviewed base/head. Supply the exact model files, the card/driver nvidia-smi line, and commands with output tied to both revisions. This makes the measurements reproducible.
Checked
- Duplicates: 9 new named items checked; no duplicate owner found. Dryer reported 0 pairs.
- Complexity:
CardRoute38::newgrew from 27 to 28 through one allocation-selection branch; no separate responsibility was added. - Silent failure: 3 paths followed. Q8-writing quantizers, Q8 readers, and invalid route reserves return named errors.
- Tests, source-level mutation check:
hw_native_activation_planesprotects crates/gpu/src/gemm/act32.rs:301 and crates/gpu/src/gemm/act32.rs:396; restoring Q8 allocation or deleting refusal makes assertions fail. - Tests, source-level mutation check:
a_card_route_is_counted_in_its_files_formprotects crates/model/src/arch/qwen35moe/place.rs:556; dropping the layer filter or native-build condition makes assertions fail. - Tests, source-level mutation check:
the_card_route_runs_the_whole_ubatch_where_nothing_moves_for_itprotects crates/model/src/arch/qwen35moe/place.rs:1453; using the Rows rate for Native fails the reserve assertions. - Gates: no tolerance or existing pin moved. Reported FAIL-first results cover the allocation, refusal, and format-selection changes.
- Adversarial checks: mixed formats, non-native builds, empty Q8 planes, and ubatches around 2,048 are blocked by format checks or named errors. The final bounds check found constructor validation for zero columns and invalid K.
- Performance: allocation changes occur at load time; launch counts and float reduction order are unchanged.
- Escape catalog: no C1–C4 pattern matched.
Notes
Static review only; builds and card gates were not rerun.
Dryer did not scan crates/gpu or crates/gpu-gates; these changes were checked by grep.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs, crates/gpu-gates/src/bin/shared/qwen38_open.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)
|
The review is done and the contribution check passed, so I'm merging this. |
native FP4로만 읽는 routed 입력이 Q8 buffer를 더는 잡지 않고, placement도 실제 할당 바이트대로 세게 합니다.
What and why
On the Qwen3.8 native FP4 card route, the gate and up input is read only in its native FP4 form. It still allocated the Q8 planes and the plan still counted the old f32 row scratch for it.
GemmAct32::new_native_inputnow holds the native form only, andCardRoute38::newuses it for the fused route. A launch that writes Q8 planes refuses a scratch that has none, by name. On the plan side,RouteForm { Rows, Native }makes the card route scratch follow the file's form:Nativewhen the build is native FP4 and every routed stack in the file's layers is NVFP4, otherwiseRowsas before. Load, the shared open, the serve seat and the two gate binaries read the same form, so the reserve the plan widens is the reserve the load checks.Speed is unchanged (the base and head ranges overlap, see below). The change moves the planned card bytes, so more of a card's memory is left for the KV cache.
Release notes: Changed: the Qwen3.8 native FP4 card route no longer allocates Q8 planes for its input, and the plan counts the route by the bytes it holds.
Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none":native_input_onlyincrates/gpu/src/gemm/act32.rsis removed;new_native_inputreplaces it.What I ran
A/B of the built server binary on a DGX Spark, base
b4e02387against head49400131, one A/B per model (Qwen3.8-Flash-Next-FP4-Local and Qwen3.8-Flash-Next-NVFP4). The load uses a 4,096-id prompt and 128 generated tokens, 8 windows, three timed rounds per revision, temperature 0.Bytes the plan and the load hold, from the server log of one load per revision:
need bytesresident_bytesmem_leftneed bytesresident_bytesmem_leftThe planned reduction is the same for both models.
Speed, medians of three rounds (tok/s):
Every metric's ranges overlap, and
greedy_equal: True(the greedy output is identical).Tests and gates on commit
be0d8765(BLOOMERY_BOX_LOCAL=1, DGX Spark):The last gate ran on both model folders; both exit 0. The NVFP4 folder prints the same PASS lines, ending with
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 54 s (exit 0).New tests fail without the change. On
49400131, removing the layer filter inroute_formfailsa_card_route_is_counted_in_its_files_formwithleft: (Rows, Rows)andright: (Native, Rows), and removing the build condition fails it withleft: (Native, Native)andright: (Native, Rows). With the native input allocating its Q8 planes,hw_native_activation_planesfails withleft: 840andright: 280. With the Q8 refusal removed it fails atnvfp4mma.rs:2574.Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.