How We Accelerated CellGemma 803x on a Single NVIDIA L4
Replacing autoregressive generation with 1-step exact BF16 log-odds, Cell-First Split-KV caching, and an S1 Anti-Goodhart mask took per-pair inference from 29 seconds to 36 ms, running 15,087 screens in 27 minutes instead of 5 GPU days.
The 5-day bottleneck
Running a virtual-cell foundation model across thousands of drug-cell perturbations looks cheap until you actually measure wall-clock latency on a single cloud GPU. Out of the box, autoregressive decoding on CellGemma took 29 seconds per perturbation on an NVIDIA L4 (24 GB VRAM).
At 29 seconds per query, screening 15,087 candidate perturbations requires 121.5 hours, just over 5 continuous GPU days. Worse, autoregressive sampling introduces temperature noise that ruins reproducibility across independent verifiers.
1-step exact BF16 log-odds
We do not need the model to write paragraphs explaining a cellular state transition. For ranking drug candidates against a defined transcriptional readout, the only mathematically meaningful quantity is the exact next-token log-odds over the target outcome tokens.
Collapsing multi-token autoregressive decoding into a single forward pass in native BF16 immediately eliminates decode loop overhead and sampling variance. Every run becomes deterministic up to floating-point associativity, cutting latency from 29,000 ms down to 920 ms (31.5x faster) before touching KV caching.
Cell-First Split-KV reuse
In an oncology repurposing sweep, the expensive part of the prompt is the cell-state context: thousands of gene-expression rank tokens describing A549 or K562 baseline physiology. The perturbation suffix (drug identity and concentration) is tiny by comparison.
By ordering the prompt Cell-First and precomputing the baseline KV cache once per cell line, every candidate drug shares the frozen prefix tensors in VRAM. Each new drug perturbation pays attention cost only on the short suffix tokens against the cached cell KV, slashing latency from 920 ms to 54 ms.
S1 Anti-Goodhart mask
Speed without guardrails accelerates garbage. Early high-throughput sweeps showed a classic Goodhart failure: prompts that leaked summary signature markers let the model shortcut target scoring without attending to the perturbation tokens.
Adding the S1 Anti-Goodhart attention mask isolates leakage positions while keeping the static Cell-First KV prefix intact, and fusing batch evaluation across the remaining perturbation slots brings steady-state throughput to 36 ms per screen (803x speedup). All 15,087 runs finished in 27 minutes on one L4.
| Stage | Latency / screen | 15,087 screens | Speedup | Notes |
|---|---|---|---|---|
| Autoregressive decode | 29,000 ms | 5.1 days | 1.0x | Default generation on 1x L4; sampling variance |
| 1-step exact BF16 log-odds | 920 ms | 3.9 hrs | 31.5x | Single forward pass; deterministic logits |
| Cell-First Split-KV prefix | 54 ms | 34 min | 537x | Shared cell-line KV cached once in 24 GB VRAM |
| Split-KV + S1 Anti-Goodhart | 36 ms | 27 min | 803x | Batched suffix + shortcut token mask (end-to-end) |
Open challenge
Our fastest L4 sweep surfaced Allopurinol + Decitabine after pre-GPU pharmacology filters. Try to break it with primary literature, or lend your GPU to expand the next sweep.
Try to break Allopurinol + Decitabine Connect your GPU / agent