feat(rocm): grouped + non-grouped keep-quant expert GEMM — the MoE-path terminus (issue #41) - #523
Draft
VikashLoomba wants to merge 2 commits into
Draft
feat(rocm): grouped + non-grouped keep-quant expert GEMM — the MoE-path terminus (issue #41)#523VikashLoomba wants to merge 2 commits into
VikashLoomba wants to merge 2 commits into
Conversation
…mbineGate) (mudler#41) The next links in the generic MoE path after the router/silu-mul. Hand- translated from cuda_moe.cu (MoeCombineKernel :473, MoeCombineGateKernel :555) and the SharedExpertGate CPU oracle (cpu_ops.cpp:2387). Grid-stride, f32 math, bf16/f32 dtype arms via boundary conversions; the combine-gate folds the shared-expert sigmoid gate rounded through bf16 exactly as the donor. Evidence (4x gfx1100, ROCm 7.14, Release): - new MoE combine/gate cross-device case: 9/9 assertions (MoeCombineGate's oracle is the host-computed composite — no CPU op registration exists) - ctest -R 'rocm|cross_device': 4/4 - full ctest: pre-existing failure set shrinks 7 -> 5; test_bench and test_capi now PASS (they failed at op 77 / the router dtype before the chain). test_loaded_engine_dense now fails only on the async-scheduling assertion (a lane capability gap, not a kernel throw). - Named remaining blocker: the grouped quant expert GEMM (kMatmulBTQuantGrouped), the DeepSeek-V4 keep-quant family. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: pi:kimi-k3 [pi]
…ant, kMatmulBTQuantGrouped) — the MoE-path terminus (mudler#41) The last kernel blocker for GDN-MoE models on discrete ROCm. Ports the cuda_quant_dot.cu grouped + plain keep-quant GEMMs (QuantDotGemmGroupedKernel :746 / QuantDotGemmKernel :706 / the Q8_0 + Q8_K activation quantizers) and the DotQ8_0 / DotQ4K / DotQ5K / DotQ6K superblocks 1:1. Registers kMatmulBTQuant (op 74) + kMatmulBTQuantGrouped (op 75) — registering the non-grouped op flips GgufQuantComputeAvailable() so the keep-quant path actually activates on ROCm. Integer dot cores via a portable Dp4a (bit-identical to __dp4a); the HW dot instruction is a named perf lever. Evidence (4x gfx1100, ROCm 7.14, Release): - cross-device grouped-quant case: 16/16 (Q8_0/Q4_K/Q5_K/Q6_K, valid random blocks + real f32 activations, NMSE <= 5e-4 vs the CPU keep-quant oracle) - ctest -R 'rocm|cross_device': 4/4; full ctest: the 5 pre-existing host/lane failures only (test_bench + test_capi pass since the MoE chain). - E2E: Qwen3.6-35B-A3B Q4_K_M (21GB GDN-MoE GGUF) runs end to end on one gfx1100 with keep-quant active — ops 74 AND 75 resolve vt-native, zero CPU-ref fallback, correct output. Needs --max-num-seqs 1 to fit one 24GB card (the GDN state pool otherwise pushes past; residency note, not a kernel defect). A backend-Alloc instrumentation run confirmed the OOM was cumulative ~23.8 GiB = genuine capacity, not a kernel bug. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: pi:kimi-k3 [pi]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Row
BACKEND-ROCM— the last kernel blocker for MoE-bearing models on discrete ROCm. Issue #41. Stacked on #509 (MoE combine/gate chain).What changed
NEW
src/vt/rocm/rocm_grouped_gemm.hip— ports the keep-quant expert GEMM family fromcuda_quant_dot.cu1:1:kMatmulBTQuant(op 74, non-grouped) +kMatmulBTQuantGrouped(op 75, grouped overexpert_ids)DotQ8_0/DotQ4K/DotQ5K/DotQ6Ksuperblocks,__dp4a→ portableDp4a(bit-identical integer core),__shfl_down_syncreductionGgufQuantComputeAvailable()on ROCm — the grouped op alone leaves the loader dequantizing experts to bf16.Cross-device case: all four formats vs the CPU keep-quant oracle, valid random blocks + real activations.
Evidence (4× gfx1100, ROCm 7.14, Release)
ctest -R 'rocm|cross_device': 4/4; full ctest: only the 5 pre-existing host/lane failures (zero new)vt-native, zero CPU-ref fallback, correct output. Requires--max-num-seqs 1to fit one 24GB card (the GDN state pool otherwise pushes past — a residency note, not a kernel defect; confirmed via a backend-Alloc instrumentation run showing genuine cumulative ~23.8 GiB).Speed claims
Honest gaps
hipMalloc/hipFreeactivation scratch is correctness-grade; a queue-owned grow-only pool is a perf lever (decode-step churn).--max-num-seqs 1on 24GB; multi-GPU expert sharding or host streaming is the follow-on for bigger MoE / longer context.