PtychoFM: A Foundation Model for Ptychographic Imaging

Aileen Luo, Emon Dey, Ming Du, Tao Zhou, Peco Myint, Himanshu Goel, Shashank Subramanian, Xiangyu Yin, Tekin Bicer, Siniša Veseli, Cheng-Chu Chung, Jeffrey A. Klug, Aldo Peña Pérez, Llorenç Fanals-i-Batllori, Christopher Kenney, Henry Shi, Lorenzo Rota, Angelo Dragone, Zirui Gao, Douglas A. Bennett, John A. B. Mates, Leila R. Vale, Michael R. Vissers, Yi Jiang, Junjing Deng, Tejas Guruswamy, Varuni K. Sastry, Bowen Zheng, Takenori Shimamura, Oliver Hoidn, Aashwin Mishra, Hannah Parraga, Brandon Stone, Jonathan Baldwin, Aaron Michelson, Michael Wojcik, Xiaoyin Zheng, Robert Underwood, Yijiang Li, Jinxing Jiang, Nicholas Schwarz, Apurva Mehta, Johanna Nelson Weker, Hassina Bilheux, Joel N. Ullom, Alexander Hexemer, Antonino Miceli, Kibaek Kim, Hanfei Yan, Mathew J. Cherukara, Alec R. Sandy, Stefan Vogt, Laurent C. ChaponarXiv 2026

TL;DR

When imaging nanoscale structures with X-rays, physical lenses often get in the way, so scientists use ptychography—computing images from scattered light patterns. The catch is that solving the underlying math usually takes hours of finicky computation, leaving researchers flying blind during experiments. PtychoFM is a physics-aware foundation model that turns those cryptic scattering patterns into clear images on the fly at 200 frames per second, working even when experimental conditions get messy.

What Problem Does This Paper Address?

Imagine trying to photograph a microchip, except you have no lens and your camera can only record the brightness of scattered X-rays, completely losing the wave's phase (timing/structural information). Ptychography solves this "phase retrieval" puzzle by scanning an overlapping X-ray beam across a sample and using iterative algorithms to mathematically reconstruct both the object and the beam (probe).

While powerful, conventional iterative algorithms require hundreds to thousands of iterations per dataset and are notoriously sensitive to noise and tuning. Meanwhile, modern synchrotrons fire off hundreds of diffraction frames per second. Existing machine learning shortcuts are fast, but brittle—trained for one specific sample or beam setup, they fail to generalize when experimental conditions shift. Scientists desperately need a tool that is both fast enough for live feedback and flexible enough to handle brand-new samples.

Methods

PtychoFM pairs a foundation-model training strategy (broad pre-training plus light experiment-specific fine-tuning) with wave-propagation physics:

  • Hybrid Architecture: A Vision Transformer (ViT) encodes global, non-local relationships in a $256 \times 256$ diffraction pattern, while two Convolutional Neural Network (CNN) decoders reconstruct the local amplitude and phase images of the illuminated patch.
  • Unsupervised Physics-Aware Training: Crucially, PtychoFM needs no ground-truth object images to learn. During training, its predicted object patch is multiplied by a known probe and passed through a differentiable Fourier forward model to simulate a diffraction pattern. The network updates its weights simply by minimizing the mismatch between simulated and measured diffraction.
  • Single-Shot Edge Inference: At test time, the forward model is stripped away. A single GPU predicts patches directly from individual diffraction frames and stitches them together live.

Datasets

  • Simulated Pre-training Dataset: 50 million simulated diffraction patterns created by combining natural images from ImageNet (acting as synthetic amplitude/phase objects) with a library of real, experimentally reconstructed X-ray probes from three major facilities (APS, NSLS-II, and LCLS) spanning diverse focusing optics.
  • Experimental Fine-Tuning & Evaluation Datasets: Collected at synchrotron beamlines (primarily APS Sector 26 and NSLS-II). These include step-scan data on a 130 nm copper-based CMOS circuit (for fine-tuning, ~50,000 frames), tested out-of-distribution on continuous "fly-scan" data of a 28 nm CMOS chip, ptycho-tomography projections at different tilt angles, and a weakly scattering niobium Josephson junction.

Key Insights and Ideas

  • When "Knowing Less" Beats Classical Math: Standard iterative solvers assume the X-ray probe stays identical across the entire scan. In one test on a Josephson junction, scanning optics moved through an uneven background beam, violating this rule and causing classical algorithms to fail unless rescued by bespoke preprocessing. Because PtychoFM applies a learned prior to single frames without forcing dataset-wide probe consistency at inference, it effortlessly recovered the structure out of the box.
  • Physics Tames Data Hunger: Exploring Chinchilla-style scaling laws (from 3M to 724M parameters), the authors found that unlike Large Language Models—which suffer diminishing returns on repeated data—PtychoFM benefits from multiple passes over the same diffraction patterns, as the physics forward model tightly constrains valid solutions. Around 43M parameters proved a practical sweet spot.
  • Cross-Sample & Cross-Mode Transfer: Fine-tuning on slow step-scans of a thick copper chip successfully generalizes to rapid, motion-blurred fly-scans of smaller silicon/copper features and even niobium quantum circuits with vastly different refractive indices.

