Autonomous Algorithm Discovery for Ptychography via Evolutionary LLM Reasoning
Authors: Xiangyu Yin, Ming Du, Junjing Deng, Zhi Yang, Yimo Han, Yi Jiang
Organizations: Advanced Photon Source, Argonne National Laboratory, Lemont, IL, USA · Department of Materials Science and NanoEngineering, Rice University, Houston, TX, USA
Ptychography is a computational imaging technique widely used for high-resolution materials characterization, but high-quality reconstructions often require the use of regularization functions that largely remain manually designed. We introduce Ptychi-Evolve, an autonomous framework that uses large language models (LLMs) to discover and evolve novel regularization algorithms. The framework combines LLM-driven code generation with evolutionary mechanisms, including semantically-guided crossover and mutation. Experiments on three challenging datasets (X-ray integrated circuits, low-dose electron microscopy of apoferritin, and multislice imaging with crosstalk artifacts) demonstrate that discovered regularizers outperform conventional reconstructions, achieving up to +0.26 SSIM and +8.3~dB PSNR improvements. Besides, Ptychi-Evolve records algorithm lineage and evolution metadata, enabling interpretable and reproducible analysis of discovered regularizers.
Figures & tables
Figure 1: System architecture of Ptychi-Evolve showing the discovery loop. The LLM Engine generates regularizer code, which is executed by the Pty-Chi reconstruction library. The Evaluator assesses reconstruction quality and records metrics to the History Manager. Context from the history informs both the Evolution Controller (for selecting parent algorithms and actions) and the LLM Engine (for code generation). The Evolution Controller triggers actions (generate, tune, crossover, or mutate) that prompt the LLM to produce new regularizer variants.
Dataset
Algorithms
Success
Best
Δ SSIM
Δ PSNR
Duration
X-ray IC
100
83%
0.785
+0.26
+8.3 dB
16.5 hrs
Apoferritin
147
97%
0.836
+0.12
+3.2 dB
29.5 hrs
Multislice
97
94%
0.871
+0.18
+8.0 dB
10.5 hrs
Table 1: Discovery Statistics and Performance. Best reports the discovery-evaluation SSIM at the fixed discovery horizon (IC: 3000 iterations; apoferritin and multislice: 1000). Δ SSIM and Δ PSNR report improvement of the best discovered regularizer over the baseline at the representative comparison iteration in Figure 3 (IC: 3000 iterations; apoferritin: 1000; multislice: 1000) using the same evaluation references as in Figure 2 . For multislice, Δ values are computed on the mean across layers.
Figure 2: Visual comparison of reconstructed phase images at representative iterations. Columns show a reference image, baseline reconstruction, and best discovered regularizer. For multislice and apoferritin, the reference is the simulated ground-truth phase; for X-ray IC, the reference is a long-iteration (i.e., 10,000) reconstruction used as an evaluation reference in the absence of ground truth. SSIM values overlaid on baseline/best are computed against the corresponding reference, and all images within each row share a unified color scale (shown by the colorbar on the right). X-ray IC is shown at 3000 iterations; apoferritin and multislice are shown at 1000 iterations.
Figure 3: Convergence comparison showing SSIM, PSNR, RMSE, and MAE versus reconstruction iterations for baseline (grey) and best discovered regularizer (green), computed against the same evaluation references as in Figure 2 . IC is swept up to 10,000 iterations; apoferritin and multislice are swept up to 1,000 iterations. Multislice results are shown per layer (top row: layer 1; bottom row: layer 2).
Dataset
Technique
Description
X-ray IC
Adaptive notch filtering
FFT-based grid artifact suppression
X-ray IC
Structure-tensor TV
Edge-aware anisotropic smoothing
X-ray IC
Barzilai-Borwein
Adaptive step size acceleration
Apoferritin
Variance-gated
Preserves features under noise
Apoferritin
Soft-Huber
Noise-adaptive shrinkage
Apoferritin
Perona-Malik
Anisotropic diffusion
Table 2: Key Techniques Discovered by Dataset
Figure 4: Discovery trajectory over generation number from the merged history. Grey points show successfully evaluated algorithms; the green curve shows the best discovery-evaluation SSIM found so far (computed at the fixed discovery horizon: IC 3000 iterations; apoferritin and multislice 1000).
Figure 5: Technique adoption timeline from the merged history, showing the generations in which successfully evaluated algorithms include each technique. Lines span first-to-last appearance and markers indicate that a technique appears in at least one algorithm in that generation (techniques shown have ≥ 5 occurrences; technique names are normalized to merge spelling variants).
Iterative ptychographic reconstruction algorithms are widely used for coherent diffractive imaging but can exhibit slow convergence under realistic experimental conditions. We propose a machine learning-augmented approach that accelerates iterative ptychographic reconstruction by introducing a learned fast-forward operator applied during reconstruction. Following an initial warm-up using standard iterations, the fast-forward operator advances the reconstruction toward a more converged state, after which conventional iterative updates are resumed. This strategy preserves the physical consistency and flexibility of established ptychographic solvers while reducing the number of iterations required for convergence. The model is trained on diverse ptychographic datasets and evaluated on experimental data acquired in a different year, demonstrating robustness and temporal generalization. Compared with conventional iterative solvers, the machine learning-augmented method achieves comparable reconstruction quality while converging faster in terms of Poisson negative log-likelihood, yielding over a two-fold reduction in wall-clock time. The approach has been integrated into an existing reconstruction pipeline and deployed in production at a synchrotron beamline, demonstrating practicality for real-time experimental operation.
Bowen Zheng, Katayun Kamdin, David Shapiro +10
Advanced Light Source, Lawrence Berkeley National Laboratory, Berkeley, CA 94720, USA · Department of Physics, Massachusetts Institute of Technology, Cambridge, MA 02139, USA · Department of Materials Science and Engineering, University of California Davis, Davis, CA 95616, USA +6
Scientific data processing often requires task-specific algorithms or AI models, creating a barrier for domain scientists who need to analyze their data but may not have extensive computing or image-processing expertise. This barrier is especially pronounced when data are noisy, have a high dynamic range, are sparsely labeled, or are only loosely specified. We introduce CVEvolve, an autonomous agentic harness with a zero-code interface for scientific data-processing algorithm discovery. CVEvolve combines a multi-round search strategy with tools for code execution, evaluation implementation, history management, holdout testing, and optional inspection of scientific data and visual outputs. The search alternates between discovery and improvement actions, and uses lineage-aware stochastic candidate sampling to balance exploration and exploitation. We demonstrate CVEvolve on X-ray fluorescence microscopy image registration, Bragg peak detection, high-energy diffraction microscopy image segmentation, and hybrid analytical-learning-based affine registration. Across these tasks, CVEvolve discovers algorithms that improve over baseline methods, while holdout test tracking helps identify candidates that generalize better than later over-optimized alternatives. These results show that zero-code, autonomous LLM-powered algorithm development can help domain scientists turn unstructured scientific image data into practical algorithms and downstream scientific discoveries.
Ming Du, Xiangyu Yin, Yanqi Luo +4
Advanced Photon Source Argonne National Laboratory Lemont, IL, USA
Computational imaging, which recovers hidden signals from indirect, noisy measurements, underpins quantitative discovery across scientific disciplines, yet building a correct reconstruction pipeline demands deep domain expertise and remains laborious even for domain scientists. We introduce Imaging-101, a benchmark of 57 expert-verified computational imaging tasks spanning six scientific domains, each grounded in a peer-reviewed paper and canonicalized into a standardized four-stage pipeline (preprocessing, forward physics modeling, inverse solver, and visualization) Three evaluation tracks (planning, function-level unit tests, and end-to-end reconstruction) probe distinct agent capabilities across the full pipeline. Evaluating seven frontier LLMs uncovers systematic challenges in applying coding agents to computational imaging that go beyond those exposed by general coding benchmarks, spanning algorithm selection, physical convention handling, and pipeline integration. These findings highlight concrete capability gaps and point toward skill-augmented, domain-specialized agents as a practical path to reliable computational imaging assistance.
Siyi Chen, Jiahe Ying, Yixuan Jia +9
Key Laboratory of Spacecraft Design Optimization and Dynamic Simulation Technologies, Ministry of Education, Beijing, 102206, China