rocm: implement the two DSpark kernels so --dspark can draft on gfx1151 (fixes #597) - #670
Open
zom-2018 wants to merge 1 commit into
Open
rocm: implement the two DSpark kernels so --dspark can draft on gfx1151 (fixes #597)#670zom-2018 wants to merge 1 commit into
zom-2018 wants to merge 1 commit into
Conversation
…ero-draft) Port the two CUDA-only DSpark kernels to ROCm so the speculative path actually drafts on Strix Halo: - dspark_markov_argmax_kernel + ds4_gpu_dspark_markov_argmax_tensor (rocm/ds4_rocm_indexer.cuh): on-device markov-chain argmax over the vocab with q8_0 w1/w2 rows, same monotonic-key atomicMax tie-break. - attention_noncausal_raw_batch_heads_kernel + ds4_gpu_attention_noncausal_raw_batch_heads_tensor (rocm/ds4_rocm_attention_launch.cuh): non-causal batch attention over the raw KV ring for draft blocks, incl. DS4_DSPARK_VERIFY_NONCAUSAL host oracle (first 3 launches). - drop both ROCM_UNAVAILABLE stubs. Previously the engine probe failed on ROCm (unavailable stubs), so --dspark entered the propose path but emitted proposed=0 every cycle. (cherry picked from commit d3c8e665f62d41d384145e4b5f807b93048bd058)
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
Fixes #597 — "DSpark never produces a draft on ROCm / gfx1151".
Root cause: the DSpark engine path in
ds4.cis backend-shared, but two GPUkernels it needs existed only in
ds4_cuda.cu. ROCm builds resolved themthrough
ROCM_UNAVAILABLE_INTstubs inds4_rocm_unavailable.cu, so thesession probe always failed and every propose cycle ended with
proposed=0.This PR implements both kernels for ROCm (HIP) and removes the two stubs:
dspark_markov_argmax_kernel+ds4_gpu_dspark_markov_argmax_tensor(
rocm/ds4_rocm_indexer.cuh): on-device markov-chain argmax over the vocabwith q8_0 w1/w2 rows — direct port of the CUDA kernel, same monotonic-key
atomicMaxtie-break.attention_noncausal_raw_batch_heads_kernel+ds4_gpu_attention_noncausal_raw_batch_heads_tensor(
rocm/ds4_rocm_attention_launch.cuh): non-causal batch attention over theraw KV ring for draft blocks — direct port, same one-block
max/denominator/value accumulation order; keeps the
DS4_DSPARK_VERIFY_NONCAUSALhost-side oracle for the first 3 launches.Signatures match the existing declarations in
ds4_gpu.h; no other files aretouched.
Scope / safety
--dsparkis used (the kernels are only reachedthrough the DSpark propose/verify path).
Measured on AMD Strix Halo (Ryzen AI Max+ 395, Radeon 8060S gfx1151), ROCm 7.2
Before (upstream):
proposed=0every cycle (exactly the #597 symptom).After,
--dspark-confidence 0.3, 300 generated tokens, DeepSeek-V4-Flash-0731abliterated GGUF (80.76 GiB) + its DSpark support drafter:
At the default
--dspark-confidence 0.9the adaptive scheduler staysconservative:
proposed=21, accept_rate=90.5%.Wall-clock is currently break-even on this bandwidth-bound APU (the 6-row
target verify costs ~4–5x a single decode pass, dominated by routed-expert
weight reads), so this is not a speedup claim — it makes DSpark functional
on ROCm, which is the precondition for any follow-up verify-path optimization.
Testing
make strix-haloclean (gfx1151).--dspark+DS4_DSPARK_STATS=1: drafts proposed,verified and accepted; coherent output; stats counters advance.
--dspark: unchanged behavior.