perf(hip): read Qwen GDN recurrent state directly from indexed bank - #4
Merged
Merged
Conversation
Rebase the indexed recurrent-state optimization onto the current rx9070-port after the arena-trim compile fixes from PR #6. The normal recurrent graph gathers the selected persistent GDN state row into a packed scratch tensor before every fused gated-delta-net invocation. With GGML_ROCM_GDN_INDEXED_STATE=single-v1, the qualified RX 9070 path instead passes the persistent F32 state bank plus a dynamic I32 row selector directly to GGML_OP_GATED_DELTA_NET_INDEXED. The HIP kernel reads the selected bank row on device, avoiding the GET_ROWS state gather while preserving the ordinary GDN output and snapshot writeback path. The optimization remains default-off and deliberately narrow: - HIP RDNA4 backend - one sequence and one recurrent-state selection - Qwen35 geometry S_v=128, H_v=48, H_k=16 - K=3 (n_rs_seq=2), 1..3 tokens - F32 contiguous ordinary device state bank - fused autoregressive/chunked GDN enabled A backend capability query prevents the model graph from assuming that an arbitrary GPU buffer supports this operation. An explicit state-dependency input preserves zero-initialization ordering. CPU execution is implemented for correctness/fallback; non-qualified shapes retain the existing graph. Historical RX 9070 / Windows ROCm evidence measured 24-46% reduction in the target GDN state-access component and about +3.2% mean end-to-end decode in one ABBA run (OFF 53.863/51.978 vs ON 54.500/54.692 t/s), with matching outputs and speculative token counts. The original investigation also noted run-to-run drift, so this port does not claim a universal TPS gain until it is re-benchmarked on current upstream. This port excludes the later direct-write fusion WIP, graph-capture diagnostics, snapshot-copy experiments, and all ROCmFPX quantization code. Source: 21edd46f773765db02bbae1d480bc68d1ed97115
bryanwieg
force-pushed
the
perf/indexed-gdn-state-port
branch
from
September 19, 2026 04:05
0c1b96a to
0e9baec
Compare
bryanwieg
marked this pull request as ready for review
September 19, 2026 22:31
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.
Draft upstream-native port of historical commit
21edd46f773765db02bbae1d480bc68d1ed97115.This is intentionally broader than the first three ports because it adds a GGML op and touches CPU/HIP execution plus the Qwen35 graph. It should be compile- and correctness-tested before merge.
Enable with
GGML_ROCM_GDN_INDEXED_STATE=single-v1.The later direct-write fusion WIP (
6f688e7a...) is explicitly excluded.