Repository navigation
Conversation
The transposed feed-forward epilogue called tl.extra.cuda.libdevice.tanh. Triton's AMD backend refuses the CUDA-namespaced libdevice functions ("Implicit conversion of CUDA __nv_tanhf device function has been dropped"), so the rtx5080 preset failed to compile its epilogue on ROCm. triton.language.extra.libdevice dispatches to the right library on every backend and is what the rtx5070ti INT8 GEMM epilogue already uses, so behaviour on NVIDIA GPUs is unchanged.
This change was prepared with the help of an AI coding agent.
Test Plan:
```
python -m unittest discover -s tests -p 'test_*.py'
matrix-game render --scene ancient-egypt --resources resources --input clip.mp4 --preset rtx5080 --prompt-mode fixed --output outputs/rtx5080
```
Both pass on AMD Instinct MI355X (PyTorch 2.12.0, ROCm build); the render produces every input frame.
The rtx5090, rtx5080 and rtx5070ti presets quantize to FP8 and MXFP8 in layouts and encodings that only NVIDIA's libraries accept, so they could not run on ROCm. FP8 (rtx5090, rtx5080, the fp8 roles of rtx5070ti): the e4m3 encoding is now chosen once per process. MI300-series (gfx94x) GPUs only multiply the FNUZ variant (float8_e4m3fnuz, largest finite value 240), which is how PyTorch's own tests pick their e4m3 type; every other GPU keeps float8_e4m3fn and 448. The Triton activation quantizers take the largest finite value as a constexpr and cast to the output tensor's element type, so the CUDA build compiles exactly the code it did before (448, float8e4nv). MXFP8 (the cross_q role of rtx5070ti): PyTorch's ROCm MX GEMM (hipBLASLt on gfx950) refuses SWIZZLE_32_4_4 and accepts only NO_SWIZZLE, with row-major [M, K/32] e8m0 scales, M a multiple of 32, no bias and BF16 output. On ROCm the quantizer therefore writes row-major scales, pads the activation rows with zeros to a multiple of 32, and the bias is added after the GEMM. AMD GPUs without MX GEMMs (all but gfx950) run that role in BF16. The NVIDIA path is unchanged. This change was prepared with the help of an AI coding agent. Test Plan: ``` python -m unittest discover -s tests -p 'test_*.py' for p in rtx5090 rtx5080 rtx5070ti realtime; do matrix-game render --scene ancient-egypt --resources resources --input clip.mp4 --preset $p --prompt-mode fixed --seed 42 --output outputs/$p done matrix-game render --scene ancient-egypt --resources resources --input clip.mp4 --preset realtime --dit-runtime native --no-vae-graph --prompt-mode fixed --seed 42 --output outputs/native ``` On AMD Instinct MI355X (gfx950, PyTorch 2.12.0 ROCm build) the unit tests pass and each preset renders all 120 frames of a 120-frame clip. Per-frame PSNR against the native runtime: rtx5090 19.3 dB, rtx5080 20.0 dB, rtx5070ti 18.9 dB mean, where the bf16 realtime preset gives 22.2 dB. Each converted linear was also checked against its BF16 layer (relative error 0.037 for FP8 and MXFP8, 0.015 to 0.05 for INT8), and an MXFP8 layer replays bit-identically from a CUDA graph.
Add an AMD ROCm subsection to the v4 install guide: the ROCm build of PyTorch 2.12.0 replaces the CUDA one and nothing else changes. It lists the presets that were run on AMD Instinct MI355X, what the FP8 and MXFP8 presets need from the GPU, that the -sage presets need SageAttention (which has no ROCm build), and that HIP_VISIBLE_DEVICES selects the GPU. docs/installation.md points to it. This change was prepared with the help of an AI coding agent. Test Plan: Documentation only. On an MI355X host with a ROCm build of PyTorch 2.12.0 (an AMD build against ROCm 10.2 rather than the download.pytorch.org rocm7.2 wheel) and the package installed as described, the unit tests and the realtime, quality, baseline, rtx5090, rtx5080 and rtx5070ti renders ran: ``` python -m unittest discover -s tests -p 'test_*.py' matrix-game render --scene ancient-egypt --resources resources --input clip.mp4 --preset quality --prompt-mode fixed --output outputs/quality ```
jeffdaily
added a commit
to AMD-Ecosystem/moat
that referenced
this pull request
Nov 25, 2026
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.
This lets Matrix-Game-4 inference run on AMD GPUs with ROCm. Matrix-Game-3 is not changed (#67 covers it).
Problem
On a ROCm build of PyTorch, the bf16 presets already run, but the
rtx5090,rtx5080andrtx5070tipresets do not:float8_e4m3fn. MI300-series GPUs (gfx94x) only multiply the FNUZ encoding (float8_e4m3fnuz, largest finite value 240), so their FP8 GEMMs refuse the tensors.rtx5070tiMXFP8 role uses NVIDIA's swizzled block-scale layout and a bias in the GEMM. PyTorch's ROCm MX GEMM (hipBLASLt, gfx950 only) accepts only unswizzled row-major[M, K/32]scales, M a multiple of 32, no bias and BF16 output.rtx5080epilogue callstl.extra.cuda.libdevice.tanh, which Triton's AMD backend refuses.Change
rtx5090/fp8_linear.py: pick the e4m3 encoding once per process (FNUZ and 240 on gfx94x,float8_e4m3fnand 448 everywhere else). The Triton quantizers take the maximum as a constexpr and cast to the output tensor's dtype, so the CUDA build compiles the same code as before.rtx5070ti/linear.py: on ROCm, write row-major scales, pad the activation rows to a multiple of 32 and add the bias after the GEMM; AMD GPUs without MX GEMMs (all but gfx950) run that one role in BF16. The NVIDIA path is unchanged.rtx5080/linears.py: usetriton.language.extra.libdevice.tanh, which dispatches correctly on every backend (thertx5070tiepilogue already does this).docs/installation.md: an AMD ROCm install section (the ROCm build of PyTorch replaces the CUDA one; nothing else changes), what each preset needs from the GPU, andHIP_VISIBLE_DEVICES.Testing
Unit tests (
python -m unittest discover -s tests -p 'test_*.py') and 120-frame renders of the same clip and seed withmatrix-game render --scene ancient-egypt ... --prompt-mode fixed --seed 42 --preset <p>, compared frame by frame with the bf16nativeruntime on the same GPU (the release check indocs/testing.md):Each converted linear layer was also checked against its BF16 layer (relative error about 0.04 for FP8 and MXFP8). On the MI300X, the FP8 GEMM output matches an exact FNUZ emulation to BF16 rounding. Nothing was run on an NVIDIA GPU. With the CUDA build's Triton (3.7.0), the five changed kernel instances compile to byte-identical PTX, cubin and SASS for sm_90, sm_100 and sm_120 before and after this change.
Notes:
-sagepresets need SageAttention, which has no ROCm build.torch.backends.cudnn.deterministic = Truemakes renders repeat bit for bit at the same speed. cuDNN makes the same promise, so this PR does not change it.My agent came up with this analysis, but I've read and approved it. The changes were prepared with the help of an AI coding agent.
This pull request was prepared with the help of an AI assistant acting as a coding agent and was read and approved by a person before it was opened. It comes from an ongoing effort to add AMD GPU support to widely used CUDA projects, one repository at a time: https://github.com/AMD-Ecosystem/moat -- that repository describes how the work is done and what a person checks before anything is submitted.
If you would rather not receive pull requests from this effort, say so here or open an issue at https://github.com/AMD-Ecosystem/moat/issues/new/choose and we will close this and stop. That can cover this repository alone or everything you own, whichever you prefer.