Skip to content

gpu, placement, qwen38: every dense site of the wide walk runs its wide GEMM, its rows holding only the forms their sites read - #1080

Merged
juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-dense-site
Nov 1, 2026
Merged

juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-dense-site

Conversation

@juliankang4

@juliankang4 juliankang4 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Qwen3.8 전용으로 남아 있던 dense site 처리(형식별 chunk 경로, activation 형식 선택, norm gate 선택)를 공용 owner로 옮겼습니다. 다음 모델은 이 코드를 따로 쓰지 않아도 되며, 판정 arm에서 손실은 없습니다.

What and why

The Qwen3.8 wide prefill walk carried its own code for the dense sites. It had a by-name chunk path for K-quant and NVFP4 projections in wide38.rs, with act_with, project_chunks, reads_q8_1 and wide_in. Its inputs held every quantized form whatever the sites read, and a sigmoid-only norm entry served it. The next model with dense sites on GGUF, NVFP4 or FP4-Local files would have had to write the same again. This PR moves each piece into a shared owner, so a new model's walk calls these owners and writes none of it:

  1. Dense projection: every dense site of the wide walk calls site::gemm, whatever its type. A K-quant site reads q8_1 blocks of 128 on the grouped GEMM, and an NVFP4 site reads q8 blocks of 32 on the 32-value GEMM. The shared expert goes through site::gated. The chunk path in wide38.rs is removed, and so is the ubatch arena's by-name state that served it.
  2. Activation forms: site::DenseActs and site::resident_wants hold only the forms the sites read. The load and the plan count the same bytes through one rule, placement::kernels::wide_act_bytes, which reads kernels::attention::Forms, reached through PlanInputs::stack(). place_hybrid and the Nemotron-H plan now call gemm_act32_bytes, which replaces their own copies of the formula.
  3. Norm gate: the gated norm takes the model's gate as data (GdnGate). Qwen3.6 uses SiLU; Qwen3.8 and GLM-5.3-Flash KDA use sigmoid. That replaces the per-gate entry enqueue_norm_gate_sigmoid. The BF16 and MXFP8 product epilogues finish only a sigmoid-gated norm, so they refuse SiLU by name.
  4. Product store: the Q8_0 plane (and slab), K-quant (Q3_K, Q4_K, Q5_K, Q6_K, IQ4_XS) and Q8 NVFP4 GEMMs store BF16 through one cell rule shared by both GEMM families (f32tile::ProductCell: the identity for f32, round to nearest even for BF16). Every format's q/k/v now gets the BF16 rows that only FP4-Local had.
  5. Norm output form: on a site without a product epilogue, the gated norm writes its readers' q8 form itself (gdn_norm_gate_q32, gdn_norm_gate_q128). It calls the existing norm_gate_body and quantizer cores after a warp gather, so the bytes, refusals and fault are the quantizer's.

The grouped and 32-value GEMMs keep their own sum order. A K-quant or NVFP4 prompt column is therefore no longer bit for bit the decode step's one-column launch. The prompt matches the decode within the e2e gate's bands, as the FP4-Local path already did. The plan of a real file counts its own forms. The recorded fixture budget and the qwen4exp_meta pins keep the q8-32 count they were recorded with, named as Stack::q8_blocks32.

No arm of the A/B loses (table in What I ran). UD-Q4_K_XL prefill also moved +1.49%, and TTFT p95 moved +1.46%, at C=1.

Release notes: Under the hood: the dense sites of the Qwen3.8 prompt walk run through shared owners for every file format, with no speed loss.

Code shape

  • No second copy. The new BF16 entries are thin calls of each family's existing body macro, and the store is one cell rule. The norm's q8 entries call the existing norm_gate_body and the existing quantizer cores (act32::quant32_group, q8_1_quant_vals). The form byte rule has one owner, placement::kernels, which model::fit, place, place_hybrid and the Nemotron-H plan read. The Q8_0 plane checks are one helper, Gemm32Kernels::q8_0p_entry.
  • Model code holds only architecture facts. Qwen3.8 code names only its gate (plan38::GDN_GATE). wide38.rs lost its chunked fallback.
  • Dead code is gone. act_with, project_chunks, reads_q8_1, wide_in and the ByName use in wide38.rs, and enqueue_norm_gate_sigmoid, are removed.
  • No silent failure. A missing q8_1 scratch is a named state error, a SiLU gate into an epilogue is refused by name, and a norm form of the wrong K or columns or without Q8 planes is refused by name. A type with no BF16 entry is refused by name with the output untouched.
  • Comments state what is true now.
  • No relaxed gate. UBATCH_TOKEN_BYTES moves from 120,889 to 109,209 with a PIN; the 11,680 B left the arena for the counted forms. The unsafe ratchet adds the norm entries' blocks with a PIN. The new PTX shape rows carry a PIN.
  • 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": the chunked by-name fallback in crates/gpu/src/arch/qwen3moe/wide38.rs (removed); the two norm-gate entries per gate in crates/gpu/src/linear/norm_gate.rs (now one enqueue dispatching on the gate).

What I ran

Every check ran on a DGX Spark. The gate runs print this line from nvidia-smi --query-gpu=name,driver_version,compute_cap --format=csv,noheader:

NVIDIA GB10, 595.84, 12.1

bash tools/arch.sh prints sm_121a, and the toolkit is CUDA 13.3. Each block below names the commit it ran on; all of them are commits of this branch.

FAIL-first, on head a574ed15a, with the BF16 cell rule truncating instead of rounding and the norm's q8 words written without the lane gather:

export BLOOMERY_BOX_LOCAL=1
sed -i 's/        cuda_device::convert::f32_to_bf16_rne(v)$/        (v.to_bits() >> 16) as u16/' crates/gpu/src/gemm/f32tile.rs
sed -i 's/        let src = ((4 \* lane + j) \& 31) as u32;/        let src = lane as u32;/' crates/gpu/src/linear/norm_gate.rs
./tools/box.sh "cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features gpu --release --bin gate_gemm"
./tools/box.sh "BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case bf16_store"
./tools/box.sh "BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case g32_slab"
./tools/box.sh "BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case norm_form"

All three cases exit 1. bf16_store prints 10 FAIL lines (every dense K-quant line), g32_slab 6 and norm_form 8. The first of each:

# gate_gemm --case bf16_store
gpu-gate.sh: gate_gemm ran 21 s (exit 1)
GPU GATE RED: gate_gemm (exit 1)
gemm32 case=bf16_store ty=Q3K m=7 rows=320 K=2048 dense_site=true FAIL
# gate_gemm --case g32_slab
gemm32 case=g32_slab K=2560 m=16 rows=4112 grid=33 entry=gemm_q8_0p entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=false unwritten=0 checked=65792 worst_err_over_band=0.056 band_off=0 contract_bits_differ=0 y_fnv=256df6760857058e FAIL
# gate_gemm --case norm_form
gemm32 case=norm_form gate=Silu m=1 n_v=32 nan=false rows_eq=true q32_eq_quantizer=false q128_eq_quantizer=false fault_ok=true FAIL

Gates on head a574ed15a (base 6791d577b), after git checkout of the two files and a rebuild of gate_gemm:

for c in bf16_store g32_slab nvfp4_native norm_form zgate; do
  ./tools/box.sh "BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case $c"
done
just gate-gpu-linear
just gate-ptx-spill
BLOOMERY_TIER=fixture just gate-gpu-qwen4exp-e2e
BLOOMERY_TIER=fixture just gate-gpu-qwen38-serve
BLOOMERY_TIER=real BLOOMERY_CARD_ALL_EXPERTS=1 BLOOMERY_REF_MODEL="$NVFP4_DIR" just gate-gpu-qwen4exp-nvfp4

bf16_store checks the five dense K-quant types at 7 and 300 columns: each BF16 row equals the F32 store rounded to nearest even, bit for bit. IQ3_XXS has no BF16 entry and is refused by name. g32_slab passes 13 lines and nvfp4_native 51, with no FAIL line; every nvfp4_native line has bf16_eq=true. zgate passes 28 lines. The output (the ptx-spill list of nonzero entries is cut here):

# gate_gemm --case bf16_store
gpu-gate.sh: gate_gemm ran 22 s (exit 0)
gemm32 case=bf16_store ty=Q3K m=7 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q3K m=300 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q4K m=7 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q4K m=300 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q5K m=7 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q5K m=300 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q6K m=7 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Q6K m=300 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Iq4Xs m=7 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Iq4Xs m=300 rows=320 K=2048 dense_site=true PASS
gemm32 case=bf16_store ty=Iq3Xxs m=7 rows=320 K=2048 dense_site=false PASS
gemm32 case=bf16_store ty=Iq3Xxs m=300 rows=320 K=2048 dense_site=false PASS
# gate_gemm --case g32_slab
gpu-gate.sh: gate_gemm ran 1 s (exit 0)
gemm32 case=g32_slab K=2560 m=16 rows=4112 grid=33 entry=gemm_q8_0p entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=65792 worst_err_over_band=0.056 band_off=0 contract_bits_differ=0 y_fnv=256df6760857058e PASS
gemm32 case=g32_slab K=2560 m=65 rows=4112 grid=66 entry=gemm_q8_0p entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=267280 worst_err_over_band=0.071 band_off=0 contract_bits_differ=0 y_fnv=8af9d8d4c394d283 PASS
gemm32 case=g32_slab K=2560 m=1100 rows=4112 grid=594 entry=gemm_q8_0p_slab entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=1130800 worst_err_over_band=0.077 band_off=0 contract_bits_differ=0 y_fnv=9521145de741e977 PASS
gemm32 case=g32_slab K=2592 m=16 rows=4112 grid=33 entry=gemm_q8_0p entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=65792 worst_err_over_band=0.060 band_off=0 contract_bits_differ=0 y_fnv=886af2dc789c238c PASS
gemm32 case=g32_slab K=2592 m=65 rows=4112 grid=66 entry=gemm_q8_0p entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=267280 worst_err_over_band=0.071 band_off=0 contract_bits_differ=0 y_fnv=9c8f676e2af435aa PASS
gemm32 case=g32_slab K=2592 m=1100 rows=4112 grid=594 entry=gemm_q8_0p_slab entry_ok=true act_eq_host=true decode_vs_ggml=true bf16_eq_f32_rne=true unwritten=0 checked=1130800 worst_err_over_band=0.085 band_off=0 contract_bits_differ=0 y_fnv=1beb2efa95ae3d60 PASS
# gate_gemm --case nvfp4_native (the first of 51 lines)
gpu-gate.sh: gate_gemm ran 1 s (exit 0)
gemm32 case=nvfp4_native rows=16 slots=14 k=128 input=Pattern fused=false native=true q8_eq=true producer_eq=true bf16_eq=true wrong=0 guard=true eager_graph_eq=true hash=84a59ace36b2db65 PASS
# gate_gemm --case norm_form
gpu-gate.sh: gate_gemm ran 1 s (exit 0)
gemm32 case=norm_form gate=Silu m=1 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=9 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=512 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=9 n_v=32 nan=true rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=1 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=9 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=512 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=9 n_v=32 nan=true rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
# gate_gemm --case zgate
gpu-gate.sh: gate_gemm ran 5 s (exit 0)
# just gate-gpu-linear
gate_linear: 196 clauses, 0 failed — PASS
gpu-gate.sh: gate_linear ran 13 s (exit 0)
# just gate-ptx-spill
ptx-spill bin=generate_ds41 entries=521 pinned=521 nonzero=... violations=0 PASS
ptx-spill bin=gate_qwen3vl_tower entries=26 pinned=26 nonzero=none violations=0 PASS
# BLOOMERY_TIER=fixture just gate-gpu-qwen4exp-e2e
clauses: 27 ran, 9 left to the real tier
gpu-gate.sh: gate_qwen4exp_e2e ran 450 s (exit 0)
# BLOOMERY_TIER=fixture just gate-gpu-qwen38-serve (three runs)
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 230 s (exit 0)
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 44 s (exit 0)
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 38 s (exit 0)
# BLOOMERY_TIER=real ... just gate-gpu-qwen4exp-nvfp4
transform: 92 admitted experts, 0 parts differ from a static load: PASS
gpu-gate.sh: gate_qwen4exp_nvfp4 ran 108 s (exit 0)

The Qwen3.8 e2e gate also ran on head 993bf33df (base 28bc0af4b). Its forced arm holds the stores and the last logits within their bands:

BLOOMERY_TIER=fixture just gate-gpu-qwen4exp-e2e
gemm forced: last argmax ours=34727 (returned 34727) ik=not compared in this tier; last logits' distance from the pass's 1.829e-2 (band 5.143e-2) PASS
gemm forced: every layer's store within its band, past it at []; PLE ring 1.227e-3 (band 4.454e-2) PASS
clauses: 27 ran, 9 left to the real tier
gpu-gate.sh: gate_qwen4exp_e2e ran 437 s (exit 0)

norm_form also ran on commit e4856df2, which holds this change. Its last line is the native FP4 form, refused by name with the output kept:

./tools/box.sh "cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features gpu --release --bin gate_gemm"
./tools/box.sh "BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case norm_form"
NVIDIA GB10, 595.84, 12.1
gemm32 case=norm_form gate=Silu m=1 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=9 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=512 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Silu m=9 n_v=32 nan=true rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=1 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=9 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=512 n_v=32 nan=false rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form gate=Sigmoid m=9 n_v=32 nan=true rows_eq=true q32_eq_quantizer=true q128_eq_quantizer=true fault_ok=true PASS
gemm32 case=norm_form native=true m=9 n_v=32 refused=true kept=true PASS
gpu-gate.sh: gate_gemm ran 0 s (exit 0)

Host tests on head a574ed15a: bloomery-placement lib (225 passed, including a_wide_input_holds_the_forms_its_readers_read), bloomery-model arch::qwen35moe (112 passed), bloomery-gpu lib site wide38 norm_gate act32 (22 passed).

The user-facing binary on head a574ed15a, built with the release feature set and started on each of the three Qwen3.8 files:

cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve
./target/release/bloomery-serve -m "$MODEL" --host 127.0.0.1 --port 18741 --ctx-size 16896
curl -s -X POST http://127.0.0.1:18741/completion -H 'Content-Type: application/json' \
  --data '{"prompt":"The capital of France is","n_predict":24,"temperature":0,"cache_prompt":false}'

UD-Q4_K_XL loaded in 20.4 s, NVFP4 in 23.9 s and FP4-Local in 16.9 s. All three answered the short prompt with ' Paris. The capital of Germany is Berlin. ...'. Each also answered a 4,701-token prompt (160 numbered copies of one sentence and a request to summarize them, n_predict 48) coherently.

Speed, TP=1, P=4096, K=128, three rounds per side on one GB10, base and head built and timed in the same run. The A/B runs print:

NVIDIA GB10, 595.84
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |

Each side is built in its own checkout (base or head):

(cd head && cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve)

The server for the C=1 arms, with MODEL set to the UD-Q4_K_XL first shard, the NVFP4 folder or the FP4-Local folder (Hardware below), and for the FP4-Local MTP C=2 arm:

env BLOOMERY_DRAFT=off BLOOMERY_HOST_ROOM=96G ./head/target/release/bloomery-serve -m "${MODEL}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896
env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 2 --ctx-size 16896

Each request is a streamed POST /completion whose prompt is 4,096 token ids from a fixed window of a token-id corpus (code-fn, SHA-256 7520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1; prose-en, d10c7044df8884fdd200304604772d81a4b56a228f802d5f05db724b245ef77a):

{"prompt": [4096 token ids], "n_predict": 128, "cache_prompt": false, "stream": true, "timings_per_token": true, "return_tokens": true, "temperature": 0, "top_k": 1}

The C=1 arms send one request at a time on code-fn. The C=2 arm sends two at once on code-fn and on prose-en, with "temperature": 0.7 and seed 42 for the first request and 43 for the second. Prefill and decode tok/s come from the server's timings, and TTFT p95 and total tok/s from the client clock. Each cell is the median of the three rounds, with their range in parentheses. A positive change is faster for every metric, TTFT included.

C=1, head a574ed15a against base 6791d577b:

metric base head change ranges overlap
UD-Q4_K_XL C=1 prefill tok/s 1671.70 (1666.34 to 1673.14) 1696.60 (1693.00 to 1696.96) +1.49% no
UD-Q4_K_XL C=1 TTFT p95 ms 2455.24 (2453.73 to 2463.11) 2419.30 (2418.56 to 2424.10) +1.46% no
UD-Q4_K_XL C=1 decode tok/s 30.85 (30.77 to 30.98) 31.02 (30.77 to 31.07) +0.57% yes
FP4-Local C=1 prefill tok/s 2904.86 (2889.37 to 2915.41) 2909.36 (2894.37 to 2909.75) +0.15% yes
FP4-Local C=1 TTFT p95 ms 1415.04 (1410.28 to 1422.62) 1412.93 (1412.91 to 1419.98) +0.15% yes
FP4-Local C=1 decode tok/s 31.69 (31.60 to 31.90) 31.63 (31.60 to 31.69) -0.20% yes
NVFP4 C=1 prefill tok/s 2591.72 (2570.93 to 2597.26) 2593.63 (2590.09 to 2598.93) +0.07% yes
NVFP4 C=1 TTFT p95 ms 1585.69 (1582.13 to 1598.16) 1584.70 (1581.58 to 1587.06) +0.06% yes
NVFP4 C=1 decode tok/s 22.95 (22.86 to 23.03) 22.88 (22.88 to 23.03) -0.33% yes

FP4-Local MTP C=2, head dd1ad10e9 against base 1397a0baf:

metric base head change ranges overlap
FP4-Local MTP C=2 code-fn decode tok/s 31.62 (31.22 to 31.81) 32.63 (32.21 to 32.69) +3.21% no
FP4-Local MTP C=2 code-fn prefill tok/s 2658.80 (2657.31 to 2663.90) 2665.31 (2662.15 to 2667.50) +0.24% yes
FP4-Local MTP C=2 code-fn TTFT p95 ms 3141.67 (3124.42 to 3141.71) 3125.22 (3122.07 to 3130.53) +0.52% yes
FP4-Local MTP C=2 code-fn total tok/s 46.47 (46.30 to 46.65) 50.24 (46.41 to 51.07) +8.12% yes
FP4-Local MTP C=2 prose-en decode tok/s 26.24 (25.43 to 26.75) 26.91 (26.80 to 27.04) +2.56% no
FP4-Local MTP C=2 prose-en prefill tok/s 2718.05 (2712.84 to 2718.94) 2705.85 (2700.59 to 2715.37) -0.45% yes
FP4-Local MTP C=2 prose-en TTFT p95 ms 3060.62 (3042.87 to 3063.85) 3075.68 (3054.51 to 3080.59) -0.49% yes
FP4-Local MTP C=2 prose-en total tok/s 40.51 (40.28 to 41.31) 41.52 (40.14 to 43.12) +2.49% yes

The C=2 arm is sampled and this PR does not change the decode step, so I do not count its decode rows as a gain. Greedy UD-Q4_K_XL output first differs at token 42 of one request. The likely cause is the BF16 qkv rows that GGUF now shares with FP4-Local; the e2e gate holds its bands.

Hardware (if the change is for a machine)

NVIDIA GB10 (DGX Spark), driver 595.84, CUDA 13.3, arch sm_121a. Models:

repository revision file
unsloth/Qwen3.8-Flash-Next-GGUF 766911a6b7369840a91dbcd95f9f997acaab6cd6 UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf (SHA-256 4448186216b3af4cc558bbce2c3213f01608f8f8b2e5267a9767971dd3ec8082)
nvidia/Qwen3.8-Flash-Next-NVFP4 fc694b54fb0174e0913e6adf86691ef85a4ead47 the folder
nvidia/Qwen3.8-Flash-Next-FP4-Local b9ce18a6887e18c089fdea8509a33e63429a3300 the folder

AI help

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

…de GEMM, its rows holding only the forms their sites read

A K-quant site reads the rows' q8_1 blocks of 128 on the grouped GEMM and an
NVFP4 site the q8 blocks of 32 on the 32-value GEMM, one launch a projection
in place of the by-name chunks of eight columns; the shared expert's three
sites go through site::gated whatever their types. site::DenseActs holds a
wide input's q8_1 blocks only when a K-quant site reads them, its q8 blocks of
32 only when a Q8_0, Q5_0 or NVFP4 site does, and room for the MMA forms its
sites copy. placement::kernels::wide_act_bytes is the one rule of those
bytes; PlanInputs::stack counts them by the file's dense types and a machine
holds them beside the ubatch walk's other rows.
…; the product epilogues refuse a SiLU gate by name

NormGateArgs and NormGateTail carry a GdnGate (SiLU for Qwen3.5/3.6, sigmoid
for Qwen3.8 and KDA), one enqueue_norm_gate picks the entry by it, and
site::resident_gemm_norm_gate runs a SiLU-gated norm apart from the product,
so a SiLU-gated model's z projection reads the same common site.
A dense site whose consumer reads BF16 rows (the delta layer's qkv, the
attention projections) took an F32 product and a separate conversion on
every arm except BF16 and native NVFP4. The Q8_0 plane (and its slab
entry), the five K-quant types a dense site reads and the Q8 NVFP4 entry
now each have a BF16 twin that differs only in the output type; the store
and the refused-NaN store of both GEMM families go through one cell rule
(f32tile::ProductCell: the identity for f32, round to nearest even for
u16), so the three families share one epilogue.

GemmKernels::enqueue_gemm_bf16 and Gemm32Kernels::enqueue_gemm32_bf16
launch them; another weight type is refused by name. site::gemm takes the
BF16 output on every one of these arms.

gate_gemm checks each BF16 store against the F32 product of the same
weights and columns rounded to nearest even, with the guard past the cells
untouched: bf16_store over a synthetic stack of each K-quant type (IQ3_XXS
refused by name), the Q8_0 plane and slab entries in g32_slab, and the Q8
NVFP4 product in nvfp4_native, which previously required it to be refused.
The model-free cases run under their own filters.
…aunch

On a site without a product epilogue, the gated norm wrote its f32 rows
and a second launch quantized them for the output projection. The norm
now has two entries that also store each token's row in the form its
readers take: gdn_norm_gate_q32 (q8 blocks of 32, one head a group of four
blocks, act32::quant32_group) and gdn_norm_gate_q128 (q8_1 blocks of 128,
one head a block, q8_1_quant_vals), under either gate. The warp gathers
its values into the quantizers' lane geometry, so the bytes, refusals and
fault are those of the quantizer over the stored row.

NormGateKernels::enqueue_norm_gate_into takes the form (NormOut);
site::resident_gemm_norm_gate uses it when the readers take one q8 form
and no MMA or native FP4 form, and keeps the norm then resident_quantize
otherwise.

gate_gemm norm_form: the rows and both forms bit-equal to the norm then
the quantizer under SiLU and sigmoid at 1, 9 and 512 tokens, and a head
holding a NaN refused alike with the fault raised.
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app 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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Nov 1, 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 must-fix findings remain.

Non-blocking

⚠ Complete the numeric-change evidence: crates/gpu/src/arch/qwen3moe/wide38.rs:2460.
K-quant q/k/v now reach the BF16 product store before convolution. The precision-change class requires an owning e2e count pin and timed A/B evidence. The PR provides gate summaries, timing tables and a server startup command, but omits the measurement commands and their output. Attach those logs, the model file paths and the raw nvidia-smi line, and identify how the tested commits correspond to this head. This makes the reported token divergence and speed comparison independently assessable.

Checked

Confirmed the removed q8_1 bypass in wide38.rs and traced resident_gemm_bf16 through the K-quant BF16 dispatch in site.rs to its convolution consumer. Checked the evidence request against the base contracts and PR body. The reviewer instructions classify missing performance proof as non-blocking. No escape-catalog pattern or ledger lesson applies to this finding.

Notes

Static validation only; no Rust build or GPU gate run. The reported measurements were not independently reproduced.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_gemm.rs, crates/gpu-gates/src/bin/gate_linear.rs, crates/gpu-gates/src/bin/gate_nvtier.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 e4856df into midagedev:main Nov 1, 2026
7 checks passed
@midagedev

Copy link
Copy Markdown
Owner

After this PR, gate-gpu-qwen4exp-e2e with BLOOMERY_FIXTURE_VARIANT=q38dense (fixture tier) is red on main. It was green at the parent 153bbc5 and red at 7391b34, both run on our RTX A6000:

card leg plan: 4 of 4 layers hold routed experts on the card, a layer's count Some(256)..Some(256) (want 256 ...) PASS   # 153bbc51d
card leg plan: 4 of 4 layers hold routed experts on the card, a layer's count Some(252)..Some(253) (want 256 on every layer: half the experts, the header's budget) FAIL   # 7391b3491

This is the case your budget_machine doc already names: the load now plans with PlanInputs::stack, and the recorded budget still uses Stack::q8_blocks32. The q38dense regeneration needed the db517b69 oracle tree, which was not public. It is now (#935). If it helps, we can run the regeneration on our box. Tell us which you prefer.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@juliankang4

juliankang4 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

@midagedev Thanks for catching this. It is ours: the recorded budget in the q38dense header still comes from Stack::q8_blocks32 while the load now plans with PlanInputs::stack, so the header asks for 256 experts a layer that the plan no longer fits. I'll fix the budget at its source and regenerate the q38dense sets here with the db517b69 tree, then run gate-gpu-qwen4exp-e2e with BLOOMERY_FIXTURE_VARIANT=q38dense on our cards. The PR will reference this comment.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The fix is up in #1093. The recorded card budget in the Qwen fixture now plans with the load's own activation stack, so q38dense holds 256 routed experts a layer again (card leg plan: 4 of 4 layers hold routed experts on the card, a layer's count Some(256)..Some(256)).

The five q38dense sets are regenerated with the db517b69 tree (CPU build, AMD Ryzen 9 9950X), and just gate-gpu-qwen4exp-e2e with BLOOMERY_FIXTURE_VARIANT=q38dense passes on our card. crates/model/tests/qwen4exp_meta.rs:272 is a real-tier pin that needs a re-pin from just gate-qwen4exp-meta on the real model; #1093 leaves it as it is.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

This is merged as 547a846 (#1093), so main plans the q38dense card budget with the load's activation stack again and carries the regenerated sets.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

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 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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants