--- 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 / ├── config.json # SAVEConfig (VAEConfig, FMConfig, TrainConfig, cond_encoding) ├── vocab.json # ConditionVocabulary (condition columns, classes, 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} } ```