Skip to content

DynaCell 2D: FNet-2D VSCyto2D-aug baseline, lite predicts, and a new-channel tutorial - #541

Draft
alxndrkalinin wants to merge 10 commits into
mainfrom
dynacell-fnet2d-vscyto2daug
Draft

alxndrkalinin wants to merge 10 commits into
mainfrom
dynacell-fnet2d-vscyto2daug

Conversation

@alxndrkalinin

Copy link
Copy Markdown
Collaborator

Summary

A 2D FNet baseline built for fast iteration, and a tutorial so a new user can plug in a new source channel (e.g. a waveorder phase reconstruction from brightfield), train, predict on DynaCell-lite and score it.

  • FNet-2D patch/aug arms (nucleus, iPSC-trained):
    • fnet2d_vscyto2daug: 384² patch with the VSCyto2D augmentation stack copied verbatim.
    • fnet2d_bigpatch: the same patch with flips only. This config is kept but not trained.
    • Both train with bf16-mixed, trainer.benchmark and channels_last. Measured on an A40: 1.216 s/step with no flags at fp32, 1.162 with flags, 0.492 with flags + bf16; peak memory 27.9 → 11.7 GB.
    • The tests pin how each arm differs from the other and from fnet2d. The speed-flag test matches 2D FNet models by name prefix, so per-reconstruction variants inherit the flags.
  • fnet2d_vscyto2daug_seed1: a second draw of the baseline, which gives the seed-to-seed spread a reconstruction must beat.
  • DynaCell-lite 2D predict configs for both seeds: iPSC lite and A549 h2b mock, DENV and ZIKV lite, focus2d slab only.
    • They use new lite plane files, built with precompute-gt build.focus_planes.
    • The full-benchmark A549 plane files can't be reused because they have 10 timepoints against 5 in the lite stores.
  • tools/assemble_channel_store.py (with tests): builds a new store from kept base channels plus renamed channels from other stores. It refuses mismatched shapes or positions, duplicate channel names and an existing output.
  • applications/dynacell/docs/2d-virtual-staining-tutorial.md: the step-by-step guide, linked from the dynacell README.

Verification

Each step in the tutorial was run once on an A40 (2026-11-17); untested steps are marked (not run) in the doc.

  • Lite fast-tier eval matches the full benchmark. With the existing fnet2d nucleus checkpoint on the same FOVs: pixel metrics within 5e-4 per FOV, Dice within 1e-3, mean mAP within 0.003. Scoring takes about 2.5 min per test set and predicting under 1 min.
  • New-channel path, test side: using Phase3D itself as the stand-in for a reconstruction, the store built with assemble_channel_store.py and viscy preprocess predicts bitwise-identically to the registered store (max abs diff 0, 50 FOVs).
  • New-channel path, train side: with assemble_channel_store.py, viscy preprocess and extract_focus_slab_store.py, the slabs equal production cell_focus.zarr bitwise on 8 FOVs. A 40-step fit from a variant config ran with bf16 and both flags.
  • Tests:
    • The config-tree tests passed: 1953 passed, 132 skipped. They cover test_benchmark_config_composition, test_submit_benchmark_{job,batch}, test_bake_best_ckpt, test_cli_routing, test_evaluate_compose, generate_lite_benchmark_configs_test, generate_grouped_eval_configs_test and assemble_channel_store_test.
    • The full test suite has not been run on this branch yet.

Running

The baseline fits are running from this branch: 38159918 (seed 0) and 38159930 (seed 1). Their lite predicts and evals are chained to run when the fits finish.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc

alxndrkalinin and others added 10 commits November 17, 2026 11:55
The 2D counterpart of the fnet3d_bigpatch / fnet3d_vscyto3daug ablation.
FNet3D trained with a 384x384 patch and the VSCyto3D augmentations works
out of domain where vanilla FNet fails, and no 2D FNet had been trained
that way: every fnet2d fit uses 64x64 patches and flips only.

- fnet2d_bigpatch: 384x384 patch, fnet2d's flips (isolates patch size).
- fnet2d_vscyto2daug: the same plus the VSCyto2D GPU augmentation stack,
  verbatim from fcmae_vscyto2d_fit.yml, from a 600x600 CPU crop
  (isolates the augmentations).