Key Results

  • Real-Time Speed: Streamed live from a synchrotron detector to a single edge GPU (NVIDIA RTX 6000 Pro), PtychoFM reconstructs up to 200 frames per second.
  • Low-SNR Quality: On noisy 200 Hz fly-scan data (only 5% exposure time of a high-SNR reference), PtychoFM outperformed classical DM, RAAR, and ePIE in full-field error (RMSE) and correlation (PCC), while exhibiting fewer periodic grid artifacts than top-performing iterative solvers (rPIE and LSQML).
  • Resolution Trade-off: Edge-response analysis yielded an effective spatial resolution of 85.5 nm for PtychoFM versus 41.2 nm for LSQML, an expected limit of single-frame inference compared to overlap-driven iterative refinement.
  • Massive Scale: Assembled a continuous 0.5 mm $\times$ 0.2 mm map from over 10 million diffraction patterns (250 scans over 27 hours), surviving beam drops and instabilities that would derail standard batch reconstructions.

Limitations and Future Work

  • Experiment-Specific Fine-Tuning Required: Pre-training cannot yet cover every possible photon energy, detector geometry, or noise profile. Users still need a small step-scan dataset—and one traditional iterative run to extract the probe—to fine-tune the model for a new beamline setup.
  • Single-Shot Blind Spots: Because each frame is predicted independently without enforcing overlap consistency, PtychoFM cannot refine scan positions, recover changing probes, or guarantee strictly quantitative full-field phase contrast (since diffraction is insensitive to constant phase offsets per patch).
  • Future Directions: The authors view PtychoFM as a scout rather than a replacement for iterative methods—envisioning hybrid ML-iterative pipelines for live probe updates, as well as autonomous "self-driving" experiments where AI agents read PtychoFM's live maps to decide where to scan next.

Summary updated

Abstract

Ptychography provides high-resolution lensless imaging across X-ray, electron, and optical microscopy, but reconstructing images from diffraction measurements generally requires computationally intensity iterative phase retrieval. These methods often require experiment-specific analysis, limiting real-time feedback as data acquisition rates increase. Here, we demonstrate PtychoFM, a physics-aware foundation model for ptychographic imaging that combines large-scale pre-training with experiment-specific fine-tuning to reconstruct complex object images directly from individual diffraction patterns. Trained using a differentiable forward model without object-space labels, PtychoFM transfers from step-scan training data on one sample to fly-scan measurements of other samples with different feature sizes, morphologies, and refraction indices. At a synchrotron beamline, diffraction frames were streamed from the detector to a single GPU for inference at up to 200 frames per second and returned for real-time visualization. PtychoFM provides a practical route to rapid, transferable ptychographic reconstruction and live experimental feedback under nonideal conditions.
BibTeX
@misc{luo2026ptychofm,
  author = {Aileen Luo and Emon Dey and Ming Du and Tao Zhou and Peco Myint and Himanshu Goel and Shashank Subramanian and Xiangyu Yin and Tekin Bicer and Siniša Veseli and Cheng-Chu Chung and Jeffrey A. Klug and Aldo Peña Pérez and Llorenç Fanals-i-Batllori and Christopher Kenney and Henry Shi and Lorenzo Rota and Angelo Dragone and Zirui Gao and Douglas A. Bennett and John A. B. Mates and Leila R. Vale and Michael R. Vissers and Yi Jiang and Junjing Deng and Tejas Guruswamy and Varuni K. Sastry and Bowen Zheng and Takenori Shimamura and Oliver Hoidn and Aashwin Mishra and Hannah Parraga and Brandon Stone and Jonathan Baldwin and Aaron Michelson and Michael Wojcik and Xiaoyin Zheng and Robert Underwood and Yijiang Li and Jinxing Jiang and Nicholas Schwarz and Apurva Mehta and Johanna Nelson Weker and Hassina Bilheux and Joel N. Ullom and Alexander Hexemer and Antonino Miceli and Kibaek Kim and Hanfei Yan and Mathew J. Cherukara and Alec R. Sandy and Stefan Vogt and Laurent C. Chapon},
  title = {{PtychoFM: A Foundation Model for Ptychographic Imaging}},
  year = {2026},
  eprint = {2611.32830},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.32830},
}
Figure