arXiv:2610.29362cs.LGOct 2026

Manuscript Offprint

arXiv:2610.29362

Compositional neural networks for multimodal X-ray and neutron scattering inversion

Valentin Munteanu, Alexander Hinderhofer, Dmitry Lapkin, Vladimir Starostin, Frank Schreiber

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

X-ray and neutron scattering are indispensable for structural characterization across condensed-matter physics and materials science. Yet, because scattering experiments generally record intensities without phase information, distinct structures can yield similar scattering patterns, rendering the corresponding inverse problems non-unique. This ambiguity can be reduced by combining complementary measurements, but their integration into machine-learning frameworks remains challenging. Here we introduce a modular framework for probabilistic multi-measurement analysis based on prior-amortized flow matching. Single-observation posterior estimators are trained separately for individual observation types or physical probes and combined only at inference time through a compositional sampler. This late fusion approach allows pretrained single-observation models to be reused without dedicated joint retraining. As a case in point, we consider reflectometry, which provides depth-resolved, nanometer-scale information about thin films and interfaces. Our single-observation demonstrations span X-ray, time-of-flight neutron and polarized neutron reflectometry. In separate co-refinement studies, task-matched estimators enable homogeneous composition across multiple neutron contrasts and heterogeneous multimodal composition of X-ray and neutron measurements. Together, these results establish compositional flow matching as a modular approach to uncertainty-aware inversion and co-refinement, with potential applicability to other scattering problems in which multiple observations constrain a common physical structure while retaining measurement-specific parameters.

†^{\dagger} frank.schreiber@uni-tuebingen.de

INTRODUCTION

X-ray and neutron scattering are central to structural characterization in condensed-matter physics and materials science [1, 2]. Since scattering experiments generally record intensities without phase information, recovering the underlying structure can lead to non-unique or only weakly constrained inverse problems. Distinct structures or parameter combinations can therefore yield similar scattering patterns, so a single best-fitting structure may conceal alternative solutions that remain compatible with the data. Two distinct strategies address this ambiguity. First, probabilistic inversion uses Bayesian inference to characterize a posterior distribution over structural and instrumental parameters rather than returning a single structure. Second, measurements with complementary sensitivities can be combined so that parameters weakly identified by one observation may be constrained by another.

Posteriors arising from scattering inverse problems can be strongly correlated, non-Gaussian or multimodal, and joint inference enlarges the parameter space by introducing both quantities shared across measurements and quantities specific to an individual contrast, probe or instrument. These characteristics motivate flexible posterior approximations that can represent complex uncertainty across a range of possible observations. Simulation-based inference (SBI) [3] provides such an approach by training neural networks on simulated parameter-observation pairs to approximate posterior distributions. In the amortized setting, the main computational burden is incurred during training, after which inference for new measurements can be performed rapidly. This makes SBI attractive for repeated or high-throughput analysis in experimental science, including at X-ray and neutron facilities.

Amortized posterior estimators are nevertheless typically trained for a fixed observation model, and a network trained for one simulator cannot in general be combined directly with a network trained for another. Training a new joint model for every number and combination of measurements would undermine the modularity and computational reuse offered by amortization. Compositional SBI provides a foundation for combining posterior information from multiple observations at inference time [4, 5]. Many joint inversion problems, however, require an additional structure of shared and local parameters. Some parameters describe a common physical system and must be shared across observations, whereas others describe a particular contrast, probe or instrument and remain local to an individual measurement. A modular multi-measurement framework must therefore combine separately trained estimators in a common parameter space while correcting the repeated contribution of the shared prior.

Flow matching [6, 7] provides a convenient basis for such a compositional construction. It trains a time-dependent vector field that transports samples from a simple base distribution to the target distribution along a prescribed probability path. Flow matching posterior estimation (FMPE) has been shown to be a competitive and scalable SBI method [8]. For the probability path used here, the learned vector field also determines a posterior score, which enables the information supplied by separately trained posterior estimators to be composed during sampling.

Specular X-ray and neutron reflectometry are indispensable techniques for resolving the depth-dependent structure and properties of thin films, multilayers and buried interfaces [9, 10]. Beyond its broad experimental relevance, reflectometry presents a demanding setting for this modular inference framework because it spans different probes, acquisition modes and observation structures. X-ray reflectometry (XRR) is sensitive to the electronic scattering length density (SLD), neutron reflectometry (NR) is sensitive to the nuclear SLD and can exploit isotope-dependent contrast, and polarized neutron reflectometry (PNR) further extends this sensitivity to magnetic properties through the spin dependence of the neutron interaction [11, 12]. Joint analysis of such measurements can constrain parameters that are weakly identified by an individual observation. The information gained nevertheless depends on the experimental design, measurement strategy, contrast engineering and model parameterization [13–16]. In practical reflectometry analysis, prior knowledge about plausible thickness ranges, expected material SLDs or instrumental conditions further constrains the solution space.

XRR is performed at synchrotron light sources [17, 18] or laboratory sources, whereas NR uses monochromatic or time-of-flight (TOF) reflectometers [19]. Energy-dispersive XRR and rotating-sample XRR geometries further illustrate the move towards rapid and parallel acquisition [20, 21]. Such developments increase the relevance of amortized analysis for in situ and time-resolved scattering experiments [22, 23]. PNR additionally requires polarization components such as polarizers, spin flippers and, depending on the experimental configuration, spin analyzers. In full spin-resolved PNR, four reflectivity cross sections are distinguished: the non-spin-flip channels R↑↑R^{\uparrow\uparrow} and R↓↓R^{\downarrow\downarrow}, and the spin-flip channels R↑↓R^{\uparrow\downarrow} and R↓↑R^{\downarrow\uparrow}, where the first and second arrows denote the incident and reflected neutron-spin states, respectively. Magnetization components parallel to the neutron-spin quantization axis contribute to the non-spin-flip channels, whereas components transverse to this axis couple the two spin states and generate spin-flip scattering. When the incident neutron polarization is selected but the reflected spin state is not resolved, the two measured intensities sum over the possible reflected spin states, such that R↑=R↑↑+R↑↓R^{\uparrow} = R^{\uparrow\uparrow} + R^{\uparrow\downarrow} and R↓=R↓↓+R↓↑R^{\downarrow} = R^{\downarrow\downarrow} + R^{\downarrow\uparrow}. For magnetization collinear with the neutron-spin quantization axis, the spin-flip cross sections vanish, and the measured intensities reduce to R↑=R↑↑R^{\uparrow} = R^{\uparrow\uparrow} and R↓=R↓↓R^{\downarrow} = R^{\downarrow\downarrow}, as assumed by the two-channel PNR model used for the experimental co-refinement examples in this work. Because these channels have fixed physical labels and ordering, they are treated as a single multichannel observation rather than as separate observations combined through compositional inference.

Previous machine-learning approaches to reflectometry have included point-estimator neural networks for XRR and NR and models incorporating prior knowledge [24–31]. Other studies have addressed high-throughput and autonomous-experiment settings [32–34], as well as variational-autoencoder analyses of PNR data [35]. Probabilistic approaches based on mixture-density networks or normalizing flows have further enabled uncertainty-aware single-observation inference [36, 37]. In particular, prior-amortized neural posterior estimation (PANPE) conditions the generative model not only on the measured data but also on user-provided prior bounds, allowing experiment-specific prior information to be changed at inference time without retraining [37]. These developments make fast single-observation inference increasingly realistic. However, they do not provide a modular mechanism for combining estimators trained separately for different measurements, experimental contrasts or physical probes.

Here we introduce a prior-amortized compositional flow matching framework for probabilistic reflectometry analysis. This work makes two closely connected contributions. First, we adapt prior-amortized flow matching posterior estimation to a broad range of experimentally relevant XRR, NR and PNR settings. Second, building on recent compositional SBI approaches [5], we introduce compositional posterior sampling for reflectometry and extend the formalism to accommodate shared and local parameter blocks. Specifically, we derive the composition equations for separately trained estimators whose parameter spaces comprise a common block of shared parameters together with observation-specific local parameters. The resulting sampler combines compatible posterior estimators trained separately for individual observations or physical probes. The user specifies which parameters are shared and which remain local, the score contribution from each estimator is embedded into the resulting joint parameter space, and the repeated contribution of the shared prior is corrected during composition. In reflectometry, shared parameters can include layer thicknesses and interfacial roughnesses, whereas contrast-dependent SLDs, backgrounds, scale factors and probe-specific scattering properties may remain local to individual observations. This supports homogeneous composition, in which the same trained model is reused across several observations with a common parameterization as in multi-contrast NR, and heterogeneous composition, in which separately trained XRR and (P)NR models are coupled through shared structural parameters. Throughout this work, multimodal refers to the combination of different experimental modalities or probes. Although demonstrated here for reflectometry, the shared-local compositional construction is applicable more broadly to X-ray and neutron scattering problems in which multiple observations constrain a common physical model while retaining measurement-specific parameters.

The remainder of the paper is organized as follows. We first demonstrate the approach on a sequence of reflectometry problems of increasing complexity, progressing from single-curve XRR and NR inference to multichannel PNR, multi-contrast NR co-refinement and multimodal XRR/PNR co-refinement. We then discuss the scope and limitations of the framework. The mathematical formulation, neural-network architecture, compositional sampler and training-data generation are provided in the Methods.