Both keep fnet2d's batch 48, store, normalization, model, optimizer,
32-true precision and 200k steps, and take no speed flags (2D FNet
leaves are pinned flags-off). Nucleus, iPSC-trained, phase input.
Tests pin the arm-vs-arm and arm-vs-fnet2d differences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
… bf16

The arms are the new 2D FNet baseline for fast iteration on phase
reconstructions, so they take trainer.benchmark, channels_last and
bf16-mixed. Measured on an A40 (aug arm, steps 90-158): 1.216 s/step
without flags at 32-true, 1.162 with the flags, 0.492 with flags plus
bf16-mixed; peak memory 27.9 -> 11.7 GB. MSE loss is unaffected by the
bf16-SSIM cancellation issue, and the 3D pair already trains at bf16.

Both arms keep identical settings so they stay paired. The speed-flag
test lists the two models as 2D leaves that opt into the flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
Phase-reconstruction variants trained on this baseline need a
seed-to-seed spread to beat on the lite test set; a second draw gives
it. The leaf is the baseline with seed_everything: 1 and its own run
tree. The speed-flag test now matches the 2D FNet models by prefix so
the seed draw and per-reconstruction variants inherit the flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
…nels

Phase reconstructions (e.g. waveorder outputs) arrive as separate plates
whose phase channel is named Phase3D like the existing one. Training
needs them next to Phase3D (the focus-slab anchor) and the target in one
store, and the registered stores must stay untouched.

assemble_channel_store.py copies kept channels (and their normalization
stats) from a base store and adds renamed channels from other stores,
refusing a (T, Z, Y, X) or position mismatch, duplicate channel names
and an existing output. Added channels get stats from viscy preprocess.
Checked on 3 lite FOVs: the added and kept channels equal their sources
bitwise and the scale is preserved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
…aseline

Both seeds of fnet2d_vscyto2daug predict the iPSC lite test set and the
three A549 h2b lite conditions on the focus2d slab only, using new lite
plane files built with precompute-gt build.focus_planes (the full A549
files have 10 timepoints against 5 in the lite stores). These are the
baselines every phase-reconstruction variant is compared against.
Submit with --ckpt best.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
…nnels

Step-by-step guide for iterating on phase reconstructions: assemble a
train store with the new channel (assemble_channel_store, viscy
preprocess, extract_focus_slab_store), write a per-reconstruction
variant of the fnet2d_vscyto2daug leaf, launch it, predict on
DynaCell-lite with the lite plane files, and score the fast metric tier.
Every command was run once on an A40 (2026-11-17) unless marked; the
fast eval reproduced the full-benchmark 2D eval on the same FOVs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
All input and output stores now close through one ExitStack, and the
tool no longer writes an empty normalization attribute when no base
channel is kept, so viscy preprocess starts from a clean store. Output
chunks take one channel per chunk regardless of the base chunking.
Verified as the tutorial runs it: the 50-FOV lite test store predicts
bitwise-identically to the registered store, and the 8-FOV train store
slabs equal production cell_focus.zarr bitwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
Re-ran the store-assembly steps exactly as written and updated their
checks and timings. Adds a section on new datasets and target channels
(single-plane eval flags, direct io.* paths, compute_pixel_metrics for
PSNR/FRC only), pins the GPU type for predicts, moves resolved configs
off node-local /tmp, and marks what was not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
… scores

The guide's "5-plane train store" read as if the 2D model trains on a
5-plane input. It trains on one plane per sample drawn from the in-focus
plane +/-2, predicts the 3-plane slab, and scores the single GT-anchored
focus plane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The first 200k-step fnet2d_vscyto2daug fits reached their minimum
validation loss at step 3818 (seed 0) and 2158-2988 (seed 1), about 2%
of the budget, then rose 12% by step 36k while training loss kept
falling. At 384^2 x batch 48 each step carries 36x the pixels of
fnet2d's 64^2 patches, so fnet2d's 200k-step budget is far too long.
20k steps is about 5x the best step (~1.7 h on an A100).

The running baseline fits keep 200k (their resolved configs are fixed);
with a constant learning rate their best checkpoints compare directly
with 20k-step variants. The tutorial explains the budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc

This branch has not been deployed

No deployments
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.

1 participant