Skip to content

Collection - Run Struphy kernels on NVIDIA GPUs (CUDA) #650

Open
17 of 23 issues completed
Open

Description

@max-models

Tracking issue for running Struphy's compute kernels on NVIDIA GPUs, next to the existing pyccel (CPU) kernels.

The design, principles, per-PR details and open questions are in CUDA_STRATEGY.md, which is kept up to date in each PR. This issue tracks progress. Each step is a small PR that keeps the CPU code path working and tested. The PRs are stacked: each branch contains the previous one, so they are reviewed and merged in order.

Goal: a developer adding a kernel creates a folder <package>/kernels/<name>/ with:

  • the pyccel kernel <name>_kernels.py;
  • an __init__.py that declares <name> = Kernel.from_folder(__name__, structs=CUDA_STRUCTS);
  • optionally, <name>_cuda.cu, plus its parity cases in pic/tests/cuda_parity_cases.py.

Loading, dispatch and the pyccel/CUDA parity tests are done by the infrastructure. The parity tests run on a GPU, and without one through CPU emulation. On the GPU, a kernel without a CUDA version raises a clear error instead of silently falling back to the CPU.

Where things live:

  • Infrastructure: cunumpy 0.6. Kernel, KernelCatalog, PyccelKernel and CudaKernel are in cunumpy.kernels; CudaStructArguments, CudaStruct and write_cuda_header are in cunumpy.arguments; the array views come from cunumpy/array_view.cuh; the testing helpers are in cunumpy.kernel_testing.
  • Argument classes, in pairs in kernel_arguments/: a pyccel class (MarkerArguments, DerhamArguments, DomainArguments, LocalProjectorsArguments) for the NumPy backend, and a CUDA class (Cuda<Name>) with the same constructor for the CuPy backend. The owner (Particles, Derham, Domain, the local projectors) creates the one for its backend.
  • CUDA kernels see only the C structs generated from those classes (pusher_args.cuh, local_projectors_args.cuh).
  • FEEC data on the GPU (stencil vectors and matrices, MPI exchange, one GPU per rank) is in feectools.

Done

Open PRs (merge in this order)

  • PR 17: feectools with CUDA (CUDA PR 17 - struphy on the feectools CUDA stack #680, base devel): the feectools submodule points at devel-tiny, which contains the feectools CUDA stack, and pyproject.toml pins feectools>=0.3.1, <=0.3.1.
  • PR 18: Geometry evaluation on the GPU for all analytic mappings (CUDA PR 18 - Geometry evaluation on the GPU for all analytic mappings #681):
    • CUDA versions of kernel_evaluate_pic, kernel_evaluate, kernel_pullpush_pic and kernel_pullpush, with the full metric chain (f, df, det_df, df_inv, g, g_inv, pull/push) for kind_map 10–12, 20–22 and 30–32;
    • the Cuboid-only restriction of all CUDA kernels is lifted, and CuPy particle runs work again.
  • PR 19: Spline mappings on the GPU (CUDA PR 19 - Spline mappings on the GPU #683, kind_map 0–2):
    • DomainArgs gets array views for t1..3, ind1..3 and cx/cy/cz;
    • IGAPolarCylinder, IGAPolarTorus, Tokamak, GVEC and DESC can be created on CuPy (their setup runs on the host);
    • device versions of spline_3d, spline_2d_straight and spline_2d_torus.
  • PR 20: Use cunumpy 0.6.0 (Use cunumpy 0.6.1 #685): new import locations (cunumpy.kernels, cunumpy.arguments) and regenerated headers. It needs Update to cunumpy 0.6.1 feectools#94 (feectools on cunumpy 0.6), which it points its submodule at.

None of these PRs has run on a GPU. The CPU emulation (every CUDA kernel compared with pyccel without a GPU) and the CPU regression tests are the gate so far.

Next steps

Each step is a sub-issue, labelled GPU and CUDA:

  1. Merge the open CUDA PRs and release feectools on cunumpy 0.6 #686 Merge the open CUDA PRs and release feectools on cunumpy 0.6
  2. First GPU run of the CUDA tests (H100) #687 First GPU run of the CUDA tests (H100)
  3. 6D array views in cunumpy for the matrix accumulations #688 6D array views in cunumpy for the matrix accumulations (vlasov_maxwell, linear_vlasov_ampere)
  4. Run VlasovAmpereOneSpecies end to end on the GPU #689 Run VlasovAmpereOneSpecies end to end on the GPU (including when kernels are compiled)
  5. Decide between hand-written CUDA and code generation before the guiding-centre kernels #690 Decide between hand-written CUDA and code generation before the guiding-centre kernels
  6. Port the remaining models, in the porting order of CUDA_STRATEGY.md:
  7. What still runs only on the host:
  8. Multi-rank marker exchange with CUDA-aware MPI #698 Multi-rank marker exchange with CUDA-aware MPI
  9. GPU runner in CI for the CUDA tests #699 GPU runner in CI for the CUDA tests
  10. Smaller items:

Earlier sub-issues: #411, #672, #678 and #342 (open), and #673, #674, #675 and #134 (closed).

Unrelated bugs found along the way go into their own issues and PRs.

🤖 Generated with Claude Code

Activity

  1. added
    GPURunning Struphy on GPUs
    CUDACUDA kernels and the CUDA porting (see #650)
    on Oct 7, 2026
  2. 23 remaining items

  3. changed the title [-]Run Struphy kernels on NVIDIA GPUs (CUDA)[/-] [+]Collection - Run Struphy kernels on NVIDIA GPUs (CUDA)[/+] on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CUDACUDA kernels and the CUDA porting (see #650)CollectionGPURunning Struphy on GPUsenhancementNew feature or requesthigh

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions