File size: 8,538 Bytes
299b839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language:
  - en
library_name: sc-save
tags:
  - single-cell
  - scrna-seq
  - bioinformatics
  - computational-biology
  - ai4science
  - virtual-cell
  - flow-matching
  - optimal-transport
  - vae
  - dit
  - gene-block-attention
  - perturbation-prediction
  - batch-effect-correction
  - pytorch
  - anndata
  - scanpy
  - iclr-2026
  - arxiv:2604.16776
metrics:
  - wasserstein-distance
  - mmd
  - pearsonr
  - r2
  - scib
---

# SAVE: Multi-Condition Single-Cell Generation with Gene Block Attention (ICLR 2026)

Model hub for **SAVE** (*ICLR 2026*), packaged as **`sc-save`** (`v0.2.0`) on PyPI.

- **Project Page & Overview Video:** [save.argonx.dev](https://save.argonx.dev)
- **GitHub Repository:** [fdu-wangfeilab/sc-save](https://github.com/fdu-wangfeilab/sc-save)
- **PyPI Package:** [`sc-save`](https://pypi.org/project/sc-save/) (`pip install sc-save`)
- **Paper:** [OpenReview](https://openreview.net/forum?id=l7QEoK4uDP) · [arXiv:2604.16776](https://arxiv.org/abs/2604.16776)
- **Interactive Demo Space:** [ArGoN1/sc-save-demo](https://huggingface.co/spaces/ArGoN1/sc-save-demo)
- **One-Click Colab Reproduction:** [ICLR 2026 Reproduce Notebook](https://colab.research.google.com/github/fdu-wangfeilab/sc-save/blob/main/notebooks/SAVE_ICLR2026_Reproduce_Colab.ipynb) · [Quickstart Tutorial](https://colab.research.google.com/github/fdu-wangfeilab/sc-save/blob/main/notebooks/SAVE_Quickstart_Tutorial.ipynb)

---

## Model Overview

Standard Transformer models for single-cell RNA-seq (~20,000 unordered genes per cell) face an $\mathcal{O}(G^2)$ attention bottleneck and lack spatial 2D grids for Vision Transformer (ViT) patchification. **SAVE** introduces:

1. **LLM Biological Knowledge (Semantic Gene Embeddings → OT Gene Blocks):** Encodes curated NCBI Gene functional summaries via GenePT (1,536-dim embeddings) and solves iterative **Optimal Transport** clustering to partition genes into $L$ balanced, pathway-coherent **Gene Blocks** ($K = 3200$ default; $K=400$ for perturbation/BEC), collapsing self-attention complexity from $\mathcal{O}(G^2)$ to $\mathcal{O}(L^2)$ (**191× training speedup** on 1× RTX 3090: `2,391.2 min → 12.5 min`).
2. **Gene-Block Attention VAE + DiT Latent OT Flow Matching:** Compresses block-structured profiles into pathway-structured latents $z \in \mathbb{R}^{N \times L \times d}$ and trains a conditional DiT Optimal-Transport Flow Matching denoiser (`AdaLN`, independent condition masking $p=0.6$, multi-condition Classifier-Free Guidance) sampled in **20 ODE steps**.
3. **One Unified Framework Across 8 Benchmarks:** Supports 1–5 condition cell generation (including unseen covariate combinations), zero-shot batch effect correction (`scIB`), and leave-one-out counterfactual perturbation prediction.

---

## Bundle Layout (`SAVE.save` / `SAVE.load`)

Each pretrained checkpoint subfolder in this repository stores a self-contained `sc-save` bundle produced by `model.save(...)`:

```text
<dataset_bundle>/
├── config.json      # SAVEConfig (VAEConfig, FMConfig, TrainConfig, cond_encoding)
├── vocab.json       # ConditionVocabulary (condition columns, classes, <mask> id)
├── metadata.json    # Gene count, pad_idx, var_names, training flags
├── scaler.npz       # Fitted MaxAbsExpressionScaler parameters
├── vae.pt           # Stage-1 Gene-Block Attention VAE weights
└── fm.pt            # Stage-2 DiT Conditional OT Flow Matching weights (generation bundles)
```

Planned / hosted benchmark bundles:
- `heart/` — Dual-condition (`batch`, `cell_type`) Human Heart Atlas (`K=3200`)
- `pbmc/` — Dual-condition (`batch`, `cell_type`) Human PBMC (`K=3200`)
- `lung_atlas/` — Dual-condition (`batch`, `cell_type`) Human Lung Atlas (`K=3200`)
- `lung_cancer/` — 5-covariate (`assay`, `development_stage`, `disease`, `uicc_stage`, `cell_type`) Lung Cancer Atlas (`K=3200`)
- `pbmc_ifn/` — Perturbation prediction (`condition`, `cell_type`) PBMC IFN-$\beta$ (`K=400`)

---

## Quickstart (`sc-save v0.2.0` + `huggingface_hub`)

```bash
pip install sc-save huggingface_hub
```

```python
from huggingface_hub import snapshot_download
from sc_save import SAVE
import scanpy as sc

# 1. Download a pretrained SAVE bundle (e.g., heart)
bundle_dir = snapshot_download(
    repo_id="ArGoN1/sc-save",
    allow_patterns=["heart/*"],
)
model = SAVE.load(f"{bundle_dir}/heart", device="auto")

# 2. Conditional cell generation with 20-step OT Flow Matching + CFG
gen_adata = model.generate(
    {"batch": "D1", "cell_type": "Atrial_Cardiomyocyte"},
    n_cells=500,
    guidance_weight=2.0,
    steps=20,
)

# 3. Inspect condition-modulated Gene Block attention weights
attn_res = model.generate_with_attention(
    {"batch": "D1", "cell_type": "Atrial_Cardiomyocyte"},
    n_cells=32,
    steps=20,
)

# 4. Zero-shot batch / condition transfer on an external AnnData
adata = sc.read_h5ad("my_cells.h5ad")
transferred = model.transfer(
    adata,
    target_cond={"batch": "D1"},
    input_cond="obs",
    inverse_scale=True,
    trim_pad=True,
)
```

For training from scratch on your own `.h5ad` file (requires GenePT embeddings from [Zenodo 10833191](https://zenodo.org/records/10833191)):

```python
import scanpy as sc
from sc_save import SAVE, SAVEConfig, build_gene_blocks, load_gene_embeddings

adata = sc.read_h5ad("heart_raw.h5ad")
gene_embs = load_gene_embeddings("GenePT_gene_protein_embedding_model_3_text.pickle")
blocks = build_gene_blocks(adata, gene_embs, block_size=3200)

cfg = SAVEConfig.save_b(gene_block_size=3200, cond_encoding="offset")
model = SAVE(blocks.adata, condition_cols=("batch", "cell_type"), config=cfg, device="auto")
model.fit()
model.save("./outputs/save_heart_bundle")
```

---

## Verified ICLR 2026 & `v0.2.0` Benchmarks

Across Google Colab GPU validation ([`iclr2026_v2_colab_validation.json`](https://github.com/fdu-wangfeilab/sc-save/blob/main/results/iclr2026_v2_colab_validation.json)), `sc-save v0.2.0` passed all **10/10 primary ICLR 2026 benchmarks** with **zero regression gate failures**:

| Benchmark | Key Metric(s) | Paper Target | `v1` Colab (Blackwell G4) | **`v0.2.0` Colab (A100 / L4)** |
| :--- | :--- | :---: | :---: | :---: |
| **Table 1** (`pbmc3k` / `dentategyrus` / `tabula_muris`) | WD ($\downarrow$) / MMD ($\downarrow$) | `19.14/1.80` · `9.16/0.17` · `10.86/0.04` | `12.76/0.48` · `8.08/0.11` · `10.65/0.04` | **`12.74/0.49` · `8.11/0.11` · `10.21/0.03`** |
| **Table 2** (`heart` / `pbmc` / `lung_atlas`) | WD ($\downarrow$) / MMD ($\downarrow$) | `8.30/0.63` · `5.37/0.29` · `4.37/1.14` | `8.83/0.64` · `5.39/0.30` · `4.42/1.16` | **`8.20/0.61` · `5.30/0.29` · `4.41/1.15`** |
| **Table 3** (`lung_cancer` Seen / Unseen) | WD ($\downarrow$) / MMD ($\downarrow$) | `3.10/1.06` · `4.63/2.11` | `3.07/1.08` · `5.39/2.16` | **`3.05/1.07` · `4.42/2.07`** |
| **Table 4** (`lung_atlas` / `heart` / `pbmc` BEC) | scIB ($\uparrow$) | `0.8128` · `0.7983` · `0.8309` | `0.8097` · `0.8019` · `0.8125` | **`0.8080` · `0.7985` · `0.8238`** |
| **Table 5** (`pbmc_ifn` 7-fold LOO Average) | PCC ($\uparrow$) / $R^2$ ($\uparrow$) / WD ($\downarrow$) | `0.96` / `0.86` / `5.15` | `0.943` / `0.807` / `5.77` | **`0.940` / `0.792` / `5.86`** |

- **Up to 8.43× faster generation** and **2.27×–2.48× faster end-to-end** on dedicated Colab A100 vs. `v1` Blackwell G4.
- **Atlas-scale memory safety:** `Tabula Muris` (`196,311 × 22,400`) runs end-to-end inside **52 GB host RAM** on Colab L4 via streaming randomized PCA and tiled RBF-MMD ($\le 16\text{ MB}$ tiles).

---

## Intended Use & Limitations

- **Intended Use:** Academic and computational research in single-cell transcriptomics, conditional virtual cell synthesis, batch integration, and in-silico perturbation modeling.
- **Limitations:** Generated expression profiles are statistical approximations learned from training cohorts and require wet-lab or orthogonal biological validation before clinical or therapeutic decisions. Genes absent from the precomputed GenePT vocabulary are excluded or placed into remainder/padded blocks during Gene Block construction.

---

## Citation

```bibtex
@inproceedings{
li2026save,
title={{SAVE}: A Generalizable Framework for Multi-Condition Single-Cell Generation with Gene Block Attention},
author={Jiahao Li and Jiayi Dong and Peng Ye and Xiaochi Zhou and Haohai Lu and Fei Wang},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=l7QEoK4uDP}
}
```