Skip to content

Add optional CUDA tests on a simulated H100 - #206

Open
saqibkh wants to merge 1 commit into
mumax:devfrom
saqibkh:add-gpu-sim-ci
Open

saqibkh wants to merge 1 commit into
mumax:devfrom
saqibkh:add-gpu-sim-ci

Conversation

@saqibkh

@saqibkh saqibkh commented Nov 8, 2026

Copy link
Copy Markdown

The CI has no job that runs the mumax+ tests, because the hosted runners have no GPU (the only workflow today builds release wheels). This adds a separate, optional workflow (gpu-sim.yml) that builds the Python package and runs the pytest suite on a simulated NVIDIA H100 provided by PantheonSim, via the pantheongpu/setup-pantheonsim action (pinned by SHA). I am the author of PantheonSim, so please weigh this accordingly.

It is not meant to be a required check, and it does not replace testing on real GPUs. A simulator cannot reproduce hardware-specific behavior or timing, so I see it as a way to catch CUDA-only breakage in pull requests when nobody has a GPU handy.

What it does

  • Builds the package with pip install . (both the single and double precision modules) and CUDA 13.0, then runs pytest -m "not slow and not mumax3" test with vgpu run.
  • Two things are needed because of the simulator: PTX-only device code (the simulator JIT-compiles PTX and does not run SASS) and a shared CUDA runtime. CMakeLists.txt hardcodes CMAKE_CUDA_ARCHITECTURES native, which needs a GPU at configure time, so a sed in the CI checkout replaces that line with 90-virtual and CMAKE_CUDA_RUNTIME_LIBRARY Shared. No source file in the repository is changed. If you would rather have a CMake option for the architecture, I am happy to send that instead.
  • src/cmd installs its executable to $CONDA_PREFIX/bin, so the job sets CONDA_PREFIX to its venv.
  • cuFFT and cuRAND come from the CUDA toolkit (library-path: 'false').
  • Triggers: workflow_dispatch and pull_request against dev, path-filtered to src/, mumaxplus/, test/, CMakeLists.txt, setup.py, pyproject.toml and the workflow itself. A concurrency group cancels older runs, and ccache is used for the CUDA objects.

What was left out

  • The slow and mumax3 tests, as in the README.
  • Two single-precision tests are deselected, with comments in the workflow:
    • test_average.py::TestAverage::test_average_zeeman_energy_geometry expects 0.5 * E1 == E2 to rtol=1e-12. The stray field between the two magnets (an FFT) adds float32 rounding noise, and the simulated cuFFT rounds differently from the real one. With the stray field source disabled the simulator gives exactly half, like a real GPU.
    • test_strayfield.py::TestEnableStrayFields::test_enable_as_stray_field_source uses random grid sizes and an absolute tolerance of 1e-10 on float32 sums. It is marginal on real hardware as well (I saw differences up to 6e-11 on an RTX 3060, against the 1e-10 limit), and it failed in about one of seven simulator runs. Loosening that tolerance would make it stable everywhere.
  • Only one GPU architecture (an H100) and one CUDA version (13.0) are covered.

Result on a fork

453 passed, 102 deselected (the 102 are the slow/mumax3 tests and the two above). The whole job took about 45 minutes on a cold run: about 16 minutes of that is the action building the simulator the first time, the package build takes about 5 minutes, and the tests about 24 minutes (test_frozenspins_inhomogeneous alone is about 10 minutes on the hosted runner).

Run: https://github.com/saqibkh/plus/actions/runs/42464335925

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant