File size: 10,314 Bytes
b09a05b
 
e89291f
 
 
 
 
 
 
 
 
 
b09a05b
e89291f
7fc9e69
e89291f
e206b21
 
 
 
 
e89291f
e206b21
7fc9e69
 
e206b21
 
 
 
 
 
 
 
 
 
 
 
e89291f
8b3dfa7
e89291f
 
 
 
dccf794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fc9e69
 
 
 
 
dccf794
 
 
 
 
 
 
 
 
e89291f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dccf794
 
e89291f
 
 
7fc9e69
e89291f
 
 
7fc9e69
e89291f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dccf794
 
 
 
 
 
 
 
e89291f
7c07328
 
 
 
 
 
 
 
e89291f
 
 
 
 
 
 
 
 
 
 
dccf794
 
e89291f
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
---
license: mit
library_name: pytorch
pipeline_tag: other
tags:
- perturbation-biology
- single-cell
- t-cells
- crispr
- adaptive-computation
- halting
- state-model
---

# RefineRx β€” adaptive-depth halting as a per-perturbation signature

RefineRx adds a **learned, per-perturbation adaptive-depth halting** mechanism to
the ARC **STATE** perturbation-response architecture, and asks whether the
resulting halting depth E[N] is a reproducible, effect-size-independent signature.
This repository ships both the **positive** and the **negative** result of that
question:

- **βœ… Positive (the working artifacts): four `oracle-ACT` halt heads** on **frozen**
  cell-line STATE-embedding (ST-SE) backbones (K562, HepG2, Jurkat, RPE1). Read off a
  fixed, gradually-refining backbone, these recover a usable per-perturbation depth
  signature (reproducible within-line, effect-independent, non-redundant with
  network topology).
- **⚠️ Negative (documented, for the record): CD4-native fused-halting checkpoints**
  trained from scratch on CD4+ T-cell **pseudobulk**. The response head fits, but
  the halting depth **collapses to a constant** on this pseudobulk substrate β€” see
  the key result below. These checkpoints are shipped as the reproducible negative,
  not as a recommended depth model.

> **Naming note.** "CD4-native" refers only to the from-scratch pseudobulk
> checkpoints in `checkpoints/`; it is the *collapsed* model. The usable
> depth signal in this repo comes from the frozen-backbone halt heads in
> `halt_heads/`.

**Paper:** *When Does a Perturbation Model Know Enough?* (Yash Raj).
**Code:** https://github.com/yashraj59/RefineRx

---

## ⚠️ Key result β€” read this first

**On the CD4 pseudobulk backbone, the fused-halting expected depth E[N] collapses
to a constant** (E[N] β†’ 6.0, the round budget; across-perturbation std β‰ˆ 1e-4),
**even though the model fits the perturbation response well.** The response head
works; the *depth* signal does not survive on this substrate.

Why it collapses β€” a head-free diagnostic locates the cause **upstream of the
halt head**:

- The oracle stopping round **r\* is degenerate**: r\* = max (the final refinement
  round) for **100% of held-out perturbations**, with zero spread.
- The per-round magnitude-free distances form a **step function**
  (1.04 β†’ 1.23 β†’ 1.20 β†’ 1.24 β†’ 0.99 β†’ 0.03): refinement rounds 2–5 are no better
  than round 1, and only the *final* round converges. There is no smooth
  accuracy-vs-depth curve for a halt head to calibrate on.
- Increasing the ponder weight 10Γ— (Ξ³: 0.01 β†’ 0.1) does **not** restore spread.

### What we do β€” and do not β€” claim

We attribute the collapse **primarily to pseudobulk aggregation, and we are careful
not to over-read it:**

- **The signal exists at single-cell resolution.** The *frozen*-backbone
  single-cell CD4 analysis (two donors, D1/D4) on this same biology recovers a
  **reproducible within-donor depth signature** (split-half ρ = 0.62–0.75, rising
  with stimulation), and at the stimulated 48 h endpoint separates resting-sparing
  inflammatory-program suppressors from damaging/generic perturbations. So depth
  **is** recoverable from CD4 data β€” just not from aggregated pseudobulk.
- **Pseudobulk is the leading suspect,** because averaging cells removes the
  within-population variation the single-cell signature draws on (and raw CD4
  pseudobulk response is donor-unstable by construction).
- **We could not run the clean control.** Separating "pseudobulk hides it" from
  "the from-scratch x0-recurrence mechanism kills it" requires training a
  CD4-native backbone from scratch **at single-cell resolution**. The full CD4+
  single-cell screen is ~22M cells; our frozen analysis used a two-donor subsample
  capped at 50 cells/perturbation (3.9M cells). From-scratch single-cell training did
  not reach stable dataloader throughput in the compute available, so this control is
  left as future work.

**The honest, narrow statement:** *on aggregated pseudobulk the from-scratch fused
model fits the response but yields no usable depth signature, most plausibly
because pseudobulk hides it.* This does not, on its own, refute end-to-end halting.

**Interpretation.** Halting is a **computational proxy for response complexity, not
biological time.** Depth is a property of a fitted model and its refinement axis β€”
it should not be read as a biological trajectory, kinetic ordering, or a claim about
how long a real cell "computes" a response.

---

## Contents

```
checkpoints/
  best.ckpt          # CD4-native STATE transition + fused halting (~449 MB)
  last.ckpt          # last-step checkpoint of the same run (~449 MB)
halt_heads/
  halthead_k562.pt   + halthead_k562_meta.json    # oracle-ACT head, frozen K562  ST-SE backbone
  halthead_hepg2.pt  + halthead_hepg2_meta.json   # oracle-ACT head, frozen HepG2 ST-SE backbone
  halthead_jurkat.pt + halthead_jurkat_meta.json  # oracle-ACT head, frozen Jurkat ST-SE backbone
  halthead_rpe1.pt   + halthead_rpe1_meta.json    # oracle-ACT head, frozen RPE1  ST-SE backbone
config/
  config.yaml        # full run config for the CD4-native checkpoints
  hparams.yaml       # Lightning hparams snapshot (version_0)
  state_halt.yaml    # state_halt model config template (repo default)
```

---

## 1. CD4-native transition + fused-halting checkpoints

`checkpoints/best.ckpt` and `checkpoints/last.ckpt`.

**Architecture** β€” STATE transition model (`state_halt`) with a fused
adaptive-depth halting mechanism combining:

- **oracle-r\*** supervision (project Β§4.4), and
- **joint calibration** of the halt head (project Β§4.5), using a
  **magnitude-free per-round target**, with **ponder loss gated on after warmup**
  and **KL = 0**.

Backbone / halting hyperparameters (from `config/config.yaml`):

| field | value |
|---|---|
| model | `state_halt` |
| transformer backbone | `llama`, bidirectional, 8 layers, 12 heads, head_dim 28 |
| hidden_dim | 336 |
| intermediate_size | 3072 |
| cell_set_len | 64 |
| n_refine_rounds | 6 |
| predict_residual / softplus | true / true |
| distributional loss | energy (blur 0.05) |
| confidence_token | true (weight 0.01, target_scale 10.0) |
| halt_tau / halt_alpha / halt_beta / halt_gamma | 0.05 / 0.5 / 0.1 / 0.1 |
| halt_warmup_steps | 2000 |
| halt_magnitude_free | true |
| optimizer | AdamW, lr 1e-3, weight_decay 5e-4, grad_clip 10 |
| batch_size / max_steps | 64 / 15000 |
| train_seed | 42 |

**Training data** β€” CD4+ T-cell **pseudobulk**:

- **278,684 pseudobulk profiles Γ— 2,001 HVG** (HVG space shared with the
  frozen-backbone CD4 analyses; includes PuroR).
- Conditions: **Rest / Stim8hr / Stim48hr**.
- **4 donors** (used as the batch covariate).
- Input representation: `X_hvg`, `log1p(counts)` only (no library-size / 1e4
  rescaling), following the cell-load contract.
- Data schema: `pert_col=gene`, `cell_type_key=condition`, `batch_col=donor`,
  `control_pert=NTC`, `output_space=gene`.

The model **fits the perturbation response**; see the key result above for what
fails (depth identifiability on pseudobulk), not what works (response prediction).

---

## 2. Cell-line oracle-ACT halt heads

`halt_heads/halthead_{k562,hepg2,jurkat,rpe1}.pt` (+ `_meta.json`).

Each is an **oracle-ACT halt head** trained on a **frozen ST-SE cell-line llama
backbone** (no gradient to the backbone). They reproduce the expected-depth E[N]
signal at reproducibility ρ = 1.0 on their own line.

**Head module** (`AdaptiveStateRefine`, from the `_meta.json`):

- Frozen backbone, **8 layers β†’ 8 exit rounds** (exit_layers 1..8), hidden H = 328.
- **Halt head:** `Sequential(LayerNorm(H), Linear(H,64), SiLU, Linear(64,1))`,
  last-bias init βˆ’2.0 (sequential-hazard formulation).
- **Error head:** `Sequential(LayerNorm(H), Linear(H,64), SiLU, Linear(64,1))` + softplus.
- **Refinement token:** `Parameter(H)`, init `randn*0.02`, appended at sequence index S.
- Feature dims: pert_dim 2024, input_dim 2058, n_genes 2000.

**Training** (per `_meta.json`): 50 epochs (15 warmup), 4 seeds, cell_set_len S = 64,
AdamW lr 3e-3, grad_clip 1.0, Ο„ 0.05 / Ξ± 0.5 / Ξ² 1.0 / Ξ³ 0.1 / Ξ΄ 0.1, min_cells 20,
**ponder gated on after warmup**, **KL = 0**. Per-line perturbation counts are in
each meta file (e.g. K562 = 968).

**These are the positive-control counterpart to the CD4 pseudobulk collapse.**
Read off a *frozen, gradually-refining* backbone, the halt heads DO admit a usable
per-perturbation depth signal: within-line split-half ρ β‰ˆ 0.76–0.85, effect-size
independent once #DE and cell count are controlled (partial ρ β‰ˆ 0), and
**non-redundant with network topology** β€” no GRN/PPI graph statistic reproduces the
per-perturbation ordering of E[N] (best |ρ| = 0.23, below a 0.3 novelty ceiling).
The signature is reproducible *within* a cell type but does **not** port across cell
lines (cross-line ρ = 0.14) β€” it is a cell-type-specific property.

Two claims must be held apart. As a **descriptor**, E[N] is *non-redundant* with the
network (above): it captures per-perturbation structure the graph statistics miss. For
one downstream **target-class ranking task**, however, it is *non-additive* with a
STRING baseline built from the same functional modules β€” adding |Ξ”E[N]| gives no AUC
lift over response + STRING in three of four lines. Non-redundancy as a descriptor and
non-additivity for that one classifier are different statements; only the latter is
negative, and it does not diminish the signature's novelty.

---

## Provenance & caveats

- Checkpoints were **stage-copied from a live training job** (consistent snapshot;
  the training run was not interrupted).
- The three config files describe the CD4 run; `state_halt.yaml` is the repo
  default template (hidden_dim 768 there vs 336 in the actual CD4 run β€” use
  `config.yaml` for the shipped checkpoints).
- **Depth is model-specific and is not biological time.** Do not interpret E[N] or
  r\* as a kinetic / temporal ordering of the biological response.
- The collapse on pseudobulk is a substrate result, not a proof that CD4 halting is
  intrinsically unidentifiable (see "What we do β€” and do not β€” claim").

## Citation / code

Source, training scripts, and analysis: **https://github.com/yashraj59/RefineRx**