CUDA Graph optimization for massive speedup in small systems - #410
CUDA Graph optimization for massive speedup in small systems#410JonathanMaes wants to merge 34 commits into
Conversation
Squashed snapshot of the CUDA-Graph-accelerated mumax3 fork (based on mumax/3 commit 3fe3d41, "Update gpus.txt"). Adds a transparent split-graph CUDA Graph capture/replay path for Run()/Steps() across Heun, RK23, RK45DP, RK56 and BackwardEuler, with safety guards for Temp, time-dependent B_ext/material parameters, NoDemagSpins and custom field terms, plus the conv_kernmul launch-range and lazy MaxTorque/MemCpyDtoH micro-optimizations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the upstream mumax3 README with a fork-focused README covering: - Performance table (4K–1M cell speedup measurements on RTX 5060 Ti) - How the CUDA Graph capture/replay path works - Safety guard list - Pre-built Windows binary download link (GitHub Releases) - Build-from-source instructions (Windows CUDA 13.2 + Linux) - Summary table of all source changes vs upstream 3fe3d41 - Upstream citation and license notice Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi, Would it be possible to extend this it include the minimizer? It has a similar structure, where there are a bunch of consecutive Cuda calls. (I don't have access to Cuda 13.0, so I'm not sure how the Cuda graph stuff works and whether this is a reasonable ask. If not, feel free to ignore) |
|
Hi Josh, I had been thinking the same thing, since the use of Also, I think CUDA Graphs were introduced in CUDA 10.0, so not having access to 13.0 should not pose an issue. The mention of 13.0 in the other pull request is a wholly separate issue that was already present when trying to compile mumax3.12 with CUDA 13.0. |
| ) | ||
|
|
||
| func init() { | ||
| DeclFunc("RunGraph", RunGraph, "Like Steps, but captures the torque-evaluation kernels as CUDA Graphs and "+ |
There was a problem hiding this comment.
Does this function serve any purpose? It seems that tryRunGraph is the version of this function that is actually used. The only use case for this function I see is to print the reason for not using CUDA graphs during a panic. Also, seems like this would more appropriately be called StepsGraph.
(see #303 & bugfix/backwardEuler branch)
The CUDA Graph functionality we use requires CUDA >=10.1. Let's just provide executables from 11.0 onward.
This PR captures part of the changes introduced in mumax³-CO, as presented in C.-Y. You, J. Magn. 31, 204-213 (2026).
As extensively described in C.-Y. You, J. Magn. 31, 204-213 (2026) and on the accompanying website, using CUDA Graph to capture and replay the torque-evaluation kernels in each solver stage can result in a speedup of up to 3-5x for small systems, depending on the solver used. This integrates seamlessly into
Run()andSteps()(no changes to input scripts required) and is enabled by default in simulations with <800k cells when >20 steps are requested. Importantly, this optimization is not used/usable withB_extor material parametersAddFieldTerm)NoDemagSpinsand is only implemented for the Heun, RK23, RK45DP and RK56 solvers.
TODO
EnableCUDAgraphs) to disable the usage of CUDA Graphs, in case this causes issues on someone's system.minimize()andrelax()in the same manner.