The core finding
The sim-to-real gap on real JWST spectra was not forward-model fidelity — the usual suspect. It was a radius/baseline degeneracy: inferring planet radius instead of fixing it turned an unusable importance-sampling ESS of 1 into a physical retrieval.
scroll to expand
Simulation-trained posteriors collapse on real JWST spectra, and the field's default explanation is forward-model error. Controlled ablations ruled that out here. The actual culprit was a radius/baseline degeneracy: with planet radius held fixed, the transit baseline had nowhere to go, importance-sampling ESS sat at 1, and best-fit χ²/dof was 301. Inferring radius as a parameter and calibrating against an independent nested-sampling reference brought χ²/dof to 0.06 and coverage from 2/7 to 7/7.
MIRAGE attacks the sim-to-real gap from both ends. On the domain-adaptation side, TauREx3 forward models are trained with correlated-noise injection so the encoder never sees a clean spectrum. On the inference side, an optimal-transport calibration step aligns the amortised posterior to a nested-sampling reference computed independently for each target. Neither half is enough on its own — the calibration is what converts a fast posterior into a trustworthy one.
The context encoder treats a spectrum as a sequence, not a vector. Each wavelength bin becomes a token carrying its flux, optionally its per-wavelength uncertainty σ, and an instrument embedding — so NIRSpec PRISM and NIRISS SOSS spectra can be fused in one model rather than one model per mode.
Tokens are projected to d_model and augmented with a sinusoidal wavelength positional encoding, so the transformer knows where in the band each bin sits regardless of how the instrument grid is sampled. Self-attention runs over all bins; mean-pooling and a linear head produce the context vector the flow-matching posterior conditions on.
It is registered into fm4ar's block registry as a SpectraEncoder block, replacing the stock DenseResidualNet context encoder — fm4ar itself stays unmodified, so upstream fixes keep applying. The method follows SpectraFM (Koblischke & Bovy 2024) and is independently reimplemented in PyTorch.
An optional covariance branch embeds out-of-transit residual frames, conditioning the posterior on the structure of correlated noise rather than only its scale.
def forward(self, context: Mapping[str, Tensor]) -> Tensor: wlen = context["wlen"] # (batch, seq) μm flux = context["flux"] # (batch, seq) # Multi-instrument fusion: one embedding per mode inst_emb = self.instrument_embedding( context["instrument_id"].long() ) # Token = [flux, (σ,) instrument embedding] feats = [flux.unsqueeze(-1)] if self.use_error_bars: feats.append(context["error_bars"].unsqueeze(-1)) feats.append(inst_emb) tokens = self.token_proj(torch.cat(feats, dim=-1)) tokens = tokens + self._wavelength_pe(wlen) # SpectraFM Eq. 2 encoded = self.transformer(tokens) return self.output_proj(encoded.mean(dim=1))
Coverage — parameters whose true value falls inside the credible interval, against an independent nested-sampling reference. Seven parameters per target.
The honest negative: noise-conditioning improved calibration on the synthetic benchmark but did not transfer to real data. Neither did CycleGAN domain translation over structured randomisation, nor higher-resolution opacity grids. All three ablations are reported rather than dropped.
The three targets span planet class, instrument, and data provenance — the method was not retuned between them.
| Target | Instrument | χ²/dof | Radius (truth) |
|---|---|---|---|
| WASP-39b | NIRSpec PRISM | 0.06 | 1.23 (1.28) RJ |
| WASP-96b | NIRISS SOSS | 0.079 | 1.196 (1.20) RJ |
| K2-18b | NIRISS | 0.20 | 0.233 (0.235) RJ |
| WASP-96b provenance | self-reduced, raw MAST | ||
WASP-96b is the strongest test: its spectrum was reduced end to end from raw ERO 2734 exposures with exoTEDRF and batman light-curve fitting, so no published reduction sits between the telescope and the retrieval. Its water feature comes back at 5.8σ.
K2-18b — a cold sub-Neptune observed with a different instrument — is the out-of-class case, and the only one that misses full coverage, at 6/7.