Skip to content

Commit 052b5c8

Browse files
committed
Add audited tutorial and align protocol defaults
1 parent 623635d commit 052b5c8

7 files changed

Lines changed: 429 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ after its first public release.
1919
labels retained in portable checkpoints.
2020
- Version-pinned, checksum-verified download command for the scDiffusion-X
2121
OpenProblem dataset.
22+
- A concise H5MU-first tutorial and an implementation audit linking the public
23+
models to the executed research references.
2224

2325
### Changed
2426

2527
- The concise user-facing command is now `multiflow`; the historical
2628
`multiflow-omics` command remains as a compatibility alias.
2729
- The main CLI no longer uses anonymous NPZ files for training or generation.
30+
- Default midpoint-solver steps now match the research protocols: 100 for
31+
cell-state generation and 50 for perturbation prediction.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ The run directory contains `model.pt`, `history.csv`, and a readable
6767
`run.json`. The generated H5MU stores paired RNA/ATAC latent states, the fixed
6868
cell-type mapping, sampling seed, ODE steps, and checkpoint checksum.
6969

70+
For a practical walk-through, real-data contract, perturbation input contract,
71+
and reproducibility checklist, see the [MultiFlow tutorial](docs/tutorial.md).
72+
7073
## H5MU contract
7174

7275
MultiFlow uses one file instead of separate anonymous arrays:
@@ -116,6 +119,9 @@ and ATAC encoder bundle; do not train directly on the raw feature matrices.
116119
The latent flow objective, normalization, and sampling contracts are described
117120
in [docs/model_contract.md](docs/model_contract.md).
118121

122+
The source-to-release implementation checks are summarized in
123+
[docs/implementation_audit.md](docs/implementation_audit.md).
124+
119125
## Python API
120126

121127
```python

docs/implementation_audit.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Implementation audit
2+
3+
This document records the source-to-release checks performed before writing the
4+
public tutorial. It separates the executed model graph from inactive notebook
5+
experiments and from preprocessing that remains outside the package.
6+
7+
## Reference hierarchy
8+
9+
1. Cell-state architecture: executed cells 10, 14, 15, and 19 in
10+
`MultiFlow/generation/best_record/Joint_model_VAE_AE_encoder_cross_attention.ipynb`.
11+
2. Perturbation architecture: the production leave-one-cell-type-out runner
12+
`run_leave_one_out_all_celltypes.py`, which incorporates the intended zero
13+
control embedding missing from the earlier exploratory notebook cell.
14+
3. Concatenation ablation: the active graph in
15+
`Joint_model_VAE_diffusion_encoder_cross_attention_concat.ipynb`, represented
16+
by the corrected research module `multiflow_generation/model.py`.
17+
4. Protocol defaults and encoder boundary: manuscript Methods plus the executed
18+
training and sampling cells.
19+
20+
## Numerical graph checks
21+
22+
The release models were initialized with the reference state tensors after a
23+
semantic key mapping and evaluated on identical random inputs. The largest
24+
absolute output difference was `0.0` for all three checks:
25+
26+
| Release model | Reference | State entries | Max. absolute difference |
27+
|---|---|---:|---:|
28+
| `CellStateFlow` | executed cross-attention notebook module | 87 | 0.0 |
29+
| `PerturbationFlow` | production leave-one-out runner | 88 | 0.0 |
30+
| `ConditionalConcatFlow` | corrected concat notebook module | 47 | 0.0 |
31+
32+
The executable audit is kept outside the package test suite because it points
33+
to the local research tree. The package tests independently cover model
34+
construction, training, sampling, checkpoint migration, H5MU validation, and
35+
CLI round trips.
36+
37+
## Training and sampling checks
38+
39+
- target path: linear interpolation between Gaussian source and encoded target;
40+
- objective: RNA MSE plus ATAC MSE with equal weight;
41+
- source noise: independent for the cross-attention and perturbation models;
42+
- concat ablation source: one shared Gaussian state for both modalities;
43+
- optimization: Adam, learning rate `1e-4`, batch size 512, 600 epochs;
44+
- latent normalization: per-feature mean and standard deviation estimated from
45+
training cells and inverted after sampling;
46+
- generation solver: midpoint ODE integration with 100 steps;
47+
- perturbation solver: midpoint ODE integration with 50 steps; and
48+
- perturbation control: fixed class index 0 with an exact zero embedding.
49+
50+
## Explicit boundaries and corrected exploratory cells
51+
52+
- The public package begins with paired encoder latents. It does not yet bundle
53+
the paper RNA VAE, multimodal ATAC autoencoder, decoders, feature files, or
54+
encoder scale factors.
55+
- The package does not create leave-one-cell-type-out splits or apply
56+
benchmark-specific latent/profile corrections. These operations must remain
57+
explicit and training-only.
58+
- The exploratory concat notebook assigns `x1_atac = rna_latent` in one cell.
59+
This is inconsistent with paired RNA/ATAC training and with the surrounding
60+
code. The corrected research module and release use `atac_latent`; the concat
61+
model is labeled as an ablation rather than the canonical paper model.
62+
- The earliest perturbation notebook initialized the control embedding as a
63+
trainable random vector. The later production runner fixes and masks row 0,
64+
matching the manuscript definition `p = 0`; the release follows that
65+
production behavior.
66+
- The previous CLI fallback of 200 ODE steps did not match the paper protocol.
67+
The release now selects 100 steps for cell-state generation and 50 for
68+
perturbation unless an explicit override is recorded.
69+
70+
These boundaries are also stated in the README and tutorial so users cannot
71+
mistake generated latent states for decoded biological profiles.

docs/model_contract.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ requires equal latent dimensions.
5252
The default `rng_mode="legacy_interleaved"` matches the research sampler's
5353
RNA/ATAC random-draw order. Record `seed`, `batch_size`, ODE `steps`, device,
5454
and package version because all are part of exact stochastic reproduction.
55-
The perturbation experiments used 50 midpoint steps. The generation CLI uses
56-
200 midpoint steps by default and records the chosen value in every output.
55+
The cell-state generation experiments used 100 midpoint steps and the
56+
perturbation experiments used 50. The CLI selects the corresponding default
57+
from the model type and records the chosen value in every output. Use
58+
`--sampling-steps` during training or `--steps` during generation only when an
59+
explicitly documented sensitivity analysis requires a different value.
5760

5861
`rng_mode="batch_invariant"` makes a fixed seed independent of batch size by
5962
allocating the complete source state first. This option can use substantially

0 commit comments

Comments
 (0)