Repository navigation
gpu: one SwiGLU epilogue writes the down's q8 blocks of 32 from the up GEMM of either family: Q4_K over a card route, Q8_0 planes over a dense block, NVFP4 planes as before - #1100
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: two gates now own the same card-join refusal checks.
Must fix
1. Keep card-join shape refusals in the common gate
card_slots.rs:1065 and q38_combine.rs:210 both test enqueue_card_join with zero tokens and a short output. Both reach the same slots_launch and short checks. This is kind B duplication under R14 and AGENTS' one-test-per-contract rule.
Remove the model-level copies now so future shape changes have one test owner. Keep the common hardware test, replace combine_refusals below, and update the refusal descriptions to locate those two cases in that common test.
pub(crate) fn combine_refusals(&mut self, c: &Ctx) -> Result<[CombineRefusal; 3], GateError> {
// PIN(2026-11-01): no_token and short output are covered by
// card_slots::tests::hw_the_card_sum_launchers_refuse_invalid_shapes.
let stream = c.gpu.stream();
let r_slot = self.q38.enqueue_card_shared_add(
stream,
CardSharedAddArgs {
hsum: &self.hsum,
acc: &self.acc,
sh: &self.sh,
w: &self.w,
slot: W_PITCH,
slots: W_PITCH,
n: N38,
m: M38,
fault: c.gpu.unlabelled_sink(),
y: &mut self.y,
},
);
let mut y = DeviceBuffer::from_host(stream, &vec![SENT; M38 * N38])?;
let rows = DownRows::F32(&self.y_down);
let mut gated = |gate| {
let shared = SharedJoin {
sh: &self.sh,
gate: Some(gate),
};
self.join(c, (rows, &self.sel, M38), Some(shared), &mut y)
};
let (r_routed_gate, r_gate_past) = (gated(SLOTS - 1), gated(W_PITCH));
let what = "card_sum_join";
Ok([
("q38::enqueue_card_shared_add", "slot_11_of_11", r_slot),
(what, "a_gate_among_the_routed_slots", r_routed_gate),
(what, "a_gate_past_the_pitch", r_gate_past),
])
}Non-blocking
⚠ PTX preservation proof: grouped.rs:1809 extracts the refused-slot store used by existing unfused entries into a macro arm. Supply just canon-check 39ed53b875a0811cdaf587dd19963da24a650c48 output for the unchanged entries. AGENTS' move/split class requires unchanged canonical code and resource columns; the reported spill gate does not establish both.
Checked
Duplicates: both refusal suites reach enqueue_card_join's same shape checks; deleting the model copies adds no owner.
Silent failure: zero tokens and a short output return named shape errors before dispatch.
Tests: the common gate checks error details and output preservation; the model caller checks the error identity.
Gates: the replacement keeps the shared-gate refusals and records why the duplicate cases are removed. PTX preservation remains an evidence request.
Escape catalog: C1–C4 do not match either finding. No ledger lessons are in force.
Notes
The GPU evidence names head 86fbcf95b7c60990bc74b16c1c4c12d1618d0dc0; this review covers 22dfb10d8a5ec90bfb1a036d46132e37161e2837. GPU gates were not rerun here.
Card check: gpu-evidence. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-gates/src/bin/gate_gemm.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)
22dfb10 to
cf3ce06
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed: duplicate zero-token and short-output refusal cases were removed from q38_combine.rs:191.
- Still open: PTX preservation evidence for grouped.rs:1809.
Verdict: CLEAN: the interdiff removes duplicate refusal checks while retaining their coverage in the common hardware test.
Non-blocking
⚠ PTX preservation proof: grouped.rs:1809 extracts the refused-slot store used by existing unfused entries. Supply just canon-check 39ed53b875a0811cdaf587dd19963da24a650c48 output for those entries. AGENTS' move/split class requires unchanged canonical code and resource columns; the reported spill gate establishes neither comparison.
Checked
Duplicates: 0 new items in the interdiff; three model-level cases removed. Dryer reports 0 pairs and excludes gpu/gpu-gates; the shared checks were traced manually.
Complexity: all 11 crapper targets are unchanged by the interdiff; the two edited refusal functions only lose cases.
Silent failure: 0 new suppression sites. All three removed refusal paths still return named Shape errors through slots_launch or short, including ten slots at a weights pitch of eleven.
Tests: static mutation analysis shows that removing the zero-size, short-weights or short-output guard fails the common test's expected Shape-error assertions. Both shared-gate refusal cases remain checked. The common test runs through gate-gpu-lib.
Gates: no bands move. Removed cases have dated PIN reasons naming the remaining test owner.
Escape catalog: C1–C4 do not match the interdiff.
Notes
GPU evidence names head 86fbcf95b7c60990bc74b16c1c4c12d1618d0dc0; the reviewed head is cf3ce06. CUDA gates were not rerun here.
Card check: gpu-evidence. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-gates/src/bin/gate_gemm.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)
…mon launch, its slots, pitch and gate as data
…or every down type, which the card sum's join reads; the route's form moves to placement::kernels
…p GEMM of either family: Q4_K over a card route, Q8_0 planes over a dense block, NVFP4 planes as before
cf3ce06 to
702ea21
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed: duplicate refusal cases remain removed; their common owner is named at q38_combine.rs:192.
- Still open: PTX preservation evidence for grouped.rs:1809.
Verdict: CLEAN: the interdiff removes an unused model-tax allowance without changing runtime behavior or gate coverage.
Non-blocking
⚠ PTX preservation proof: grouped.rs:1809 extracts the refused-slot store used by existing unfused entries, including gemm_q4k. Supply just canon-check 39ed53b875a0811cdaf587dd19963da24a650c48 output for those entries. AGENTS' move/split class requires unchanged canonical code and resource columns; the reported spill gate does not establish that comparison.
Checked
Duplicates: 0 new items in the interdiff. Dryer reports 0 pairs and excludes gpu/gpu-gates; those patches are unchanged.
Complexity: all 11 crapper targets are unchanged by the interdiff; no new function or branch growth.
Silent failure: 0 new suppression sites. A model name without an allowance remains a check failure.
Tests: no tests changed in the interdiff. Static checks confirm the removed allowance has no code uses. Previous refusal-guard mutation results still apply; CUDA gates were not rerun here.
Gates: the DeepSeek allowance for gate_kquant falls from one to zero; the sole remaining token match is a doc comment. No runtime gate or tolerance changes.
Escape catalog: C1–C4 do not match. A further check confirmed that deleting the allowance does not exempt the file from the ratchet.
Card check: gpu-evidence. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-gates/src/bin/gate_gemm.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)
|
The review is done and the contribution check passed, so I'm merging this. |
Qwen3.8 전용이던 카드 합산 결합, BF16 down 행, SwiGLU 에필로그를 공용 owner로 옮겼고, UD-Q4_K_XL 프리필이 5.4% 빨라졌으며 다른 arm의 손실은 없습니다.
What and why
The Qwen3.8 card route kept three pieces of its own code that other models need too: the card sum joined with the shared expert (
q38_card_sum_shared_add{,_bf16}inq38.rs), the BF16 down rows its join reads (NVFP4 downs only), and the NVFP4-only fusion of the up GEMM with SwiGLU and the q8 quantizer. GLM-5.3 ran the same join as two launches. This PR moves each piece to a shared owner:card_slots::CardSlotKernels::enqueue_card_join(card_sum_join,card_sum_join_bf16) sums the card slots and adds the shared expert's gated output in one launch. The slot count, the weight pitch and the shared gate column are data (CardJoin,SharedJoin). Qwen3.8's wide prefill walk and decode card leg call it, and so does GLM-5.3's one-card shadow, prompt program and tensor-parallel rank, which drops one launch per card layer. The fused Qwen3.8 kernels andCardSumSharedAddArgsare removed.Gemm32Kernels::enqueue_gemm32_bf16takes every 32-value stack (new twinsgemm_q8_0f_bf16,gemm_q5_1_bf16,gemm_q5_0p_bf16,gemm_iq4nl_bf16). The route's form,RouteForm::{Rows, Native}, moves toplacement::kernels, andqwen35moe/place.rskeeps only its byte constants.gemm/swiglu32.rsholds the device body that writes the down's q8 blocks of 32 from the up GEMM's tile. Both GEMM families use it:gemm_nvfp4p_swiglu(now on the common body),gemm_q4k_swiglu(grouped, card slots), andgemm_q8_0p_swiglu_allandgemm_q8_0p_slab_swiglu_all(dense, every slot).enqueue_up_swiglu32picks the entry of the up's type and slot set, and otherwise runs the up GEMM and the split quantizer as before. Callers: the card route batch,card_leg::RouteBlock,site::gatedand Qwen3.8's tier path. A new up type is one entry and one match arm.The fold and the join are bit-equal to the launches they replace. The plan's route bytes are unchanged, and the BF16 down rows keep the rule they had (a load whose every layer runs without the host leg).
On UD-Q4_K_XL at C=1, prefill moves +5.40% and TTFT p95 +5.10% (table in What I ran). No other arm loses.
Release notes: Changed: UD-Q4_K_XL prompt processing on Qwen3.8 is about 5% faster, and the card sum, BF16 down rows and SwiGLU epilogue are shared by every model.
Code shape
card_slots.rs,gemm32.rs,swiglu32.rs), and both GEMM families' blocks call the oneswiglu32!body. Qwen3.8's fused sum kernels and GLM-5.3's separate sum-then-add pair are replaced by the join.qwen35moe/place.rskeeps its two byte constants; the form enum lives inplacement::kernels. The common owners gained no per-model branch.q38_card_sum_shared_add{,_bf16},CardSumSharedAddArgsand the per-model route-run type are removed.no_tokenandshort_outputare cases of one shared shape test incard_slots.rs, anda_gate_among_the_routed_slotsanda_gate_past_the_pitchare gate cases).PIN(2026-11-01)rows in the spill table (gemm_q4k_swiglu208 B,gemm_q8_0p_slab_swiglu_all8 B), measured on the card. The new PTX shape rows carry the same pin.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none":q38_card_sum_shared_addandq38_card_sum_shared_add_bf16incrates/gpu/src/q38.rs(removed); theenqueue_card_accpluselem().enqueue_addpair incrates/gpu-glm5next/src/ffn.rs(replaced by the join).What I ran
Every check below ran on a DGX Spark. The card line is from:
The
nvidia-smibanner readsNVIDIA-SMI 595.84 Driver Version: 595.84 CUDA Version: 13.3, andbash tools/arch.shprintssm_121a. The upstream base is39ed53b875a0811cdaf587dd19963da24a650c48and the PR head is702ea214c65d5b0ad1682339454d26378a10a1b1.Host check:
It exits 0.
cargo test -p bloomery-placement --lib ffnpasses 2 tests andcargo test -p bloomery-model --lib qwen35moe::placepasses 40.FAIL-first. Each mutation below turns the gate red, and the gate passes with the mutation reverted. The mutations swap the epilogue's gate and up (
swiglu32.rs), skip quantizing the grouped walk's refused slot (grouped.rs), drop the min term from the Q5_1 BF16 down store (kernels32.rs), and make the ten-slot join sum nine slots (card_slots.rs):Gates on the changed kernels (
gate_gemmcases rebuilt first, then each case):The user-facing binary, built with the release feature set and started on each Qwen3.8 file:
UD-Q4_K_XL loaded in 20.2 s, NVFP4 in 19.6 s and FP4-Local in 16.9 s. All three answered the short prompt with
' Paris. The capital of Germany is Berlin. The capital of Italy is Rome. The capital of Spain is Madrid. The'. Each also answered a 4,701-token prompt (160 numbered copies of one sentence and a request to summarize them,n_predict48) coherently, for example FP4-Local:'\n\n<think>\nThe user wants me to summarize the farming pattern described across all 160 paragraphs (which are all identical) in one sentence. ...'.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:
Each side is built in its own checkout (
baseorhead):The server for the C=1 arms, with
MODELset 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:Each request is a
POST /completionwhose prompt is 4,096 token ids from a fixed window of a token-id corpus (code-fn, SHA-2567520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1; prose-en,d10c7044df8884fdd200304604772d81a4b56a228f802d5f05db724b245ef77a), withn_predict128. The C=1 arms send one request at a time on code-fn at temperature 0. The C=2 arm sends two at once on code-fn and on prose-en at temperature 0.7 with seed 42. Each arm times eight windows 50,000 ids apart after two warm-up windows. Prefill and decode tok/s come from the server's timings, TTFT p95 and total tok/s from the client clock. Each cell is the median of three rounds with their range in parentheses. A positive change is faster:The gain is the UD-Q4_K_XL prompt, which runs the Q4_K routed and Q8_0 shared GEMMs through the new epilogue. The C=2 arm is sampled and this PR does not change the decode step of FP4-Local or NVFP4 (their routed layers keep the existing fused kernel), so I do not count its decode rows as a gain. Greedy UD-Q4_K_XL output first differs from the base at token 42 of the first code-fn request; the e2e gates hold their bands.
Hardware (if the change is for a machine)
NVIDIA GB10 (DGX Spark), driver 595.84, CUDA 13.3, arch sm_121a. Models:
UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf(SHA-2564448186216b3af4cc558bbce2c3213f01608f8f8b2e5267a9767971dd3ec8082)model.safetensors.index.json660414e8300728ba80062e6a3c81cb76a65e2ab136ac9e9ceb450ba0c51c3c0d)model.safetensors.index.json5fa166bbb1cf25adda455117563efa72a2072272001f459eedece131ffc913e1)AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.