Skip to main content

bixverse

Python bindings for bixverse-rs. The crate does the work: this is a thin layer that opens a bixverse binary sparse store and streams minibatches out of it fast enough to keep a GPU training loop fed.

The first consumer is scVI, which ships in bixverse.nn (torch or MLX) and trains straight off the store, shuffled, without ever materialising the experiment in memory. Decoding never leaves Rust, and the GIL is released while it happens.

Install

uv pip install bixverse            # numpy only
uv pip install "bixverse[sparse]"  # adds scipy, for Batch.scipy_csr
uv pip install "bixverse[torch]"   # scVI on torch
uv pip install "bixverse[mlx]"     # scVI on MLX, Apple Silicon

Use

import bixverse as bv

reader = bv.CellReader("counts.bin")
loader = bv.CellLoader(reader, batch_size=256, layer="norm", seed=42)

for batch in loader:
    x = batch.scipy_csr()  # (256, n_genes) CSR

Pass an index array to iterate a subset, which is how a train/validation split gets expressed:

import numpy as np

rng = np.random.default_rng(0)
perm = rng.permutation(reader.total_cells)
train = bv.CellLoader(reader, perm[:180_000], batch_size=256)
val = bv.CellLoader(reader, perm[180_000:], batch_size=256, shuffle=False)

Each pass over a loader reshuffles and spawns its own feeder thread, so two concurrent passes don't share state. The seed is mixed with the epoch counter: same seed means the same sequence of epochs, not the same epoch twice.

Batches

A Batch is a NamedTuple of (raw, norm, indices, indptr, shape, cell_ids). The layer you didn't ask for is None. cell_ids is the store index of each row, which is how per-cell covariates get joined back on after the shuffle. CellLoader(genes=...) restricts and reorders the columns.

Field Sparse Dense
raw / norm CSR-ordered float32 (n_cells, n_genes) float32
indices / indptr uint32 CSR components None
shape (n_cells, n_genes) same

batch.values() returns the single requested layer, batch.scipy_csr() rebuilds a scipy.sparse.csr_matrix sharing the same buffers.

scVI

import bixverse.nn as bvnn

fit = bvnn.train_scvi("counts.bin", cells, hvg, batch, backend="torch")
latent = bvnn.scvi_latent(fit, "counts.bin", cells, batch)

scvi-tools 1.5.1's defaults, NB or ZINB, and a trained scvi-tools module loads into it and reproduces its loss. See the docs for the validation against scvi-tools.

Sparse by default

sparse=True is the default and you want it. A dense batch pays a zero-fill and a scatter over batch_size * n_genes floats regardless of how few counts it actually holds. At droplet sparsity that's roughly twenty times the memory traffic for the same information, on the feeder thread, every batch. Build the dense tensor on the GPU instead if you need one.

Layers

"raw" gives the counts. "norm" gives log1p(count / library_size * target_size), computed at write time and stored as float16, so expect agreement with a recomputation to about three decimal places rather than to machine precision. "both" returns the two together over one sparsity pattern.

Caveats

  • Cell-major stores only. A gene-major file raises on construction.
  • Ctrl-C can't interrupt a batch mid-decode: the GIL is released while the feeder works, and Python signal handlers only run while it's held.
  • The store is memory-mapped and the reader hints random access, which is right for a shuffled loader and wrong for a sequential full scan.

Development

uv venv
uv pip install "maturin>=1.15,<2" numpy scipy pytest beartype
maturin develop --release
pytest tests -q

Metadata

Release files for bixverse 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for bixverse 0.2.1
File Interpreter ABI Platform
bixverse-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
bixverse-0.2.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
bixverse-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 6.2 MB

Release files / bixverse-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bixverse-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
53eb7cfa484d4ecba992a4f57c456bbd07d898398448554e0f26f5ce09a0cefa
BLAKE2b-256 checksum
How to use checksums
00208ee759b531fece3fde60c6d3540fa998c35cdce8645217b40a86d20010a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / bixverse-0.2.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL bixverse-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 1.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
359bf9448b2878f8ab8b54a5d2b91bb1447b21414eefdb276209f11226595a81
BLAKE2b-256 checksum
How to use checksums
b71642df470d0cd5e2dad98df7f864280077d57ce1bd8e9a2b4923f985089bb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / bixverse-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL bixverse-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f268d423a45298a988aebdc07a293b58c124d520f8a62a12003b644f8a2e70a4
BLAKE2b-256 checksum
How to use checksums
7cabd8816cdf537d75a917e27c56bf7593fe6eeb4e14aeac7c438b7a84f800eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for bixverse 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for bixverse-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page