/datascales-skills:rapids-out-of-corefrom datascales-skills
Runs rapids-singlecell on a GPU over a Zarr AnnData store larger than GPU or host memory, reading cells in Dask blocks. Covers Dask-CUDA cluster setup, managed memory vs. pool, GPU sizing, and troubleshooting slow or OOM runs.
Ships in datascales-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
rapids-singlecell (rsc) mirrors the scanpy API on the GPU. Out-of-core means X is a
Dask array of cell blocks read from Zarr, so the counts never sit in memory at once. Its
docs cover the API (rapids-singlecell.readthedocs.io, pages "Out-of-core" and "Memory
management"). The code below is copied from the team's process capsule notebook and was
run as written on 2026-12-01 on 182k and 2.0M PBMC cells (1× A100 80 GB, 12 cores,
rapids-singlecell 0.18.1, RAPIDS 26.4, CUDA 13, Python 3.12; single runs). Print
rsc.__version__ first and check any call that fails against the docs for that version.
Parameters are the team's starting values: confirm them with the person.
Linux with an NVIDIA GPU only. Environments that resolve together are in the DataScales
repository: rapids_user_notebook/pixi.toml, and the pinned
capsules/process/code/environment/ (about 5 GB).
import cupy as cp, dask, rmm
from dask.distributed import Client
from dask_cuda import LocalCUDACluster
from rmm.allocators.cupy import rmm_cupy_allocator
dask.config.set({"distributed.scheduler.worker-ttl": None}) # no time-out in non-Dask steps
cluster = LocalCUDACluster(rmm_managed_memory=True, enable_cudf_spill=True,
rmm_allocator_external_lib_list="cupy", # one worker per GPU
threads_per_worker=N_CORES // N_GPUS) # the default is 1
client = Client(cluster)
rmm.reinitialize(managed_memory=True)
cp.cuda.set_allocator(rmm_cupy_allocator)
threads_per_worker speeds the CPU side (reading, decompressing). The team
spreads all CPU cores across the workers, for example 16 each on 4 GPUs and 64 cores.
Left at the default of 1, the 2.0M-cell run took 262 s against 128 s with 12 (A100,
single runs): HVG and the persist were 3.4 to 3.6 times slower.CUDA_VISIBLE_DEVICES="0,1" to choose them. More GPUs help less than
expected; see Sizing.import anndata as ad, numpy as np, pandas as pd, rapids_singlecell as rsc, zarr
from anndata.experimental import read_elem_lazy
from anndata.io import read_elem
group = zarr.open_group(STORE, mode="r")
n_cells, n_genes = group["X"].attrs["shape"]
obs = group["obs"]
adata = ad.AnnData(
X=read_elem_lazy(group["X"], (min(24_000, n_cells), n_genes)).astype(np.float32),
obs=pd.DataFrame({c: read_elem(obs[c]) for c in OBS_COLUMNS},
index=read_elem(obs[obs.attrs["_index"]])),
var=read_elem(group["var"]),
)
rsc.get.anndata_to_GPU(adata) # lazy: each block moves to the GPU when it is computed
X must be raw counts in CSR. Read only the obs columns you need. For an Icechunk
repository, pass az.Repo(path, branch="qc").open_zarr("r") as group (the curated cells).
rsc.pp.normalize_total(adata, target_sum=1e4)
rsc.pp.log1p(adata) # still lazy
rsc.pp.highly_variable_genes(adata, n_top_genes=2000, flavor="seurat") # first real read
adata = adata[:, adata.var["highly_variable"].to_numpy()].copy()
adata.X = adata.X.persist() # 2,000 genes now fit on the GPU
rsc.pp.scale(adata, max_value=10, zero_center=False)
rsc.pp.pca(adata, n_comps=50, svd_solver="covariance_eigh")
adata.obsm["X_pca"] = adata.obsm["X_pca"].compute().get() # out of Dask, onto the host
rsc.pp.neighbors(adata, n_neighbors=20, n_pcs=30, use_rep="X_pca", algorithm="ivfflat")
rsc.tl.umap(adata, min_dist=0.45, init_pos="spectral")
rsc.tl.leiden(adata, resolution=1.1)
| Point | Why |
|---|---|
HVG flavor seurat | The team's notebook found it the only flavor that works with Dask |
zero_center=False | Keeps the matrix sparse |
algorithm="ivfflat" | The default brute took over 30 minutes on 5M cells against about 1 minute. Use mg_ivfflat with several GPUs |
| After PCA the data is small | Neighbors, UMAP and Leiden run on one GPU without Dask |
| Harmony | rsc.pp.harmony_integrate(adata, key=..., basis="X_pca", adjusted_basis="X_pca_harmony"), then neighbors on X_pca_harmony. Only when the person names a batch column |
| Above 10M cells | The team's notebook suggests rsc.tl.leiden(..., use_dask=True) |
Write back only the small results (obsm/X_pca, obsm/X_umap, obs/leiden,
var/highly_variable, the settings), with the helpers in icechunk-analysis-history.
Do not rewrite X. The last cell of rapids_user_notebook on main uses undefined names;
do not copy it.
Record the run with the results: library versions, the GPU, and every setting used, in
uns or the commit metadata, or a small JSON file beside the figures. In the team's test
no agent did this unprompted, and the runs could not be traced afterwards.
Internal PBMC data, full pipeline, single runs unless noted.
| Cells | GPU | Wall | Peak GPU memory | Peak host RAM |
|---|---|---|---|---|
| 1M | 1× T4 15 GB | about 4 min | not recorded | not recorded |
| 2M | 1× A100 80 GB | 2.1 min | 9 GB | 10 GB |
| 5M | 1× A100 80 GB | 8.5 min | 16 GB | 16 GB |
| 13.8M | 1× A100 80 GB | 23.7 min (3 runs: 23.7 to 24.3) | 38 GB | 39 GB |
| about 30M | 1× 80 GB, managed | about 46 min | 79 GB, full during neighbors | 47 GB |
Use dev_tools/rapids-benchmark/rapids_benchmark.py from the DataScales repository instead
of writing a timer. It records wall time, host memory and GPU memory per step, and every
setting is a flag (--data-path, --gpus, --chunk-rows, --rmm-mode, --n-comps). By
default it writes obsm/X_umap and obs/leiden into the input store; pass
--no-write-results to leave the store alone.
Check in this order.
| Symptom | Check |
|---|---|
| GPU out of memory | Managed memory on; subset to HVGs before persist; fewer rows per block. At about 30M cells neighbors alone filled 80 GB |
| Reading, normalize or HVG slow | Zarr threading.max_workers at 1 starves decompression (about 80 s against 44 s). Blocks too small. Too few threads_per_worker |
| Neighbors slow | algorithm left at brute |
| UMAP or Leiden slow | Bound to one GPU; more GPUs will not help. A pool helps Leiden if the data fits |
| Everything slow | Threads oversubscribed (Dask × BLAS × Zarr): set OMP_NUM_THREADS. A .compute() that pulls a large block to the client. Data moved between host and GPU at every step |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
rapids-singlecell, out-of-core, gpu, single-cell, dask-cuda, zarr
Other plugins' skills for the same job
npx claudepluginhub aifimmunology/datascales --plugin datascales-skills5 skills in this plugin
/datascales-workflowPlans an analysis of large single-cell or spatial data as one workflow, AnnData on Zarr, Icechunk history and rapids-singlecell on a GPU, as the DataScales team at the Allen Institute for Immunology runs it. Use when someone wants to analyse data that is too big for memory, keeps growing or is shared between people; asks whether a GPU is worth it; wants QC through clustering at scale; or asks which DataScales tools, capsules or benchmarks exist. Start here for a whole analysis; the topic skills cover single steps./icechunk-analysis-historyKeeps the history of an analysis inside an Icechunk repository holding an AnnData store, with commits and branches through annizarr. Use by default whenever a Zarr store is built or results are saved into one, and when someone wants to version or snapshot a single-cell store, keep raw counts safe while analysing, give each person or analysis a branch, save QC results or clusters as a commit with the settings that made them, read or compare an earlier state, undo a step, or avoid keeping a full copy of the data per analysis stage. Not for choosing the store layout, and not for versioning code./spatial-on-gpuAnalyses spatial transcriptomics cell tables (10x Xenium, Atera, or any SpatialData table with cell coordinates) with rapids-singlecell on a GPU. Use when someone wants spatial QC, a spatial neighbor graph, tissue niches or zones, neighborhood enrichment, co-occurrence, ligand-receptor analysis or spatially variable genes on a GPU, wants to combine several spatial samples, or asks how a SpatialData store fits with Zarr and Icechunk. Not for segmentation, image processing or dissociated scRNA./zarr-for-single-cellSets up and tunes one AnnData store on Zarr v3 for single-cell counts with annizarr. Use when someone wants to convert or combine h5ad or 10x files into a Zarr store, add samples later, choose between CSR, CSC and dense, sort cells, pick chunks, shards or compression, or when reading one gene or one cell type from a store is slow, a store has too many small files, or a conversion runs out of memory. Not for commits and branches, and not for the GPU analysis itself.