Skip to main content

Using Numba for GPU acceleration of Neutron Beamline Digital Twins...

by Coleman J Kendrick, Garrett E Granroth, Jiao Lin
Publication Type
Conference Paper
Book Title
Proceedings of the 22nd Python in Science Conference (SciPy 2023)
Publication Date
Page Numbers
46 to 52
Publisher Location
District of Columbia, United States of America
Conference Name
SciPy 2023, Scientific Computing with Python Conference
Conference Location
Austin, Texas, United States of America
Conference Sponsor
Conference Date

Digital twins of neutron instruments using Monte Carlo ray tracing have proven to be useful in neutron data analysis and verifying instrument and sample designs. However, these simulations can become quite complex and computationally demanding with tens of billions of neutrons. In this paper, we present a GPU accelerated version of MCViNE using Python and Numba to balance user extensibility with performance. Numba is an open-source just-in-time (JIT) compiler for Python using LLVM to generate efficient machine code for CPUs and GPUs with NVIDIA CUDA. The JIT nature of Numba allowed complex instrument kernels to be generated easily. Initial simulations have shown a speedup between 200-1000x over the original CPU implementation. The performance gain with Numba enables more sophisticated data analysis and impacts neutron scattering science and instrument design.