Repository navigation
feat(miopen): fused single-layer LSTM forward-inference kernel (flagged) - #8915
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
05f448a to
38457d1
Compare
Kokoro-82M TTS inference on gfx1201 (navi48) is dominated by the bidirectional
nn.LSTM in the decoder: at batch=1 the per-timestep recurrence issues ~45k
tiny serial GEMM + elementwise dispatches, leaving the GPU idle ~94% of the
LSTM and making the workload launch-latency-bound rather than compute-bound.
Add a cooperative-grid fused inference kernel (one launch per direction) that
walks the whole sequence on-device with a grid-wide barrier per timestep,
reusing MIOpen's existing batched input-projection workspace and adding only
the recurrent W_hh*h_{t-1} term and the LSTM cell update. This collapses the
per-timestep host dispatch loop in RNNForwardInferencePacked.
Strictly opt-in behind MIOPEN_DEBUG_RNN_FUSED_INFERENCE and gated to the
validated case (single layer, LSTM, miopenRNNdefault, fp32, no dropout,
packed, linear input, uniform batch); every other configuration falls back to
the existing path unchanged. Default behavior is identical to before -- the
flag defaults off because enabling such fusion unconditionally could change
results for other models.
The kernel honors the caller's initial hidden/cell state (hx/cx) and writes
the final hy/cy, matching the stock path; uniform batch>1 is supported.
Test: test/gtest/lstm_fused_inference_test.cpp drives miopenRNNForwardInference
twice in-process (flag off = stock reference, flag on = fused) and requires
the GPU output and hy/cy to agree to 1e-5, giving the comparison real teeth.
Covers uni+bi, N=1 and uniform batch>1, fp32, including the single-timestep
edge case. The debug flag is registered in the MIOPEN_BUILD_TESTING env
registry so ScopedEnvironment can toggle it. Real Kokoro LSTM outputs match
the stock path to ~1e-6.
JIRA ID : AIRADSW-142
c51028d to
e614908
Compare
Resolve env_debug.cpp conflict: upstream removed MIOPEN_DEBUG_OPENCL_CONVOLUTIONS (gone tree-wide); keep our added MIOPEN_DEBUG_RNN_FUSED_INFERENCE declaration + registry entry. Our fused LSTM dispatch auto-merged into src/hip/rnnocl.cpp (upstream moved the file from src/ocl/). Rebuilt + all 12 lstm_fused_inference_test cases pass. JIRA ID : AIRADSW-142
…8916) ## Summary Add tuned Tensile Equality logic entries for the fp32 GEMM shapes that dominate Kokoro-82M TTS inference on gfx1201 (Navi48): - **TN** (`Cijk_Alik_Bljk_S_B_Bias_HA_S_SAV_UserArgs`): LSTM hidden-update N=1 matvecs + encoder shapes. - **NN** (`Cijk_Ailk_Bljk_S_B_Bias_HA_S_SAV_UserArgs`): HiFi-GAN decoder M-tall upsample GEMMs (skinny-N / large-M). ## Details - Entries are **appended** to the existing per-(dtype, transpose) superset logic files. **No stock solutions or exact-logic rows are removed** — this is additions-only. - Winners were selected by Tensile bench-and-merge and verified to dispatch at runtime on gfx1201 during real Kokoro runs (every added exact-logic key was confirmed reachable; no dead entries). - fp32, `UseBias=1` / `ScaleAlphaVec` / `Activation` superset `ProblemType`, matching the shapes the model actually issues. ## Validation Ran the full Kokoro test matrix (stock / yaml-only / code-only / both). The tuned logic is applied via the rebuilt hipBLASLt library and dispatches the tuned kernels for the targeted shapes, with no regression on untargeted shapes. ## Related JIRA ID : AIRADSW-142 - Companion PR (MIOpen fused LSTM inference kernel for the same Kokoro decoder): #8915 --------- Co-authored-by: Filip Jankovic <161825881+fjankovi@users.noreply.github.com>
feat(hipblaslt): gfx1201 Tensile tunings for Kokoro-82M GEMM shapes (#8916) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Add tuned Tensile Equality logic entries for the fp32 GEMM shapes that dominate Kokoro-82M TTS inference on gfx1201 (Navi48): - **TN** (`Cijk_Alik_Bljk_S_B_Bias_HA_S_SAV_UserArgs`): LSTM hidden-update N=1 matvecs + encoder shapes. - **NN** (`Cijk_Ailk_Bljk_S_B_Bias_HA_S_SAV_UserArgs`): HiFi-GAN decoder M-tall upsample GEMMs (skinny-N / large-M). ## Details - Entries are **appended** to the existing per-(dtype, transpose) superset logic files. **No stock solutions or exact-logic rows are removed** — this is additions-only. - Winners were selected by Tensile bench-and-merge and verified to dispatch at runtime on gfx1201 during real Kokoro runs (every added exact-logic key was confirmed reachable; no dead entries). - fp32, `UseBias=1` / `ScaleAlphaVec` / `Activation` superset `ProblemType`, matching the shapes the model actually issues. ## Validation Ran the full Kokoro test matrix (stock / yaml-only / code-only / both). The tuned logic is applied via the rebuilt hipBLASLt library and dispatches the tuned kernels for the targeted shapes, with no regression on untargeted shapes. ## Related JIRA ID : AIRADSW-142 - Companion PR (MIOpen fused LSTM inference kernel for the same Kokoro decoder): ROCm/rocm-libraries#8915
BrianHarrisonAMD
left a comment
There was a problem hiding this comment.
The changes are properly behind a flag, and ill approve to allow this to move forward.
I think the comments should be fixed before merging, or as a separate follow-up if this needs to land right away.
|
Addressed all seven review threads in Validation on Radeon RX 7900 XTX / ROCm 7.13:
|
|
Additional combined evaluation after deploying the freshly rebuilt current #8222 hipBLASLt (
The +0.77% median difference is within observed run variance and paired deltas are mixed, so I consider the feature performance-neutral rather than claiming an uplift. There is no reliable regression, and the correctness/dispatch tests remain 12/12 passing. |
Keep the flagged path side-effect-free and cooperative-launch-safe, account for profiling, and strengthen the GPU test to prove fused dispatch while checking every API result. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
|
This pull request has been automatically closed due to inactivity (30 days with no updates). If you'd like to continue working on this, feel free to reopen the PR or create a new one. |
TheRock Submodule Bump ActivityNewest first
|
## Summary Backfills the **MIOpen 3.6.1 / ROCm 10.1.0** changelog section with externally-visible changes that landed since the `release/therock-10.0` branch but weren't yet documented. All 43 MIOpen commits in that range were reviewed; CI/build-infra, test-only, docs, version-bump, and already-documented changes were excluded. 21 entries added: ### Added * [RNN] Fused single-layer LSTM forward-inference kernel, gated behind `MIOPEN_DEBUG_RNN_FUSED_INFERENCE` (#8915) * [Conv] Naive reference kernel enabling 3D INT8 forward convolution (#10051) * [Conv] `ConvHipConv` solver backed by vendored hipconv kernels (#9746) * [Conv] float8 vector type support + deduplicated math kernels (#10130) * [Conv] Validated gfx1151 and gfx1200 (Navi) SystemDBs (#10050) * [Conv] `MIOPEN_DEBUG_DISABLE_SYSTEM_DB` / `MIOPEN_DEBUG_DISABLE_USER_DB` env vars (#10728) * [Conv] CK depthwise convolution on RDNA wave32 GPUs (#9373) ### Changed * [Conv] Winograd Rage RxS f2x3 on gfx950 + gfx942 v4_6_1/v4_9_1 kernels (#9014) * [Conv] Updated 3D AI heuristics for gfx942 & gfx950 (#8954) ### Optimized * [Conv] Single GEMM for point (1x1) output convolution, all directions, 2D/3D (#10912) * [Conv] Naive backward-data kernel work group widened to 1024 (#10684) ### Resolved Issues * [Conv] Batch-split miscalculation on large WrW tensors — ROCM-26011 (#11188) * [Conv] Conv failure on XNACK-unsupported gfx9 APUs (gfx90c) (#11211) * [BatchNorm] Device heap-overflow in fwd spatial `FinalMeanVariance` — ALMIOPEN-2424 (#11093) * [Conv] Deterministic `SetNextValue` polarity for grouped Bwd/Wrw CK solvers (#10240) * [LRN][LayerNorm] Grid alignment + OOB threads on gfx1250 (#10251) * [Conv] Stale gfx950 grouped-wrw SystemDB entries (#11130) * [Conv][Windows] System-DB path resolution from the MIOpen module (#10838) * [Conv] System-DB fallback so MI308X (gfx942) resolves a usable DB (#8802) * JSON perf logs (`MIOPEN_PERFORMANCE_LOGS`) dropping the last solver during Find (#11166) * Build failure against GCC 15 libstdc++ under C++20 (#9642) ## Notes Deliberately excluded: internal/default-off changes (#10219, #10088, #10649, #10231), a near-duplicate of an existing 10.0.0 entry (#10188), and CI/build-infra/test-only/docs commits. Docs-only change; no code impact. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Proposed changes
Kokoro-82M TTS inference on gfx1201 (Navi48) is dominated by the bidirectional
nn.LSTMin the decoder. At batch=1 the per-timestep recurrence issues roughly 45k tiny serial GEMM + elementwise dispatches, leaving the GPU idle ~94% of the LSTM and making the workload launch-latency-bound rather than compute-bound.This PR adds an experimental cooperative-grid fused single-layer LSTM forward-inference kernel (one launch per direction) that walks the whole sequence on-device with a grid-wide barrier per timestep. It reuses MIOpen's existing batched input-projection workspace and adds only the recurrent
W_hh * h_{t-1}term and the LSTM cell update, collapsing the per-timestep host dispatch loop inRNNForwardInferencePacked.Safety / scope
MIOPEN_DEBUG_RNN_FUSED_INFERENCE. Default behavior is unchanged — the flag defaults off because enabling such fusion unconditionally could change results for other models.miopenRNNdefault, fp32, no dropout, packed, linear input, uniform batch. Every other configuration falls back to the existing path.hx/cx) and writes the finalhy/cy, matching the stock path. Uniform batch > 1 is supported.Testing
test/gtest/lstm_fused_inference_test.cppdrivesmiopenRNNForwardInferencetwice in-process — flag off (stock reference) and flag on (fused) — and requires the GPU output plushy/cyto agree to1e-5. Because both paths share the input-projection GEMM and differ only in the recurrence, the tolerance is tight and any logic bug (gate order, cell update, direction offset, batch indexing, initial-state handling) trips the assertion. Cases cover unidirectional + bidirectional, N=1 and uniform batch > 1, fp32, including the single-timestep edge case.The debug flag is registered in the
MIOPEN_BUILD_TESTINGenv registry (env_debug.cpp) soScopedEnvironmentcan toggle it from the test. Real Kokoro LSTM outputs match the stock path to ~1e-6 end-to-end.All 12 gtest cases pass on gfx1201; they fail prior to the kernel fixes, confirming the test has teeth.
Related
JIRA ID : AIRADSW-142
Checklist
make format&make check_formatto ensure the changes have been formatted