Skip to content

PtychoFM - #133

Merged
stevehenke merged 4 commits into
mainfrom
haskels/ptycho-fm-backend
Aug 18, 2026
Merged

PtychoFM#133
stevehenke merged 4 commits into
mainfrom
haskels/ptycho-fm-backend

Conversation

@stevehenke

Copy link
Copy Markdown
Contributor

No description provided.

haskels and others added 3 commits August 17, 2026 16:41
Mirrors the ptychopinn_torch subprocess-isolation pattern for the
ptycho-vit foundation model. Parent-side factory produces a
SubprocessReconstructor whose child entry points (run_reconstruct /
run_train) are the only ptychodus modules that import torch or
ptycho_vit. The parent hands the child a pre-built nested config dict
(no framework types cross the pickle boundary) plus the raw payload.

Inference batches diffraction amplitudes through PtychoViT, applies a
central crop to each patch, and stitches phase + amplitude back onto
the object grid via place_patches_fourier_shift, folding the result
into layer 0 as amp*exp(1j*ph). Training runs a minimal single-device
loop (no DDP, no mlflow, no wandb) with random_split train/val and
saves the best-val checkpoint to output_path/best.pth.

Registers Unsupervised + Supervised modes via the reconstructor library
and wires a PyQt controller with Data/Model/Training/Inference groups.
When ptycho_vit is absent, developer mode falls back to NullReconstructor
so the GUI still boots.

Optional dep ptycho-fm = ["ptycho-vit"] added to pyproject.toml; the
test_parent_config_builders discipline gate covers ptycho_fm too.
Replaces the NPZ writer with a two-HDF5 exporter matching what
ptycho_vit.CombinedDataset actually reads: <stem>_dp.hdf5 with a
'dp' dataset of diffraction patterns, and <stem>_para.hdf5 with
'object', 'probe', 'probe_position_x_m', and 'probe_position_y_m'
plus a 'pixel_height_m' attr on 'object'. file_path is treated as
a stem (the picked filename itself is not created).
ptycho-vit isn't on a package registry, so declaring the ptycho-fm extra
without a source made `uv sync` fail to resolve the lock (the same reason
ptychopinn has a matching entry). Mirror that pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stevehenke
stevehenke requested review from haskels and mdw771 August 17, 2026 22:16
@stevehenke
stevehenke marked this pull request as ready for review August 18, 2026 20:17
@stevehenke
stevehenke merged commit 9f47a80 into main Aug 18, 2026
8 checks passed
@stevehenke
stevehenke deleted the haskels/ptycho-fm-backend branch August 18, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants