mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #365] HIP: use RDNA4 matrix kernels for EXL3 prefill by default #492
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#492
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/365
Author: @LostVector
Created: 10/22/2026
Status: 🔄 Open
Base:
main← Head:upstream/rdna4-exl3📝 Commits (4)
be736e1HIP: add opt-in RDNA4 compressed EXL3 matrix prefill278dd3edocs: guide RDNA4 EXL3 matrix-prefill setup and verification85e4dfaHIP: default to RDNA4 EXL3 matrix prefill and explain rounding contract7016e3bExpose grouped WMMA selection for tests without changing CUDA-only prompt planning📊 Changes
6 files changed (+324 additions, -22 deletions)
View changed files
➕
docs/EXL3_RDNA4.md(+139 -0)📝
docs/SETTINGS.md(+19 -0)📝
docs/SETUP.md(+8 -0)📝
include/strata/kernels/exl3.hpp(+5 -2)📝
src/kernels/cuda/exl3.cu(+118 -8)📝
tests/exl3_test.cu(+35 -12)📄 Description
Our pinned v1.1.29 integration test measured 7.7–9.2% faster whole-model warm 4K prefill with this RDNA4 matrix path: about 8.28–8.41 seconds fell to 7.69–7.71 seconds. The fresh disabled-path control reproduced the earlier logits exactly, with less than 0.5% timing drift. These are helper/transfer-pruning integration measurements, not a clean standalone or decode benchmark.
The numerical difference is how floating-point sums are accumulated. Both RDNA4 paths use the same compressed EXL3 weights, FP16 operands and FP32 accumulation. WMMA groups products and additions differently from the portable DOT2 path and its warp reduction, so rounding and low output bits can differ. Those differences can propagate through later layers and expert routing. Bit-identical logits are therefore not the contract for this kernel; the existing CPU-reference tolerances, finite checks and output guards remain unchanged. The recorded full-model logit differences do not by themselves demonstrate a loss of answer quality.
Default behavior: eligible HIP gfx12 devices use the 16-row matrix prefill path by default.
EXL3_WMMA_GFX12=0restores the portable path on gfx12;EXL3_WMMA=0disables WMMA on both gfx11 and gfx12. Unsupported devices retain their existing paths. Kernel and dispatch comments document the rounding behavior, rather than leaving that explanation only in this PR body.In plain terms: while Maya reads a prompt, this lets the GPU's matrix hardware do expert calculations for many tokens together. It unpacks each small weight tile just before use and shares it across 16 or 32 routed tokens, reducing repeated work. The weights stay compressed until needed.
What we measured earlier
The existing operator accuracy thresholds are retained. Historical whole-model quality and decode observations remain below, including a 3.24% lower decode rate in one normal-cache/MTP comparison; no unchanged-quality or universal-throughput claim is made.
Focused implementation
This consolidates the compressed-weight RDNA4 matrix implementation from our fork experiments into upstream's existing grouped-expert launch path. It is one kernel proposal, not the entire experimental engine stack.
EXL3_WMMA_GFX12=0opts out on gfx12.EXL3_WMMA=0overrides forced enable and disables WMMA.EXL3_WMMA_ROWS=16/32and the existing uniform/mixed expert wrappers forset_gate_upandset_down.The separate sixteen-token scalar-FMA and predecoded-fragment-cache experiments are excluded. This PR adds neither peer transport nor host-packing, transfer-pruning, or model-cache policies. See
docs/EXL3_RDNA4.mdfor guided setup, saved configuration, build/kernel verification, rollback and limitations. The existing setup and settings guides link to it; the setup example uses the exactEXL3_*kernel switches to pin the documented defaults.Validation on upstream
451f9cb(v1.1.21)maya-ds4andexl3_test.exl3_test: zero failures and zero launch errors.EXL3_WMMA=0override with the gfx12 opt-in set: focused tests passed.3e-3), worst-element limit, and finite checks are unchanged.git diff --checkpassed.Earlier pinned integration check (v1.1.29 /
8b4b39f)The three kernel/test/documentation files in this PR applied without changes to the current helper + packed-transfer + transfer-pruning stack; their SHA-256 hashes match this PR. The default-path control and matrix-enabled run used the same compiled integration binary. An earlier disabled-path run brackets the comparison.
Each table cell averages two warm requests. The harness used fixed residency and a 4,096-token coding-agent prefix; it loaded DSpark weights but did not execute drafting. Two short coding/async prompts were also checked. The combine modes were timed in ABBA order within each loaded model. Expert selections can change with the matrix arithmetic, so this measures the complete prompt pass, including resulting routing differences, rather than a fixed set of expert operations.
All seven current integration operator runs passed: a disabled-path control and matrix modes 16/32 on each of three R9700s, with the existing CPU-reference tolerances and guards. All nine disabled-path full-logit files reproduced the earlier reference byte-for-byte. Within the matrix path, all twelve sampled full-vocabulary checkpoints repeated bitwise across the three combine-mode trials. No process swapping, host swap-out or KFD queue evictions were observed in the measured warm windows; loading is excluded from that claim.
Numerical limitation: the eight short-prompt checkpoints match the disabled path exactly. For the four 4K-context checkpoints, only two top-token choices match; maximum absolute logit difference reaches 4.47 and reference-to-matrix KL ranges from 0.036 to 0.134 nats. Deterministic repeats and passing operator checks do not establish answer quality. A held-out quality comparison would quantify downstream answer-quality impact; these logit measurements alone do not measure quality loss.
Normal-cache/MTP follow-up
A subsequent two-arm test used the same current integration binary, normal adaptive cache/path selection and actual four-bit DSpark/MTP. Each arm emitted 6,144 timed tokens across coding, async-worker and 16K-context requests. Only
EXL3_WMMA_GFX12changed between arms; matrix rows stayed at 16.The prefill improvement is useful evidence, but this run does not establish unchanged decode performance or broad quality. The selected serving configuration was restored and health/generation checked. That experiment restored its previous serving configuration afterward.
Further evaluation
The historical kernel and wide-load measurements used the earlier experimental engine. The earlier pinned integration check adds warm 4K evidence but does not isolate a clean standalone branch or establish full-model quality. The experimental integration has not replaced the selected serving configuration.
Rebase validation on v1.1.36 (
f031a23)The rebase preserves upstream's newer Volta/Turing WMMA code, 32-byte alignment for its matrix operands, and compact Pascal mixed-kernel parameters. RDNA4 retains its separate padded operand layout. HIP builds for both gfx1100 and gfx1201 compile and link the operator test. On an R9700, portable default, 16-row matrix, 32-row matrix, and explicit opt-out all pass the focused CPU-reference cases with zero failures and launch errors. Existing tolerances and guards are unchanged. RDNA3 hardware and NVIDIA compilation/runtime were not available for these checks.
These are fresh compatibility and operator checks. The whole-model prefill and decode numbers above remain measurements from the earlier pinned integration, with its stated routing, quality and scheduling caveats. There is no fresh v1.1.36 model throughput or broad quality claim.
Default-selection validation
The gfx12 default is now matrix prefill with 16-row tiles. Comments beside
rdna4_block_wmmaandwmma_nowexplain the shared FP16-operand/FP32-accumulation formats and expected accumulation-grouping/rounding differences. The existing CUDA-onlyprompt_tcplanner query stays unchanged; a read-onlyprompt_wmmaquery lets the test report the actual grouped-kernel selector.The HIP Release engine and test binary compile and link for gfx1100 and gfx1201. On an R9700, three full operator-suite runs pass: no settings (matrix selected),
EXL3_WMMA_GFX12=0(portable selected), andEXL3_WMMA=0(portable selected). Focused tests also pass with forced gfx12 enable plus global opt-out, and with 32-row matrix tiles. All five runs report zero failures and launch errors; dispatch diagnostics confirm each expected mode. Existing reference tolerances and exact/guard checks were not relaxed. These are operator/default-selection checks, not a new whole-model throughput or broad quality study. The running serving process was not changed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.