babel: fix the atac loss target ordering, and trim peak memory - #1
Merged
benjaminfreyuu merged 3 commits intoAug 13, 2026
Conversation
ChromDecoder emits peaks in chrom_groups order, but target2_bin was sliced out of y in original var_names order.
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.
Hi @benjaminfreyuu !
The sparse rewrite in the PR you created looks good to me :).
Three follow-ups on top of your branch, one commit each, so you can drop any of them independently.
Changes
c8fc2fcfix permuted atac target in babel loss.ChromDecoderconcatenates its per-chromosome heads inchrom_groupsorder, buttarget2_binwas sliced out ofy, which is in originalvar_namesorder. Those two only agree if the peaks happen to be grouped by chromosome in lexicographic order -- on the 2021 fixture 1499/1500 columns are permuted. Checked against the realPairedDataset/_collate:Taking the target from
X["x2_per_chrom"], whichget_lossalready receives, is order-independent so no reindex is needed. It also dropsy2entirely: one less full ATAC copy in RAM, and ~17% off the per-cell densification.60ec731free the redundant atac copies before training. Atnet.fit()five objects each held a full copy of the ATAC non-zeros: both inputAnnDatas,X_atac_bin,X_atac_bin_csc, and the per-chromosome slices. The CSC view and the inputs are pure temporaries that never went out of scope. Extract thevar_namesup front, thendel.aa19067size babel_predict chunks by dense bytes, not cell count. The per-chromosome tensors together span the full peak width and exist on the host and the device at once, sochunk_size = 4096is ~3.7 GB at 229k peaks -- more than it needs to be on a 16 GB T4 (midgpu). Capping one chunk's dense footprint at 512 MiB gives 586 cells/chunk at 229k peaks, and leaves the 1500-peak fixture at 4096, i.e. unchanged.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 passed -- the committedoutput_model.pklstill loads, the bundle keys are unchangedNot changed
It looks like
reindex_to_chrom_groups()is no longer used, and could be removed.