fix: restore ROCm Q8 prequantized decode kernels - #640
Closed
Scorp1o117 wants to merge 1 commit into
Closed
Conversation
ef8d923 (Add ROCm GLM 5.2 support) dropped the prequantized integer (Q8xQ8 dp4a) decode fast paths from the ROCm backend, leaving only fp32 dequant matmuls for single-token decode. On DeepSeek-V4-Flash IQ2XXS this halves decode throughput: 15 t/s -> 8.4 t/s on Strix Halo (gfx1151). Restore the four preq decode paths, guarded by !g_quality_mode to preserve the historical q8_prequant_decode semantics (quality mode keeps the fp32 path for numeric precision): - matmul_q8_0_preq_rows_w32_kernel (single Q8 decode) - matmul_q8_0_pair_preq_warp8_kernel (paired projections) - matmul_q8_0_hc_expand_preq_rows_w32_kernel (HC expand) - grouped_q8_0_a_preq_warp8_kernel (attention output projection) fp32 paths kept as fallback. Bench (DS4 IQ2XXS, ROCm 7.14, gfx1151, ctx 2048, 128 gen): 8.44 -> 15.03 t/s (old baseline 14.97); real chat 16.63 t/s, first-token latency 120ms -> 68ms.
|
I think I have these already in this PR: #623. I'm just checking if anything is missing. |
Author
|
Thanks for the heads-up, kyuz0! We independently bisected this to the same root cause —
Your #623 is more complete: model-family guard so GLM is untouched, |
Author
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.
Summary
Restore the ROCm Q8 prequantized decode kernels that were dropped by
ef8d923("Add ROCm GLM 5.2 support"). On DeepSeek-V4-Flash IQ2XXS this regression halves decode throughput: ~15 t/s → 8.4 t/s on Strix Halo (gfx1151, ROCm 7.14). All four restored kernels already exist inrocm/ds4_rocm_q8.cuh; this PR only reconnects their call sites (2 files, +155 lines, pure additions).Root cause
ef8d923refactored the ROCm matmul/attention code and removed the prequantized integer (Q8xQ8 + dp4a) single-token decode paths, leaving only fp32 dequant matmuls:Q8_0 weights cover the every-token decode path of DeepSeek (attention projections, shared experts, output projection — AProjQ8/SExpQ8/OutQ8 in the IQ2XXS layout), while prefill (n_tok>1, batch kernels) is unaffected — matching the observed profile: prefill ~150 t/s unchanged, decode halved.
Bisect evidence (same machine, same ROCm 7.14, same model file, only code version changed;
ds4-bench --ctx-start 2048 --ctx-max 2048 --gen-tokens 64-128):(Commits #45–#50 in between fail to compile on the ROCm path — no CI coverage for ROCm — and were skipped per bisect rules; ef8d923 is the first compilable bad commit.)
Changes
Restored four preq decode call sites, all guarded by
!g_quality_modeto preserve the historicalq8_prequant_decode = !g_quality_modesemantics (quality mode keeps the fp32 path for numeric precision):cuda_matmul_q8_0_tensor_labeled—matmul_q8_0_preq_rows_w32_kernel(rows_per_block: quality 8 / normal 1, matching oldq8_decode_rpb)ds4_gpu_matmul_q8_0_pair_tensor—matmul_q8_0_pair_preq_warp8_kernelcuda_matmul_q8_0_hc_expand_tensor_labeled—matmul_q8_0_hc_expand_preq_rows_w32_kernel(rows_per_block: quality 8 / normal 16, matching oldq8_hc_decode_rpb)ds4_gpu_attention_output_low_q8_tensor—grouped_q8_0_a_preq_warp8_kernel(rows_per_block: quality 8 / normal 32, matching oldattn_out_low_decode_rpb)Each preq block keeps the existing fp32 path as fallback (tmp alloc or launch failure → falls through to fp32; strictly more robust than the old hard-fail behavior). Prefill/batch paths and GLM paths are untouched.
Verification
Benchmark: DeepSeek-V4-Flash IQ2XXS (
...-imatrix-0731.gguf, 80.8GB), ROCm 7.14, gfx1151, ctx=2048, 128 gen tokens, full residency:Real chat smoke test:
ds4 --rocm -m <model> -p "..." -n 32→ 16.63 t/s, first-token latency 120 ms → 68 ms, output correct, no errors.Other:
make rocm -j32clean;ds4-eval --self-test-extractorspasses. Note: the fullmake testsuite requires CUDA tooling ($(NVCC), Makefile:247) and cannot run on a ROCm-only host — pre-existing environment limitation, unrelated to this change.Notes for reviewers
rocm/ds4_rocm_q8.cuh); only call sites are restored.q8_decode_rpb/attn_out_low_decode_rpb/q8_hc_decode_rpbas runtime config (this PR uses equivalent hardcoded defaults) and adding a ROCm compile check to CI — six commits between 7/12 and 7/18 currently fail to compile on the ROCm path.