babel: keep ATAC/RNA sparse instead of densifying up front - #61
Open
benjaminfreyuu wants to merge 1 commit into
Open
babel: keep ATAC/RNA sparse instead of densifying up front#61benjaminfreyuu wants to merge 1 commit into
benjaminfreyuu wants to merge 1 commit into
Conversation
babel_train densified the full ATAC (and RNA) matrix via a single _to_dense() before building the Dataset. On real ATAC data this OOMs — the 2022 pbmc_multiome run tried to allocate 222 GiB for a 130095 x 228942 float64 array and crashed (numpy ArrayMemoryError). The tiny 2021 test fixture (1500 peaks) hid it. Restore the original BABEL approach (wukevin/babel sc_data_loaders): keep the matrices sparse (CSR) and densify one cell at a time in PairedDataset.__getitem__ (mirrors BABEL's per-cell `utils.ensure_arr(X[i]).flatten()`). Peaks are sliced per chromosome on a CSC view. babel_predict likewise binarizes sparsely and runs inference in cell chunks instead of loading the whole dense matrix onto the GPU. Peak memory now scales with a minibatch, not the full matrix: on a synthetic 20k x 60k ATAC (9.6 GB dense) the sparse path peaks at 1.7 GB while the old toarray() path is OOM-killed under a 6 GB cap. Verified: viash test passes for babel_train (1/1) and babel_predict (1/1). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
babel_traindensified the full ATAC (and RNA) matrix with a single_to_dense()before building the Dataset. On the full 2022 datasets this OOMs — in the2026-08-01run, babel onopenproblems_neurips2022/pbmc_multiome/swapcrashed with:It only passed on the tiny 2021 test fixture (1,500 peaks); the real ATAC data has ~229k peaks.
Fix
Restore the original BABEL approach (
wukevin/babel'ssc_data_loaders): keep the matrices sparse (CSR) and densify one cell at a time inPairedDataset.__getitem__— mirroring BABEL's per-cellutils.ensure_arr(X[i]).flatten(). Peaks are sliced per chromosome on a CSC view.babel_predictlikewise binarizes sparsely and runs inference in cell chunks rather than loading the whole dense matrix onto the GPU.Peak memory now scales with a minibatch, not the full matrix.
Verification
viash test src/methods/babel/babel_train/config.vsh.yaml→ 1/1 passedviash test src/methods/babel/babel_predict/config.vsh.yaml→ 1/1 passedtoarray()path is OOM-killed under a 6 GB cap.Note
This removes the OOM crash. Walltime on the full 2022 data is untested here (no local GPU / full data); per-cell densification matches upstream, but if it proves slow,
iterator_train__num_workersand/or the resource label can be tuned as a follow-up.🤖 Generated with Claude Code