Skip to content

DynaCell: FNet-2D VSCyto2D-aug baseline, lite predicts, and 2D and 3D training tutorials - #541

Open
alxndrkalinin wants to merge 30 commits into
mainfrom
dynacell-fnet2d-vscyto2daug
Open

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

Conversation

@alxndrkalinin

@alxndrkalinin alxndrkalinin commented Nov 17, 2026 •

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 the lite test split 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.
  • Lite-split 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.
  • applications/dynacell/docs/3d-virtual-staining-tutorial.md: a 3D guide for engineers profiling and speeding up training on their own cluster, linked from the dynacell README. It covers:
    • downloading the iPSC data from the public S3 bucket and pointing the dataset manifest at the downloaded .ozx archives with DYNACELL_MANIFEST_ROOTS;
    • the 3D model families, with fnet3d_vscyto3daug as the single-GPU example and fcmae_vscyto3d_scratch as the 4-GPU DDP example;
    • launching a fit, the site settings to override on another SLURM cluster, a short profiling run and how to measure seconds per step;
    • predicting the full iPSC test set and scoring it with the fast metric tier;
    • an appendix of training times and hardware for 79 published 3D fits.
  • Training budget: the two 384² arms now stop at 20k steps instead of 200k. In both 200k-step fits, validation loss bottomed out before step 4k and never got lower after 20k.

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.
  • 3D tutorial (2026-11-23 and 11-25):
    • Every preview command ran.
    • A 30-step profiling fit ran on an A40, reading the public training archive in place.
    • The fit, predict, job-script and eval configs resolve to the downloaded paths.
    • The public archives hold the same FOVs as the lab stores and the same normalization statistics in every FOV; the planes compared are bitwise identical.
    • Not run: a full download from S3 (the checks read a local mirror), a 4-GPU fit, and predict or eval on the public test archive.
  • 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.

Status

Both baseline fits (seeds 0 and 1) finished on this branch, and their lite predicts and evals are done. They give the seed-to-seed spread a reconstruction must beat.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc

alxndrkalinin and others added 13 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
For the HPC team profiling and accelerating DynaCell 3D training: how
3D configs compose, how a training batch is built and staged, single-
and multi-GPU launch, a short profiling run, measuring steady s/step,
lite predict and fast-tier scoring of an accelerated run against a
reference, and the gotchas of long fits. Appendix A gives measured
s/batch, derived throughput, and GPU-hours actually spent for the 79
trained 3D fits, with the hardware each requested. Machine-specific
paths, hosts and job ids are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The tutorial is for a team outside the lab with no access to its
storage or cluster. It now downloads the iPSC archives from the public
S3 bucket, rewrites the aics-hipsc manifest to point at them, and picks
it up through DYNACELL_MANIFEST_ROOTS. The .ozx archives are read in
place; they match the lab stores bitwise on the planes compared and in
every FOV's normalization statistics.

Other changes for an outside cluster:
- the 4-GPU example uses fcmae_vscyto3d_scratch, since the pretrained
  encoder checkpoint is not in the release;
- a table of site settings (partition, GPU constraint, HF cache, uv
  module) with the overrides that change them;
- predict and score the full iPSC test set instead of DynaCell-lite,
  whose stores are not public; the GT cache is built on first eval.

Checked: the 30-step profiling recipe ran on one A40 reading the
public training archive (10 FOVs staged), and fit, predict, sbatch and
eval configs resolve to the downloaded paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
- Say the data-path check read the lab's mirror of the bucket, and
  that the public HTTPS URLs of both cell.ozx archives return the
  mirror's byte sizes (HEAD requests, no download).
- Mark the cold ground-truth cache fill as expected, not observed:
  no evaluation has run from an empty cache.
- README nav line: the tutorial now uses the public data and the full
  iPSC test set, not DynaCell-lite.

The "same normalization statistics in every FOV" sentence now holds
for all four archives (train cell/SEC61B/TOMM20, test cell: 500, 423,
500 and 100 FOVs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
@alxndrkalinin alxndrkalinin changed the title DynaCell 2D: FNet-2D VSCyto2D-aug baseline, lite predicts, and a new-channel tutorial DynaCell: FNet-2D VSCyto2D-aug baseline, lite predicts, and 2D and 3D training tutorials Nov 26, 2026
alxndrkalinin and others added 16 commits November 25, 2026 22:10
The 0.493 vs 0.918 s/step pair recorded in fnet3d_paper_fit.yml came
from 3,000-step pilots of the FNet3D-VSCyto3DAug 384^2 recipe, not
from fnet3d_paper's 64^2 patch. Appendix A.5 now tabulates the pilots,
including UNeXt2-3D (4.32 -> 0.90 s/step with cudnn.benchmark on one
GPU), and notes that the published FCMAE fits ran without autotuning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
Also say which run the 0.505 s/step A40 figure comes from (the full
baseline fits, validation included) against the leaves' 0.492 smoke
figure, and that the baseline fits have finished.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The seed-1 leaf copied all 115 lines of the baseline, so every recipe
change had to be made twice. It now uses the baseline as its base and
restates only the seed, names and output paths. The resolved config is
identical to before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The fnet2d_bigpatch and fnet2d_vscyto2daug leaves each repeated the same
speed flags, bf16-mixed precision, 20k-step budget and their rationale
comments. Move them into model_overlays/fnet2d_bigpatch_fit.yml (based on
fnet2d_fit.yml, as fnet3d_paper_fit.yml carries the 3D speed flags) so the
paired arms, and the seed-1 leaf that inherits from the vscyto2daug leaf,
cannot drift apart. The resolved configs of the three leaves are
byte-identical before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
_expected_speed_flags exempted the 2D FNet arms by a model_name prefix,
although the block's own comment says the flags are keyed by the composed
architecture, not by leaf identity. Select them by what they are instead:
FNet3D architecture, one input plane and a 384x384 patch. Over all 209
train leaves this picks the same three leaves as the name list did; the
architecture term is needed because other 2D nets share the patch and
depth. Update the 2D tutorial, which told users the name prefix matters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The output create_image call passed chunks but no shards_ratio, so a
sharded base store (for example chunks (1,1,8,512,512) in shards
(2,1,64,4096,4096)) came out unsharded: 72 files per FOV instead of 3.
Derive shards_ratio from the base array's shard and chunk shapes so the
output keeps the base's shard shape; an unsharded base stays unsharded.
Also take the first N positions with islice instead of listing every
position before slicing.

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

assemble built and returned a list of written position names that no
caller reads; return None and say so in the docstring. The test helper
_o(tmp_path) only wrapped tmp_path / "o.zarr", which the other tests
spell inline; inline it and delete the helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The 0.492 s/step A40 measurement it cites moved from the two arm leaves'
header comments into model_overlays/fnet2d_bigpatch_fit.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The eight fnet2d_vscyto2daug and fnet2d_vscyto2daug_seed1 lite predict
leaves pinned last.ckpt, the step-200000 weights of fits whose validation
loss bottomed out at step 3818 (seed 0) and 2158 (seed 1). Bake each fit's
best_model_path with tools/bake_best_ckpt.py, as the other predict leaves
do, and replace the header comment that told the reader to pass
--ckpt best.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
assemble_channel_store checked each added channel's shape and position
inside the per-FOV write loop, after earlier positions had been written to
the new store, so a mismatch in a later FOV left a partial store that a
trainer would accept. Check the kept and added channel names and every
position's (T, Z, Y, X) from array metadata first, and open the output
only once all inputs pass. Exception types and messages are unchanged;
the docstring now says a missing channel raises ValueError, which it
always did.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
assemble_channel_store cast every added channel to the base array's dtype
with astype, so a float phase reconstruction added to a uint16 base was
silently truncated. Compare the dtypes in the validation pass and raise a
ValueError naming the store, channel and both dtypes; the added channel is
now copied unchanged.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
_parse_add ran after argument parsing and unpacked rsplit's result, so an
--add with fewer than two colons died with a bare ValueError traceback.
Pass it as the option's type and raise ArgumentTypeError naming the
expected STORE:SRC_CHANNEL:NEW_CHANNEL form, so the user gets a usage
message and exit code 2.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The fnet2d_bigpatch overlay and leaf headers said fnet2d -> fnet2d_bigpatch
isolates the patch-size effect. The arm also changes num_samples (8 -> 4),
precision (32-true -> bf16-mixed), the speed flags and max_steps (200k ->
20k), so say so and point at model_overlays/fnet2d_bigpatch_fit.yml. The
vscyto2daug data overlay also named model_overlays/fnet2d_fit.yml as the
source of max_steps, which the 20k budget in the bigpatch model overlay has
replaced. Comments only: the resolved configs of the three affected leaves
are byte-identical before and after.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
Both tutorials told readers to check out the PR branch and listed it in
the Branch row; the branch is deleted on merge, so name main and let the
clone's default branch stand. The 2D tutorial also said the baseline fits
were expected to finish by a date and that their A549 numbers would show
an effect. The fits have finished and their leaves pin the best
checkpoint, so state that, and phrase the A549 expectation without a
forecast.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
The 2D tutorial named a person in three places: whose checkout to avoid
running, who submitted the baseline fits, and whose scratch directory
holds the synthetic-store eval log. Say another user's copy and the
baseline fits instead, and drop the pointer to the personal log; the two
constraints it supports stay stated in the tutorial.

Found in code review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
Replace the lab storage paths throughout with <train-dir>, <lite-dir>
and <model-dir>, mapped to the lab locations in one table, and drop
the Unix group name. Public docs carry no absolute paths; the table
keeps the guide usable on the lab cluster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzpgExfYMKCgogfnhcSgDc
@alxndrkalinin
alxndrkalinin marked this pull request as ready for review November 26, 2026 07:24
…er does

DynaCell is now the umbrella framework. The tutorials name the DynaCell
evaluation suite where they mean the benchmark (titles, intros, test
sets, the appendix's published baselines), the datasets as in the
paper (the iPSC dataset (Allen Institute WTC-11 hiPSC dataset) and the
A549 dataset (Biohub imaging infectomics dataset)), and the 50-FOV
subset as the lite test split, the paper's term. The S3 release name
(DynaCell release, s3://dynacell/v1/) stays.

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