matthewshu commited on
Commit
3ecbbce
·
verified ·
1 Parent(s): 3fe66a6

docs: README reflects 4-shard shuffled layout and per-D running stats

Browse files
Files changed (1) hide show
  1. README.md +58 -23
README.md CHANGED
@@ -17,24 +17,31 @@ Per-cell layer-{5,7,10} hidden states from the two scGPT checkpoints in
17
  and [matthewshu/scgpt-replogle-esm-ft](https://huggingface.co/matthewshu/scgpt-replogle-esm-ft),
18
  captured over the same 72,100-cell balanced sample of the
19
  [State-Replogle-Filtered](https://huggingface.co/datasets/arcinstitute/State-Replogle-Filtered)
20
- dataset (4 cell lines: K562, RPE1, Jurkat, HepG2). Intended for crosscoder
21
- diffing and other mechanistic-interpretability analyses comparing the two
22
- models on identical inputs.
23
 
24
  ## Layout
25
 
26
  ```
27
  matthewshu/scgpt-replogle-activations/
28
  ├── README.md
29
- ├── base/ ← scGPT-base capture (~293 GB)
30
- │ ├── shard-00000.h5 … shard-00022.h5 (23 shards × 14 GB, 50 batches/shard)
31
- │ ├── stats.h5 (Welford running mean/M2 per capture)
32
  │ ├── predictions.h5ad (3.78 GB, .X = pred, .layers["truth"] = real)
33
  │ └── training_stats.json (epochs, wandb URL, best val pearson_delta)
34
- └── esm/ ← scGPT+ESM capture (~292 GB), same layout
35
  ```
36
 
37
- Total: ~600 GB across 50 files.
 
 
 
 
 
 
 
38
 
39
  ## Capture configuration
40
 
@@ -42,12 +49,13 @@ Both runs share:
42
 
43
  | | |
44
  |---|---|
45
- | Source code commit | [`44805af`](https://github.com/mattshu0410/sc-interp/tree/44805af) |
46
  | Runner | `python -m scripts.run scgpt --dataset replogle --split sample` |
47
  | Sample | `--sample-by cell_line,gene --sample-n-per-bucket 25 --seed 42` → 72,100 cells across 2,884 buckets |
 
48
  | Capture layers | `transformer_encoder.layers.{5,7,10}` |
49
  | Capture dtype | fp16 |
50
- | Shard size | 50 batches × batch 64 = 3,200 cells/shard |
51
  | Compression | gzip-4 (lossless) |
52
  | Hardware | NVIDIA H100 PCIe (80 GB) |
53
 
@@ -56,13 +64,34 @@ The two captures differ **only** in the model: base loads
56
  `replogle_esm_ft/best_model.pt` after constructing the model with the frozen
57
  ESM2-15B per-gene prior (`scgpt_esm_prior.safetensors`, 5120 → 512 linear).
58
 
59
- ## Determinism
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  Same `--seed 42`, same dataset preprocessing, same balanced-sample bucket
62
- indices, same per-cell-line basal pairings. Train/val/test pair counts also
63
- match between runs (180,021 / 8,569 / 109,207). The 72,100-row sample is
 
64
  bit-identical at the cell-id level — only the captured activations differ.
65
 
 
 
 
 
 
66
  `obs.index` of `predictions.h5ad` matches `meta/cell_id` in each shard h5,
67
  so joining cells across files is by string key, not row index. CUDA RNG and
68
  hardware-level non-determinism mean the captured activations themselves are
@@ -70,17 +99,23 @@ not bit-reproducible across runs.
70
 
71
  ## Files
72
 
73
- - `shard-NNNNN.h5` — per-batch h5 layout from `H5ActivationSink` v3 (see
74
- `scripts/interp/hook_sinks.py:181` in the source repo for the schema and
75
- reader). Each shard contains the captured tensors keyed by capture name,
76
- per-cell metadata (`cell_id`, `pert`, etc.), and Welford accumulators
77
- under `<capture>/<tags>/running_stats/{count, mean, M2}`.
78
- - `stats.h5` global Welford accumulators across all shards in this run,
79
- flushed at sink close.
 
 
 
 
 
 
80
  - `predictions.h5ad` — self-contained predictions (`.X` = predicted log-norm
81
- expression, `.layers["truth"]` = ground truth). 0 control cells appended
82
- (the sample loader already includes balanced controls as their own buckets,
83
- unlike train/val/test where bulk controls get appended for cell-eval).
84
  - `training_stats.json` — provenance for the underlying model: wandb run
85
  URL, epoch count, best validation `pearson_delta`, total training cells.
86
 
 
17
  and [matthewshu/scgpt-replogle-esm-ft](https://huggingface.co/matthewshu/scgpt-replogle-esm-ft),
18
  captured over the same 72,100-cell balanced sample of the
19
  [State-Replogle-Filtered](https://huggingface.co/datasets/arcinstitute/State-Replogle-Filtered)
20
+ dataset. Sample is balanced over `(cell_line, gene)` buckets at 25 cells per
21
+ bucket. Intended for crosscoder diffing and other mechanistic-interpretability
22
+ analyses comparing the two models on identical inputs.
23
 
24
  ## Layout
25
 
26
  ```
27
  matthewshu/scgpt-replogle-activations/
28
  ├── README.md
29
+ ├── base/ ← scGPT-base capture (~313 GB)
30
+ │ ├── shard-00000.h5 … shard-00003.h5 (4 shards, 50 batches × batch 384)
31
+ │ ├── stats.h5 (per-D Welford running mean/M2 per capture)
32
  │ ├── predictions.h5ad (3.78 GB, .X = pred, .layers["truth"] = real)
33
  │ └── training_stats.json (epochs, wandb URL, best val pearson_delta)
34
+ └── esm/ ← scGPT+ESM capture (~312 GB), same layout
35
  ```
36
 
37
+ Total: ~625 GB across 14 data files (7 per side).
38
+
39
+ | shard | cells | layout |
40
+ |---|---|---|
41
+ | 0 | 19,200 | full (50 × 384) |
42
+ | 1 | 19,200 | full |
43
+ | 2 | 19,200 | full |
44
+ | 3 | 14,500 | partial (last batch trims to 72,100 total) |
45
 
46
  ## Capture configuration
47
 
 
49
 
50
  | | |
51
  |---|---|
52
+ | Source code commit | [`7384c03`](https://github.com/mattshu0410/sc-interp/tree/7384c03) |
53
  | Runner | `python -m scripts.run scgpt --dataset replogle --split sample` |
54
  | Sample | `--sample-by cell_line,gene --sample-n-per-bucket 25 --seed 42` → 72,100 cells across 2,884 buckets |
55
+ | Sample order | `rng.permutation`-shuffled at sample build time, so each shard interleaves cell lines and perturbations |
56
  | Capture layers | `transformer_encoder.layers.{5,7,10}` |
57
  | Capture dtype | fp16 |
58
+ | Shard size | 50 batches × batch 384 = 19,200 cells/shard |
59
  | Compression | gzip-4 (lossless) |
60
  | Hardware | NVIDIA H100 PCIe (80 GB) |
61
 
 
64
  `replogle_esm_ft/best_model.pt` after constructing the model with the frozen
65
  ESM2-15B per-gene prior (`scgpt_esm_prior.safetensors`, 5120 → 512 linear).
66
 
67
+ ## Sample order: shuffled, not sorted
68
+
69
+ Earlier versions of this dataset stored cells in obs-frame index order, which
70
+ left each shard 100% one cell-line (K562 in early shards, RPE1 in later
71
+ shards). Downstream SAE/crosscoder training therefore needed an explicit
72
+ global shuffle to avoid mid-epoch distribution shift.
73
+
74
+ The current capture seeds `rng.permutation` over the concatenated bucket
75
+ indices (commit
76
+ [`7384c03`](https://github.com/mattshu0410/sc-interp/commit/7384c03)), so
77
+ each shard contains a mix close to the global proportion (empirically ~52/48
78
+ K562/RPE1 per shard since the sample over-weights shared perts). Sequential
79
+ `iter_chunks(chunk_rows=256)` plus chunk-local shuffle is now sufficient for
80
+ IID-style training batches; no global-shuffle dataloader is needed downstream.
81
+
82
+ ## Determinism and base/esm alignment
83
 
84
  Same `--seed 42`, same dataset preprocessing, same balanced-sample bucket
85
+ indices (and the same `rng.permutation` order from a single seeded RNG),
86
+ same per-cell-line basal pairings. Train/val/test pair counts also match
87
+ between runs (180,021 / 8,569 / 109,207). The 72,100-row sample is
88
  bit-identical at the cell-id level — only the captured activations differ.
89
 
90
+ For every shard, `cell_id` arrays compare element-wise equal between
91
+ `base/shard-NNNNN.h5` and `esm/shard-NNNNN.h5`, so position N in the base
92
+ shard pairs with position N in the matching esm shard. This is the
93
+ load-bearing invariant for crosscoder pairing.
94
+
95
  `obs.index` of `predictions.h5ad` matches `meta/cell_id` in each shard h5,
96
  so joining cells across files is by string key, not row index. CUDA RNG and
97
  hardware-level non-determinism mean the captured activations themselves are
 
99
 
100
  ## Files
101
 
102
+ - `shard-NNNNN.h5` — per-batch h5 layout from `H5ActivationSink` (see
103
+ `scripts/interp/hook_sinks.py` in the source repo for the schema and
104
+ reader). Each shard contains:
105
+ - the captured fp16 BTD tensor at
106
+ `<capture>/<tags>/activation` with shape `(B, T=1536, D=512)`,
107
+ - per-cell labels under `<capture>/<tags>/labels/{cell_id, pert,
108
+ cell_index, gene_dataset_ids}`,
109
+ - per-shard Welford accumulators at
110
+ `<capture>/<tags>/running_stats/{count, mean, M2}`.
111
+ - `stats.h5` — global per-D Welford accumulators across all shards in this
112
+ run, flushed at sink close. Shape `(D,)` (token axis collapsed at write
113
+ time, suitable as the normalizer for crosscoder training without further
114
+ backfill).
115
  - `predictions.h5ad` — self-contained predictions (`.X` = predicted log-norm
116
+ expression, `.layers["truth"]` = ground truth). 0 control cells appended:
117
+ the sample loader already includes balanced controls as their own buckets,
118
+ unlike train/val/test where bulk controls get appended for cell-eval.
119
  - `training_stats.json` — provenance for the underlying model: wandb run
120
  URL, epoch count, best validation `pearson_delta`, total training cells.
121