SciPy 2024

Monte Carlo/Dynamic Code: Performant and Portable High-Performance Computing at Scale via Python and Numba
07-10, 11:25–11:55 (US/Pacific), Room 315

Monte Carlo / Dynamic Code (MC/DC) is a performant and scalable Monte Carlo radiation transport simulation package with GPU and CPU support. It is written entirely in Python and uses Numba to accelerate Python code to CPU and GPU targets. This allows MC/DC to be a portable, easily installable, single language source code ideal for rapid numerical methods exploration at scale. We will discuss the benefits and drawbacks of such a scheme and make comparisons to traditionally compiled codes as well as those written using other modern high-level languages (i.e., Julia).


Predicting how neutrons move through space and time, and change speed and direction of travel, are important when modeling inertial confinement fusion reactions, pulsed neutron sources, nuclear criticality safety experiments, and other systems. This can be modeled with a Monte Carlo simulation, where particles with statistical importance are created and transported to produce a particle history. A particle’s path and the specific set of events that occur within its history are governed by pseudo-random numbers, known probabilities (e.g., from material data), and known geometries. Information about how particles move and/or interact with the system is tallied to construct a histogram solution of parameters of interest with an associated statistical error from the Monte Carlo process. Traditional Monte Carlo simulations for steady-state systems converge slowly. When simulating dynamic systems that evolve with time, novel numerical methods are required to compute a solution performantly. We designed Monte Carlo / Dynamic Code (MC/DC) to explore such novel time-dependent numerical methods on modern high-performance computing systems. In this talk we will discuss the acceleration techniques used in MC/DC.

MC/DC can run in an unaccelerated, pure Python mode where initial development and proofs-of-concept for numerical methods can be designed. However, pure Python is often too slow to compute solutions to problems of interest in a timely manner. For those problems MC/DC uses the mpi4py package for distributed-memory parallelism and the Numba compiler to generate performant compute kernels for a desired hardware target from the same source code. Currently supported targets include ARM64, x86, and POWER9 CPUs as well as Nvidia GPUs with ongoing work to support AMD GPUs. This allows for code portability both between modern high-performance compute (HPC) systems with differing architectures, as well as between individual development and user machines. We will show how using this development scheme lets MC/DC run at the scale of tens of thousands of processors and approaches the speed of traditionally developed codes.

We will discuss the benefits and drawbacks of using a Python–Numba development scheme versus traditionally developed codes and those written using other modern high-level performance languages (i.e., Julia). We will also discuss our experience in how developer workflow and group dynamics change because of this Python-based approach—easing everything from install and environment management to continuous integration in an open-source setting. We will show how this has allowed MC/DC to grow from its birth less than two years ago, into a portable codebase that supports fully performant neutron transport and investigations of novel algorithms on modern HPC systems.

Piper is a mechanical engineering PhD student at Oregon State University where she works with Dr. Kyle Niemeyer in the Center for Exascale Monte Carlo Neutron Transport (CEMeNT). Her current work focuses on enabling both Nvidia and AMD GPU support on Monte Carlo / Dynamic Code (MC/DC) a Python, high performance, fully transient neutron transport application, built for rapid numerical methods exploration. She also works on developing novel transient deterministic neutron transport algorithms for GPU accelerators. She has previously worked at Advanced Miro Devices (AMD) and Los Alamos, Argonne, and Thomas Jefferson National Labs. Piper has her MS in mechanical engineering from Oregon State University and her BS in mechanical engineering from the Oregon Institute of Technology. She expects to graduate with her PhD sometime in 2025.