In this paper
AbstractIntroductionMethodValidationAmplification and speed-upLimitationsConclusionsReferencesWorksPhysics and Astronomy
MAGI (Multivariate Autoencoder for particle Generative Inference): a generative Machine Learning framework for accelerated multi-stage particle simulations
Abstract
Monte Carlo particle simulations are hindered by the computational cost of particle transport. This is especially true when large mass surrounds a small sensitive volume. MAGI is a conditional variational autoencoder that learns the joint energy, position and direction distribution of particles crossing a closed surface in a multi-stage simulation, to be resampled and re-injected in a smaller mass model. We validated it generating crossings, variables describing particle features later in the simulation, injecting them into the same Geant4 mass model and comparing the spectrum and counts at detector level with full simulation. Rates per injected crossing agree with unity at on our benchmark models. We measure the gain of MAGI with statistical amplification and computational speed-up : the first goes from 150 for high-statistics cosmic rays to 12000 for rare radioactive decays, while the latter ranges from 2.1 to almost 240, depending on source type and mass model. These first results validate MAGI v1.0.0 released on GitHub.
Introduction
Monte Carlo simulations using toolkits like Geant4 [1, 2, 3] are essential for background evaluation and sensitivity optimization in particle physics and astrophysics. However, in low-background experiments, particularly in cryogenic X-ray arrays with background requirements typically ranging from [4] down to [5], particle transport through complex surrounding structures and shielding poses a critical computational bottleneck. High physical attenuation or low geometric acceptance means that most simulated primaries never interact with the active region, forcing redundant outer transport computations at every inner design iteration.
While generative surrogates emulate energy showers in fixed geometries [6, 7] and phase-space interfaces like MCPL (Monte Carlo Particle Lists) [8] resample static recorded events without statistical amplification, MAGI (Multivariate Autoencoder for particle Generative Inference) bridges this gap. MAGI models the joint phase-space distribution of particles crossing a virtual surface enclosing the instrument. Decoupling the outer, design-invariant mass allows MAGI to rapidly generate synthetic crossings for downstream Geant4 re-injection, achieving both computational speed-up and statistical amplification.
Method
A virtual spherical shell encloses the detector assembly and records inward particle crossings in a primary Geant4 run. Geometry modifications confined within the shell can then be evaluated by generating synthetic crossings and transporting them inward.
MAGI is a conditional variational autoencoder (cVAE) [9, 10] conditioned on particle species. A crossing consists of energy and four quantile-transformed directional/positional variables (, , , ). The energy head combines a spline-flow continuum [11] with discrete components pinned at fluorescence lines under a focal objective [12]. The latent prior uses a conditional coupling transform [13, 14]. MAGI can also be conditioned on primary type and energy, preserving primary multiplicity.
Validation
With detector events from injected crossings, both arms, full Geant4 and MAGI re-injection, through the identical mass model, binary and scoring, we compare
At a MAGI crossing yields events at the real rate. The crossing efficiency is the geometrical and physical attenuation of the outer mass. The statistical amplification is the gain in statistics per generated crossing, and an ideal surrogate returns .
On first benchmark model (IAPS Triple) the real arm is a run of to primaries per source, performed on our cluster (Dual socket Xeon 8268, 96 cores per 6 nodes, 384GiB, 540 threads) and the MAGI arm on a MacBookAir (AppleM1, 4 performance and 4 efficiency cores, 16GB) with to crossings per source. The ratio obtained for this model is (Figure 1a) over the sum of all sources. A second benchmark model (SRON XFDM) gives over all deposits (2550 against 2565 events, crossings per arm) and in 1 keV to 1 MeV, plotted (Figure 1b). Our validation is performed with Geant4 10.4.3.
Figure 1. Detector response, MAGI against full Geant4 in the same mass model, with Poisson bands and MAGI-to-full ratios in the bottom panels. (a) IAPS Triple, v1.0, five sources (, , , , ). (b) SRON XFDM cosmic rays, v1.0, against re-injected real crossings.
Amplification and speed-up
Amplification measures detector events gained per generated crossing instead of per thrown primary. Speed-up compares computational cost: a crossing starts inside the assembly and costs more to transport than a primary, so
with both costs in core-hours, the whole-run cost per primary and the inner-transport cost per injected crossing. The speed-up of Eq. (2) omits the outer campaign that records the training set, and training time and represents a theoretical limit given a specific configuration. Let be the primaries behind the training set, the cost of recording it, the training cost, and the generation cost of the re-injected particle. For a simulation target of primaries, the net speed-up is the full cost over the MAGI cost,
where is the re-injection cost. tends to for large and sits just below 1 at . Table 1 reports , , and cosmic rays (CR, and ) in the two tested models, on the laptop, using MAGI v1.0 and 6 parallel jobs per arm. Generating crossings takes 46 s on one thread ( core-h per crossing). Training on the ASI-SSDC Hub CPU (Xeon Gold 6252N, 2.3 GHz, 96 cores, 128 GiB, 12 threads) takes to s for 40 epochs plus the prior refit, that is 10 to 24 core-h.
| SRON XFDM | IAPS Triple | ||||||||
| CR | |||||||||
| 3.6 | 3.6 | 36 | 0.54 | 5.4 | 5.4 | 54 | 2.7 | 1.8 | |
| (amplification) | 464 | 601 | 6542 | 144.5 | 668 | 869 | 12175 | 276 | 153 |
| 10.1 | 7.83 | 1.28 | 28.6 | 16.8 | 14.3 | 2.54 | 12.0 | 62.6 | |
| 3.31 | 3.63 | 3.39 | 194 | 22.6 | 20.3 | 25.3 | 30.6 | 232 | |
| , Eq. (2) | 142 | 130 | 247 | 2.1 | 50 | 61 | 122 | 10.8 | 4.1 |
| , | 8.8 | 8.6 | 9.1 | 1.7 | 8.1 | 8.4 | 9.1 | 5.0 | 2.9 |
| , | 56 | 53 | 68 | 2.1 | 33 | 37 | 54 | 9.6 | 4.0 |
| , | 119 | 110 | 190 | 2.1 | 47 | 57 | 108 | 10.6 | 4.1 |
| , | 137 | 125 | 238 | 2.1 | 49 | 61 | 122 | 10.8 | 4.1 |
Table 1. Amplification and speed-up on two mass models, in core-h. is in units of .
The computational gain strictly follows the source rarity. The heavily attenuated achieves the highest performance, reaching (SRON XFDM) and 122 (IAPS Triple), with net values of 190 and 108 at , followed by the intermediate radioisotopes and . This behavior reflects the balance between physical attenuation and computational cost: inner transport per injected crossing () is intrinsically more expensive than outer primary transport (). Conversely, high-statistics and penetrating sources gain the least: gammas, muons, and cosmic rays require significantly higher transport cost per crossing than radiosources, yielding more modest speed-ups of , 4.1, and 2.1, respectively. All reported metrics represent single-laptop benchmarks.
Limitations
MAGI v1.0 exhibits structural limits arising from cVAE latent capacity bounds (prior-posterior mismatch) and the conditional independence of decoding heads given . While localized spectral resolution defects (such as fluorescence line smearing) are mitigated in v1.0 via explicit delta-line sampling, fundamental head decorrelation and shower-context conservation cannot be resolved without structural changes. The implementation of autoregressive prior flows, coupled flow heads, and context-aware shower conditioning is deferred to the MAGI v2.0 architecture in development.
Conclusions
MAGI reproduces the detector response of a full Geant4 run within 3 % (, five sources pooled) on IAPS Triple and on SRON XFDM (). On a laptop it amplifies statistics by 464 to 12175 and speeds up the computation by 50 to 247 for radioactive sources depending on the mass model. This tool improves the efficiency and the affordability of particle simulations, demonstrating also the feasibility of running the same setup on a laptop instead of a dedicated cluster. The architecture and the user manual are available on GitHub with full package and examples.
Declarations. Licence: GPL v3.0, github.com/francescomonastra/MAGI. Funding: ASI-INAF agreement n. 2025-33-HH.0. Use of Generative AI: During the preparation of this work, the authors used generative AI model (Claude by Anthropic) for language polishing, text editing, and LaTeX formatting support. The authors reviewed and edited all content as needed and take full responsibility for the final text and data. Competing interests: none.
References
- [1]Agostinelli, S., et al.: Geant4—a simulation toolkit. Nuclear Instruments and Methods in Physics Research A 506(3), 250–303 (2003) https://doi.org/10.1016/S0168-9002(03)01368-8
- [2]Allison, J., et al.: Geant4 developments and applications. IEEE Transactions on Nuclear Science 53(1), 270–278 (2006) https://doi.org/10.1109/TNS.2006.869826
- [3]Allison, J., et al.: Recent developments in Geant4. Nuclear Instruments and Methods in Physics Research A 835, 186–225 (2016) https://doi.org/10.1016/j.nima.2016.06.125
- [4]Lotti, S., et al.: Review of the Particle Background of the Athena X-IFU Instrument. The Astrophysical Journal 909(2), 111 (2021) https://doi.org/10.3847/1538-4357/abd94c
- [5]Vaccaro, D., Gottardi, L., Akamatsu, H., van der Kuur, J., Nagayoshi, K., Taralli, E., de Wit, M., Ravensberg, K., Gao, J.R., den Herder, J.W.A.: Background rates of X-ray transition-edge sensor micro-calorimeters under a frequency domain multiplexing readout for solar axion-like particles’ detection. Review of Scientific Instruments 94(4), 043104 (2023) https://doi.org/10.1063/5.0142367
- [6]Paganini, M., Oliveira, L., Nachman, B.: CaloGAN: Simulating 3D high energy particle showers in multilayer electromagnetic calorimeters with generative adversarial networks. Physical Review D 97(1), 014021 (2018) https://doi.org/10.1103/PhysRevD.97.014021
- [7]Krause, C., Shih, D.: Fast and accurate simulations of calorimeter showers with normalizing flows. Physical Review D 107(11), 113003 (2023) https://doi.org/10. 1103/PhysRev.D.107.113003 arXiv:2106.05285
- [8]Kittelmann, T., Klinkby, E., Knudsen, E.B., Willendrup, P., Cai, X.X., Kanaki, K.: Monte Carlo Particle Lists: MCPL. Computer Physics Communications 218, 17–42 (2017) https://doi.org/10.1016/j.cpc.2017.04.012
- [9]Kingma, D.P., Welling, M.: Auto-Encoding Variational Bayes. In: International Conference on Learning Representations (ICLR) (2014)arxiv.org/abs/1312.6114
- [10]Sohn, K., Lee, H., Yan, X.: Learning Structured Output Representation using Deep Conditional Generative Models. In: Advances in Neural Information Processing Systems (NeurIPS), vol. 28 (2015)
- [11]Durkan, C., Bekasov, A., Murray, I., Papamakarios, G.: Neural Spline Flows. In: Advances in Neural Information Processing Systems (NeurIPS), vol. 32 (2019)arxiv.org/abs/1906.04032
- [12]Lin, T.-Y., Goyal, P., Girshick, R., He, K., Dollár, P.: Focal Loss for Dense Object Detection. In: IEEE International Conference on Computer Vision (ICCV) (2017)
- [13]Dinh, L., Sohl-Dickstein, J., Bengio, S.: Density Estimation using Real NVP. In: International Conference on Learning Representations (ICLR) (2017)arxiv.org/abs/1605.08803
- [14]Tomczak, J.M., Welling, M.: VAE with a VampPrior. In: International Conference on Artificial Intelligence and Statistics (AISTATS) (2018)arxiv.org/abs/1705.07120
