Repository navigation
cuda: enable fused TQ3_1S mul_mat on HIP (gfx1100) — the disable is CUDA-only - #283
Merged
TheTom merged 1 commit intoAug 13, 2026
Merged
Conversation
The tq3_1s_fused_disabled guard was root-caused and confirmed only on CUDA0 (DeepSeek-V4): a reduction-order/cancellation sensitivity that is hardware- specific and does not reproduce on RDNA3. Gate it to non-HIP so gfx1100 uses the fused mmvq-tq path instead of dequant+hipBLAS. Coherent, PPL-neutral (5.6999 vs 5.7037 +/- 0.113), +33% decode. TQ3_FUSE_OFF=1 forces the dequant path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
ggml_cuda_mul_matunconditionally setstq3_1s_fused_disabledfor TQ3_1S weights, routing every TQ3_1S mul_mat to the dequant → cuBLAS fallback instead of the fusedmmvq-tqkernel. Per the comment, this was root-caused and confirmed only on CUDA0 (DeepSeek-V4): a reduction-order / cancellation sensitivity in the fused kernel's per-lane accumulation that compounds (~2%/layer) into incoherent generation on real weight/activation distributions.That failure mode is specific to the CUDA warp reduction. RDNA3 (wavefront-32) is a different FP-accumulation regime and was never tested. On gfx1100 / RX 7900 XTX, ROCm 7.2.3 the fused kernel is correct:
Coherence — full-inference output is coherent. A greedy A/B (fused vs. the verified dequant path, temp 0) diverges only via the expected butterfly effect of a sub-noise numerical difference; both paths stay sensible for the whole generation.
Perplexity (Qwen3.6-35B-A3B TQ4-opt, wikitext-2,
-ctk q8_0 -ctv turbo4 -fa on):PPL = 5.6999 ± 0.113PPL = 5.7037 ± 0.113Identical within error (Δ ≈ 0.004, ~30× under the error bar; fused-on is if anything marginally lower).
Speed — +33% decode (9.9 → 13.2 tok/s) by staying on the fused path rather than dequant → hipBLAS, on a mixed TQ3_1S / TQ4_1S + q8_0 model.
So the disable is over-conservative for HIP. This gates it to non-HIP (
#if defined(GGML_USE_HIP)), leaves CUDA behavior untouched, and keeps aTQ3_FUSE_OFF=1env escape hatch so the dequant path is one env var away if a future gfx target does trip it.