betaFeedback

WorksPhysics 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 ∼1σ\sim1σ on our benchmark models. We measure the gain of MAGI with statistical amplification 1/χ1/χ and computational speed-up SS: 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 ∼10−2\sim10^{-2} [4] down to ∼10−7 cts s−1 cm−2 keV−1\sim10^{-7}\,\mathrm{cts}\,\mathrm{s}^{-1}\,\mathrm{cm}^{-2}\,\mathrm{keV}^{-1} [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 (uru_r, uvu_v, ϕr\phi_r, ϕv\phi_v). 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 NeventsN_{\mathrm{events}} detector events from NcrossingsN_{\mathrm{crossings}} injected crossings, both arms, full Geant4 and MAGI re-injection, through the identical mass model, binary and scoring, we compare

R=NeventsMAGI/NcrossingsMAGINeventsreal/Ncrossingsreal.(1)R = \frac{N_{\mathrm{events}}^{\mathrm{MAGI}}/N_{\mathrm{crossings}}^{\mathrm{MAGI}}}{N_{\mathrm{events}}^{\mathrm{real}}/N_{\mathrm{crossings}}^{\mathrm{real}}}. \tag*{(1)}

At R=1R = 1 a MAGI crossing yields events at the real rate. The crossing efficiency χ=Ncrossingsreal/Nprimariesreal\chi= N_{\mathrm{crossings}}^{\mathrm{real}}/N_{\mathrm{primaries}}^{\mathrm{real}} is the geometrical and physical attenuation of the outer mass. The statistical amplification ε=R/χ\varepsilon= R/\chi is the gain in statistics per generated crossing, and an ideal surrogate returns 1/χ1/\chi.

On first benchmark model (IAPS Triple) the real arm is a run of 2.7×1092.7 \times10^{9} to 5.4×10105.4 \times10^{10} 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 8×1058 \times10^{5} to 4×1064 \times10^{6} crossings per source. The ratio obtained for this model is 0.97±0.020.97 \pm0.02 (Figure 1a) over the sum of all sources. A second benchmark model (SRON XFDM) gives R=1.01±0.03R = 1.01 \pm0.03 over all deposits (2550 against 2565 events, 6.0×1066.0 \times10^{6} crossings per arm) and 1.05±0.041.05 \pm0.04 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 ±1σ\pm1\sigma Poisson bands and MAGI-to-full ratios in the bottom panels. (a) IAPS Triple, v1.0, five sources (232Th^{232}\mathrm{Th}, 226Ra^{226}\mathrm{Ra}, 40K^{40}\mathrm{K}, γ\gamma, μ\mu). (b) SRON XFDM cosmic rays, v1.0, against 2.4×1062.4 \times10^{6} re-injected real crossings.

Amplification and speed-up

Amplification 1/χ1/\chi measures detector events gained per generated crossing instead of per thrown primary. Speed-up SS compares computational cost: a crossing starts inside the assembly and costs more to transport than a primary, so

S=1χcprimaryccrossing,(2)S = \frac{1}{\chi}\frac{c_{\mathrm{primary}}}{c_{\mathrm{crossing}}}, \tag*{(2)}

with both costs in core-hours, cprimaryc_{\mathrm{primary}} the whole-run cost per primary and ccrossingc_{\mathrm{crossing}} the inner-transport cost per injected crossing. The speed-up SS 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 N0N_0 be the primaries behind the training set, Couter=N0cprimaryC_{\mathrm{outer}} = N_0c_{\mathrm{primary}} the cost of recording it, CtrainC_{\mathrm{train}} the training cost, and cgenc_{\mathrm{gen}} the generation cost of the re-injected particle. For a simulation target of A×N0A\times N_0 primaries, the net speed-up is the full cost over the MAGI cost,

Snet(A)=ACouterCouter+Ctrain+Cre−inj,(3)S_{\mathrm{net}}(A)=\frac{A C_{\mathrm{outer}}}{C_{\mathrm{outer}}+C_{\mathrm{train}}+C_{\mathrm{re-inj}}}, \tag*{(3)}

where Cre−inj=ACouterχ(cgen+ccrossing)cprimaryC_{\mathrm{re-inj}}=A C_{\mathrm{outer}}\chi\frac{(c_{\mathrm{gen}}+c_{\mathrm{crossing}})}{c_{\mathrm{primary}}} is the re-injection cost. Snet(A)S_{\mathrm{net}}(A) tends to SS for large AA and sits just below 1 at A=1A=1. Table 1 reports 232Th{}^{232}\mathrm{Th}, 226Ra{}^{226}\mathrm{Ra}, 40K{}^{40}\mathrm{K} and cosmic rays (CR, γ\gamma and μ\mu) in the two tested models, on the laptop, using MAGI v1.0 and 6 parallel jobs per arm. Generating 10610^6 crossings takes 46 s on one thread (cgen=1.27×10−8c_{\mathrm{gen}}=1.27\times10^{-8} core-h per crossing). Training on the ASI-SSDC Hub CPU (Xeon Gold 6252N, 2.3 GHz, 96 cores, 128 GiB, 12 threads) takes 2.9×1032.9\times10^3 to 7.3×1037.3\times10^3 s for 40 epochs plus the prior refit, that is 10 to 24 core-h.

SRON XFDMIAPS Triple
232Th{}^{232}\mathrm{Th}226Ra{}^{226}\mathrm{Ra}40K{}^{40}\mathrm{K}CR232Th{}^{232}\mathrm{Th}226Ra{}^{226}\mathrm{Ra}40K{}^{40}\mathrm{K}γ\gammaμ\mu
N0 (109)N_0\ (10^9)3.63.6360.545.45.4542.71.8
1/χ1/\chi (amplification)4646016542144.566886912175276153
cprimary (10−8)c_{\mathrm{primary}}\ (10^{-8})10.17.831.2828.616.814.32.5412.062.6
ccrossing (10−7)c_{\mathrm{crossing}}\ (10^{-7})3.313.633.3919422.620.325.330.6232
SS, Eq. (2)1421302472.1506112210.84.1
SnetS_{\mathrm{net}}, A=10A=108.88.69.11.78.18.49.15.02.9
SnetS_{\mathrm{net}}, A=100A=1005653682.13337549.64.0
SnetS_{\mathrm{net}}, A=103A=10^31191101902.1475710810.64.1
SnetS_{\mathrm{net}}, A→∞A\to\infty1371252382.1496112210.84.1

Table 1. Amplification and speed-up on two mass models, cc in core-h. AA is in units of N0N_0.

The computational gain strictly follows the source rarity. The heavily attenuated 40K{}^{40}\mathrm{K} achieves the highest performance, reaching S=247S=247 (SRON XFDM) and 122 (IAPS Triple), with net values of 190 and 108 at A=103A=10^3, followed by the intermediate radioisotopes 232Th{}^{232}\mathrm{Th} and 226Ra{}^{226}\mathrm{Ra}. This behavior reflects the balance between physical attenuation 1/χ1/\chi and computational cost: inner transport per injected crossing (ccrossingc_{\mathrm{crossing}}) is intrinsically more expensive than outer primary transport (cprimaryc_{\mathrm{primary}}). 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 S=10.8S=10.8, 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 zz. 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 % (R=0.97±0.02R = 0.97 \pm0.02, five sources pooled) on IAPS Triple and on SRON XFDM (R=1.05±0.04R = 1.05 \pm0.04). 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. [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. [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. [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. [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. [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. [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. [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. [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. [9]Kingma, D.P., Welling, M.: Auto-Encoding Variational Bayes. In: International Conference on Learning Representations (ICLR) (2014)arxiv.org/abs/1312.6114
  10. [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. [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. [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. [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. [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

Paper details

vlnc:W_2a6te6y9
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents