Skip to content

babel: keep ATAC/RNA sparse instead of densifying up front (re-apply #61) - #66

Open
benjaminfreyuu wants to merge 1 commit into
openproblems-bio:mainfrom
benjaminfreyuu:fix/babel-sparse-atac-2
Open

babel: keep ATAC/RNA sparse instead of densifying up front (re-apply #61)#66
benjaminfreyuu wants to merge 1 commit into
openproblems-bio:mainfrom
benjaminfreyuu:fix/babel-sparse-atac-2

Conversation

@benjaminfreyuu

Copy link
Copy Markdown
Contributor

Re-applies #61, which was merged (commit ef7a4209, 2026-08-14 04:10) but is no longer in main — main's history was rewritten afterwards and dropped the merge, so the 2026-08-14 08:03 benchmark run still hit the old crash.

Problem

babel_train densified the full ATAC matrix (_to_dense) before building the Dataset. On the 2022 pbmc_multiome/swap data this crashes:

numpy ArrayMemoryError: Unable to allocate 222. GiB for shape (130095, 228942), float64

(Confirmed again in run_2026-08-14_08-03-58.) It only passed on the tiny 2021 fixture (1.5k peaks).

Fix

Restore the original BABEL approach (wukevin/babel): keep matrices sparse (CSR) and densify one cell at a time in PairedDataset.__getitem__ (mirrors BABEL's ensure_arr(X[i]).flatten()). Peaks sliced per chromosome on a CSC view. babel_predict binarizes sparsely and infers in cell chunks.

Verification

  • viash test babel_train → 1/1 passed; viash test babel_predict → 1/1 passed.
  • Scale probe: on a 20k×60k ATAC (9.6 GB dense) the sparse path peaks at 1.7 GB; the old toarray() path is OOM-killed under a 6 GB cap.

🤖 Generated with Claude Code

Re-applies PR openproblems-bio#61, whose merge commit was dropped when main's history was
rewritten (the 2026-08-14 08:03 run still hit the old 222 GiB densify crash on
pbmc_multiome).

babel_train densified the full ATAC (and RNA) matrix via _to_dense() before
building the Dataset, which OOMs on real ATAC data (2022 pbmc_multiome tried to
allocate 222 GiB for a 130095 x 228942 float64 array). Restore the original
BABEL approach: keep matrices sparse (CSR), densify one cell at a time in
PairedDataset.__getitem__; babel_predict binarizes sparsely and infers in cell
chunks.

Verified previously: viash test passes for babel_train (1/1) and babel_predict
(1/1); on a synthetic 20k x 60k ATAC the sparse path peaks at 1.7 GB vs the old
toarray() path being OOM-killed under 6 GB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant