Skip to content

perf(hip): read Qwen GDN recurrent state directly from indexed bank - #4

Merged
bryanwieg merged 1 commit into
rx9070-portfrom
perf/indexed-gdn-state-port
Sep 19, 2026
Merged

bryanwieg merged 1 commit into
rx9070-portfrom
perf/indexed-gdn-state-port

Conversation

@bryanwieg

Copy link
Copy Markdown
Owner

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.

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
bryanwieg force-pushed the perf/indexed-gdn-state-port branch from 0c1b96a to 0e9baec Compare September 19, 2026 04:05
@bryanwieg
bryanwieg marked this pull request as ready for review September 19, 2026 22:31
@bryanwieg
bryanwieg merged commit 6fe5c50 into rx9070-port Sep 19, 2026
12 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant