Skip to content

qwen38: read NVFP4 PLE planes from a checkpoint folder - #660

Merged
juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fp4local
Oct 22, 2026
Merged

juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fp4local

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 FP4-Local 체크포인트 폴더를 분할 파일로 바꾸지 않고 그대로 불러올 수 있게, 값과 스케일이 따로 저장된 NVFP4 PLE 행을 폴더에서 직접 읽습니다.

Part of #565.

What and why

A Qwen3.8 FP4-Local checkpoint folder now loads with -m <folder>, without first being prepared into a split. The folder stores its per-layer embedding (PLE) table, per_layer_token_embd.weight, as NVFP4 rows in two planes: the 4-bit codes (80 B for a 160-value row) and the block scales (10 B). A folder load used to read only F8 PLE rows, so it refused this table with (nvfp4_rows) is stored in another layout: prepare the folder into a split.

This PR reads both planes where the checkpoint stores them. The existing row table and prefetcher gather the two planes. One decoder and one rounding rule serve the packed rows of a split and the separate planes of a folder, so a row decodes to the same bits from either layout. The folder normalizer and the folder reader share one ModelOpt metadata check for these rows, and the refusals for a wrong width, row count or scale are kept.

The planner keeps a PLE table read from a checkpoint folder on NVMe, even when the unified memory pool could hold it, the same way it treats a split's NVMe table. A host-resident copy would keep that memory for the whole run. Its page-cache reserve counts both planes, since one row read touches a page of the code plane and a page of the scale plane. Ordinary, node-assigned and multi-slot plans all go through one row placement owner. A mapped split keeps its room-dependent placement, and a hand-written Host plan for a folder table still gets its named OnCard/PleHost error.

Release notes: Added: A Qwen3.8 FP4-Local checkpoint folder loads directly, with its NVFP4 PLE table read from the folder's value and scale planes.

Code shape

  • No second copy. The folder reader, RunTable, the prefetcher and the NVFP4 group decoder are the existing ones. The packed and the separate layout share one decoder and one metadata check.
  • Model code holds only architecture facts. The Qwen folder reader names the PLE source ranges. The plane layout and the placement policy live in the common model, GGUF and placement code.
  • Dead code is gone. The blanket refusal of stored NVFP4 rows is replaced by plane support. The old alignment and scale refusals moved into group_count and decode_groups and still fire.
  • No silent failure. Short planes, wrong widths, row totals and invalid scales fail with named errors.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint level moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line): none. Ten new items (the plane descriptor, the row-table list, the shared scale check, the plane decoder, the backing getter and the source placement entry among them) were checked against the existing owners.

What I ran

Head 4aaaff7d1, base main c80347607. Its four commits rebase e8f660b1f without changing their diffs (git range-diff shows all four as equal). On e8f660b1f, cargo check --workspace --all-targets builds every crate (Finished dev profile [unoptimized + debuginfo] target(s) in 26.92s), and the placement, model and folder tests pass: test result: ok. 175 passed, test result: ok. 24 passed and the folder test a_table_s_rows_are_read_where_the_folder_stores_them ... ok. cargo test -p bloomery-model --test qwen4exp_mtp_reserve gives test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s on an earlier head of the same commits. That result and the GPU results below ran before two later changes, both in the planner only: the page-cache reserve that now counts both PLE planes, and one placement entry point that takes the row source. Neither touches the reader, the decoder or the device path.

On an NVIDIA GB10 (a DGX Spark), CUDA toolkit 13.3.1:

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

Unit tests:

  • A test written before the reader fails on the old refusal: cargo test -p bloomery-model-hf --lib a_table_s_rows_are_read_where_the_folder_stores_them gives test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 28 filtered out; finished in 0.00s on main's reader.
  • cargo test -p bloomery-hf --lib modelopt::tests gives test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 73 filtered out; finished in 0.11s, and cargo test -p bloomery-model-hf --lib arch::qwen35moe::folder::tests gives test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 28 filtered out; finished in 0.00s.
  • cargo test -p bloomery-gguf --lib nvfp4_rows gives test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 48 filtered out; finished in 0.00s. They cover the separate-plane decode and its refusals.
  • cargo test -p bloomery-placement --lib gives test result: ok. 174 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 11.48s. Its row-room test pins the reserve of a PLE table at 4,096 positions, 16 rows per position and 4,096-byte pages: (RowTableSource::Split, 536_870_912) for a split's packed rows and (RowTableSource::Parts, 1_073_741_824) for a folder's two planes. A case whose code row crosses a page boundary failed on the packed count before the change.
  • cargo test -p bloomery-model --lib arch::qwen35moe::place::tests:: gives test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 440 filtered out; finished in 0.02s. The planner-entry test an_f8_ple_table_and_its_scale_describe is one of them. It checks the exact NVMe reserve for ordinary, node-assigned and multi-slot plans and the room-dependent mapped split.

The owning GPU gates, run on the Spark itself (BLOOMERY_BOX_LOCAL=1); for the second one BLOOMERY_REF_MODEL names the FP4-Local checkpoint folder, so the gate loads the folder:

just gate-gpu-ple
gate_ple: 21 clauses, 0 failed
gpu-gate.sh: gate_ple ran 11 s (exit 0)

just gate-gpu-qwen4exp-nvfp4
(l) load resident_bytes=78139375436 ctx=3072 layers=48 in 236.9 s (runtime value)
(p) the batch set by one pass: last argmax ours=11751 oracle=11751 logits_rel=1.658e-1 (printed) PASS
(t) hf-qwen4exp-nvfp4/hf_qwen4exp_nvfp4_d3k: position 3000 after 3000 ids by ubatches (7.0 s, runtime value); argmax ours=423 oracle=423 (its runner-up 11222, margin 1.6376, our distance at the two 1.4640); logits_rel 2.095e-1
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 261 s (exit 0)

The second gate compares the folder load with the pinned transformers reference of the checkpoint (hf-qwen4exp-nvfp4): the last argmax of the one-pass batch and the token at position 3000 equal the reference's.

Folder load against the reference Result
one-pass batch, last argmax ours 11751, reference 11751
position 3000 after 3000 ids, argmax ours 423, reference 423

Difference from the reference: none in the checked argmaxes.

GPU crate tests, with the build of bloomery-serve for sm_121 in the same run:

bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- arch::qwen3moe::body38::tests:: --nocapture
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 369 filtered out; finished in 0.00s

One of the five, a_folder_s_stored_rows_decode_as_the_split_s, checks that the stored planes and the packed rows give equal bits.

Real checkpoint nvidia/Qwen3.8-Flash-Next-FP4-Local (revision b9ce18a6), loaded from the original folder with bloomery-serve -m <folder> and no intermediate GGUF. Four 4096-token windows, two code and two English prose, give 48 greedy tokens each, and the text equals what the same checkpoint prepared into a split gives:

intermediate_gguf_files=0
PASS: folder = pin split oracle on four 4096-token windows, 48 greedy tokens each

Folder against split, 4K prompt, one request at a time (C@1), on the same card. Each arm loads once and serves two identical requests. All four outputs equal the saved reference output. The folder arm runs this branch, and the split arm runs #649 on the same checkpoint prepared into a split as stored.

Setup, 4K C@1 Server prompt time (s) Prefill (tok/s) Decode (tok/s)
#649 + split as stored 8.051 / 7.881 508.78 / 519.71 27.68 / 27.78
this branch + original folder 8.193 / 7.924 499.96 / 516.91 27.51 / 27.84

There is no measurable difference in this short run. The PR adds a way to load the original folder, and it makes no speed claim. Conditions: the code-fn corpus at offset 0, 4096 input IDs, 48 greedy output tokens, context 4224, draft off, --cache-ram 0, cache_prompt=false. Every response reports 4096 prompt tokens, 48 output tokens and zero cached tokens. Both arms set BLOOMERY_HOST_ROOM=96G, because a mapped split's automatic placement would otherwise hold the PLE table on the host. At that setting both arms read PLE from NVMe and keep every routed expert on the card, and the folder arm's plan has no resident host table.

What I ran into

This does not block the PR. A separate-plane row has the same logical payload as a packed 90 B row, but its two reads may cost a different amount of page I/O on NVMe. The short run above shows no difference in speed, and I did not measure per-read cost. I measured nothing on two DGX Sparks. The loader this PR extends is the one the GLM FP4-Local folder load already uses, and no rank count, kernel or GLM behavior changes here.

Hardware (if the change is for a machine)

An NVIDIA DGX Spark (GB10), with the nvidia-smi lines above.

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 22, 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 reachable behavior defect or proven quality defect was found.

Non-blocking

⚠ Verify the final planner revision: crates/model/src/arch/qwen35moe/place.rs:394.
The PR reports that its GPU runs precede the final reserve and placement changes. Run just gate-gpu-qwen4exp-nvfp4 against the checkpoint folder at the final head and attach its output. This exercises the changed planner through a GPU load.

Checked

Duplicates: 10 new items checked; no duplicate owner found. Dryer reported 0 pairs. GPU owners were checked by Grep.

Complexity: nvfp4_rows_scale (new, 19) extracts metadata validation. ple_rows (13→21) and PleHost::new (28→33) add layout validation; fill_spanned (12→16) adds plane dispatch. Each retains one job.

Silent failure: 3 refusal paths followed: plane shape/count, invalid scales, and helper I/O. Each returns a named error to its caller.

Tests, static mutation check: crates/gguf/src/quant.rs:1131 swap nibbles; crates/gguf/src/quant.rs:1079 remove the short-scale check; crates/model-hf/src/arch/qwen35moe/folder.rs:244 omit a run; crates/gpu/src/arch/qwen3moe/body38.rs:582 submit only one plane; crates/model/src/arch/qwen35moe/place.rs:394 force Split; crates/placement/src/placement.rs:2886 count one plane; crates/placement/src/placement/nodes.rs:1528 omit serial fill latency. Each mutant fails a changed test's assertion or success requirement. Other test edits update signatures or fixtures.

Gates: no band, threshold, or lint level moved. The reader's FAIL-first result is in the PR body.

Adversarial checks: truncated planes, invalid scales, empty fills, and interrupted prefetches are blocked by validation, error propagation, or draining the pending job.

Escape catalog: no C1–C4 pattern matched.

Notes

No builds or tests were run during this review.

Card check: gpu-evidence. This pull request changes crates/gpu/src/arch/qwen3moe/body38.rs and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 22, 2026
@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 5e6e9bc into midagedev:main Oct 22, 2026
6 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 gpu-evidence Verified on the author's card: the pull request carries the gate run and its output 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 placement Placement planning: crates/placement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant