Repository navigation
OpenEquivariance + MACE on AMD Radeon AI PRO R9700 (gfx1201, RDNA4) with ROCm SDK 10.2 nightly: setup notes, deterministic-convolution and CAS-loop atomic results, and what limits performance #228
Replies: 2 comments
|
Follow-up: the Fedora backport request is now https://bugzilla.redhat.com/show_bug.cgi?id=2564512 (rocclr 7.1.1, with the three patches attached). |
|
A short summary of how the best numbers above were reached, since they are spread over §4–§6. Each row adds one change on top of the previous one (ROCm 10.2 nightly, steps/s; the factor is relative to the row above):
Repeats: 3 fresh-process pairs per step, except the ASE deterministic-conv step (1 pair for D2 1×1, 2 pairs for C1 2×2). In order of the bottlenecks they removed:
We have not yet broken down what limits the 2×2 cells after these steps. Small correction to §5 (Fedora leaks): the "about 1.2 MiB/s heap" is heap in use as counted by our allocation shim. In our short measurement windows the resident growth was the signal pool alone (0.57–0.64 MiB/s); details are in the Fedora bug linked above. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi all. We have been running MACE with OpenEquivariance on an AMD Radeon AI PRO R9700 (RDNA4, gfx1201, 32 GB) for molecular dynamics, through ASE and through LAMMPS ML-IAP, and comparing against an NVIDIA RTX A6000 run with the same harness. Below are our environment, the small changes we needed, and today's measurements. We hope this helps other RDNA4 users. Corrections are welcome.
Prepared with the help of AI coding tools.
1. Environment
2. Recipe (what we needed on top of a plain install)
torchwith its gfx1201 device wheel (amd-torch-device-gfx1201),triton, and the ROCm SDK (rocm-sdk-core,rocm-sdk-libraries,rocm-sdk-device-gfx1201). For this nightly therocmumbrella package is a source distribution; we built it as a metadata-only wheel withROCM_SDK_TARGET_FAMILY=gfx1201so that it does not probe the device. Index URLs (https://nightly.repo.amd.com/rocm/pytorch/whl-next/,https://nightly.repo.amd.com/rocm/core/whl-next/). We use a hash-pinned lock file, which we can share. Then installmace-torch==0.3.16,e3nn==0.4.4andopenequivariance==0.7.0. OEQ's JIT build needs the SDK devel headers (rocm-sdk-develof the same build).extension/libtorch_tp_jit.cpp: add#include <format>as the first include. With GCC 16, libstdc++'s<format>uses[[__gnu__::__noinline__]], which breaks after the HIP headers define__noinline__as an empty macro (known HIP issue [rocm-hip]: __noinline__ macro in host_defines.h conflicts with GCC 16 libstdc++ <format> ROCm/rocm-systems#9897)._torch/extlib/__init__.py: skip_wait_for_torch_build_lock()for torch ≥ 2.14. Torch 2.14 switchedcpp_extensionto aFileLockthat leaves thelockfile in place, so later processes wait on that file until the 300 s timeout. The OS lock still protects concurrent builds. (Note:Version("2.14.0a0") < Version("2.14"), so pre-release builds need a different check; see JIT loader times out after 300 s on thelockfile that torch ≥ 2.14cpp_extensionleaves in place, so later processes cannot load the extension #226.)CC=gcc CXX=g++ TORCH_EXTENSIONS_DIR=<cache> MAX_JOBS=<n> python -c "import openequivariance", and check thatBUILT_EXTENSIONis true.src/KOKKOS/mliap_data_kokkos.henables the device data path only for CUDA (dev(1)underKOKKOS_ENABLE_CUDA). We addedKOKKOS_ENABLE_HIP(one line). We also needed a Kokkos HIP block-size fix: Kokkos 5.2.1 checks LDS only against the per-multiprocessor limit, not the 64 KiB per-block limit. We have not submitted these two changes yet; the diffs are short and we can share them. With the 10.2 nightly SDK, 16 KOKKOS pair styles that our inputs do not use failed at device LTO link (LLVM ERROR: Inconsistent metadata on dynamic LDS variable), so we left them out of the build.3. Why OEQ's default (atomic) convolution is slow on this GPU
unsafeAtomicAdd. On gfx1201 this compiles to the nativeglobal_atomic_add_f32instruction, with no CAS loop. We checked this in our microbenchmark binary and in OEQ's own HIPRTC-compiled conv kernels: the code objects loaded at run time are byte-identical to CPU-side HIPRTC builds whose disassembly shows the native instruction. The instruction is slow on this GPU:atomicCASon the float's bits, retried until it succeeds) reaches about 31 G updates/s on scattered addresses (64 KB–8 MB footprints), about 9× the native instruction. Replaying OEQ's own storeback ranges and layouts from MACE C1 2×2, the four conv phases take 11.65 ms with the CAS loop vs 52.07 ms native (ratio 0.224). Bit-level probes (denormals, signed zero, NaN payloads) gave the same results as the native instruction.4. Model-level results with OEQ's deterministic convolution
MACE fixes
TensorProductConv(..., deterministic=False), so we wrapped the conv with a small runtime adapter. It sorts edges, builds the transpose permutation, and calls the deterministic kernels. Energies, forces and stress pass our tolerances against FP64 references for every cell below.Important for LAMMPS ML-IAP: the ML-IAP graph is not symmetric (receivers are local atoms, senders include ghosts). The deterministic backward assumes a symmetric graph, as the docs state. With a non-symmetric graph, forces came out wrong (up to 13.7 eV/Å per force component over our four test frames) with no error. That was our adapter's mistake, not an OEQ bug: atomic mode handles this graph correctly. Our adapter therefore passes the transposed index arrays (
cols[perm],rows[perm]) to the first-order backward and rejects second derivatives. We opened #227 suggesting a symmetry check, or general support, for deterministic mode.Steps/s, ROCm 10.2 lane, default (atomic) vs deterministic conv, fresh processes, 30-s blocks (60-s for 3×3):
(D2 and C1 are our two benchmark systems; 1×1/2×2/3×3 are in-plane supercells (2×2×1, 3×3×1): D2 has 225/900/2025 atoms and C1 has 273/1092/2457 atoms.) The deterministic gain grows with system size, matching the conv's growing share of step time.
4b. Same algorithm, different lowering: CAS-loop FP32 atomic adds
Deterministic conv changes the algorithm. To keep OEQ's default algorithm (non-deterministic atomic accumulation, the same as on the A6000) and only change how the FP32 atomic add is lowered, we rendered OEQ's atomic conv template with a small helper that replaces
unsafeAtomicAddin the storeback by the CAS loop above. Scope: HIP, gfx1201 only (the helper refuses other targets at compile time), FP32 irreps and weights, atomic conv only; the deterministic conv and the tensor product kernels are unchanged, and the choice is fixed per instance at construction. We checked the loaded code objects in every run: the native arm contains the native instruction, the CAS arm contains the CAS loop. No adapter is needed, so this also works unchanged with LAMMPS ML-IAP's non-symmetric local/ghost graph.Steps/s, ROCm 10.2 lane, native lowering vs CAS loop, 3 fresh-process pairs per cell (each pair ratio within 1% of the cell median), energies/forces/stress within our tolerances for both arms:
("override" is the hipBLASLt override file from §5, used in both arms.) Deterministic conv is still a little faster on the same cells (e.g. ML-IAP C1 2×2 17.87 vs 16.04 steps/s, ASE D2 1×1 47.5 vs 44.97), but the CAS loop keeps the original algorithm and needs no graph handling. The CAS change lives only in our local copy of OEQ; we can open a PR for an opt-in gfx1201 lowering if that is useful (other RDNA4 targets were not tested), but the underlying issue is the speed of the hardware FP32 atomic (ROCm/TheRock#9483).
5. Other R9700-specific findings in the same pipeline
pair/only onwith ML-IAP. Running the pair style on the GPU and everything else on the host crashed in LAMMPS's legacy host pair-communication path: device pointers were used on the host, and the buffer was too small. With our fix (KOKKOS ML-IAP on GPUs: use the device pair communication for the feature exchange when KOKKOS forces the legacy path (fixes heap corruption withpair/only on) lammps/lammps#5290),pair/only onis faster for small cells:pair/only(LAMMPS ML-IAP). Addingpair/onlyon top of deterministic conv + GEMM override gave no gain for D2 1×1 (0.999×) but 1.076× for C1 2×2: 22.28 steps/s, 2.31× the R9700 10.2 default (3 fresh-process pairs each).pair/onlyneeds our LAMMPS fix (KOKKOS ML-IAP on GPUs: use the device pair communication for the feature exchange when KOKKOS forces the legacy path (fixes heap corruption withpair/only on) lammps/lammps#5290), so this row is not reproducible with stock LAMMPS until it is merged.rocm-hip-7.1.1) instead of the TheRock wheels. We found two separate leaks, both fixed upstream in the 7.2 series. (a) Long-running HIP processes accumulate HSA signals: in our LAMMPS workload about 0.57–0.60 MiB/s in the signal pool plus about 1.2 MiB/s heap (rocm-systems PRs #1354 and #4653; a rebuild of Fedora's 7.1.1 with those two commits showed zero growth over 60 minutes with unchanged speed). (b) Loops of synchronoushipMemcpyleak about 930 B per call (the reproducer in [Issue]: [HIP] Synchronous host/devicehipMemcpyleaks ~0.9 KiB of host memory per call ROCm/legacy-rocm-build#6573); this needs the submission-batch change from rocm-systems PR #4671 as well, and with all three changes the reproducer shows 0 B per call. We plan to ask Fedora for a backport. The TheRock 10.x runtime used for the OEQ runs above showed neither leak.6. Comparison with an RTX A6000 (same harness)
The A6000 numbers come from existing runs with the same harness: OEQ's default atomic conv and default settings. All R9700-specific changes (deterministic conv, GEMM override,
pair/only) were measured on the R9700 only. Trying them on the A6000 is left for future work. Values are R9700 steps/s, with the R9700/A6000 ratio in parentheses.6a. Same algorithm (atomic conv). The fair column is our closest like-for-like comparison: same algorithm, same harness, default settings, release wheels. The other two columns are informational. One uses a newer software stack (10.2 nightly); the other adds an R9700-specific workaround (the hipBLASLt override).
pair/onlyresults (§5) are also informational (R9700 only).6c. Same algorithm with the CAS-loop lowering (§4b) — R9700-specific workaround, informational. Same algorithm as the A6000 run, but it needs our local OEQ change, so it is not in the fair column.
6b. Different algorithm — informational only, not a fair comparison. The R9700 columns use OEQ's deterministic conv, while the A6000 numbers are OEQ's default atomic conv. The ratios show how far the R9700 gets with that change. They do not compare the two GPUs on equal terms.
(ASE D2 1×1 on 10.2: median of the 2 valid processes out of 3.)
pair/only(LAMMPS ML-IAP), R9700 only: C1 2×2 22.28 steps/s (0.927 of the A6000 atomic run); D2 1×1 unchanged from deterministic + GEMM override (67.47, 1.198), becausepair/onlyadds nothing there.7. Notes for OEQ developers
TensorProductConv: make the symmetric-graph precondition checkable, or support non-symmetric graphs in backward #227).lock-file wait inextlib/__init__.pyinteracts badly with torch ≥ 2.14'sFileLock(JIT loader times out after 300 s on thelockfile that torch ≥ 2.14cpp_extensionleaves in place, so later processes cannot load the extension #226). We can send a small PR that detects the lock mechanism instead of checking the version.All reactions