Skip to main content

Decompress / Compress Zarr on the GPU

Project description

czarr

Status Build Tests Documentation codecov prek zizmor
Meta Hatch project Ruff ty uv Conventional Commits Commitizen friendly License
Package PyPI PyPI

czarr reads and writes Zarr v3 arrays on NVIDIA GPUs. Compression runs through nvCOMP, file I/O runs through cuFile (GPUDirect Storage where the system supports it), and reads return cupy.ndarray.

Documentation: https://czarr.readthedocs.io/

Installation

The NVIDIA wheels are CUDA-version-specific, so the CUDA build is an explicit choice:

pip install "czarr[cu12]"     # CUDA 12
pip install "czarr[cu13]"     # CUDA 13

pip install czarr without an extra installs no CUDA wheels and fails at import. Linux only.

Usage

Through zarr, after one setup call:

import czarr, zarr

czarr.configure_gpu()
arr = zarr.open_array("data.zarr")     # any zstd/lz4/gzip/zlib/blosc store,
out = arr[:]                           # including CPU-written ones; decodes on GPU

Or through the explicit API, which parses metadata once and holds no global state:

from czarr.core import Array

arr = Array.open("data.zarr")
out = arr[0:4, :, 8:24]

Both return cupy.ndarray. Writing goes through zarr (czarr.create_cuda_array or zarr.create_array with czarr codecs). See the documentation for the how-to guides and API reference.

Codec selection

Situation Codec
Default ANS (lowest scratch, scales past 4 GiB)
Small arrays Bitcomp (fastest below 4 GiB; OOMs above on A40)
Interoperable bitstream Zstd, LZ4, Gzip, Zlib (bit-identical with the CPU libraries)
Existing blosc stores decode-only via czarr.Blosc; write new data as [Shuffle, Zstd]

GPU decode pays off from roughly 1 MiB chunks upward; below 256 KiB, multi-threaded CPU Blosc is faster.

Chunk shapes for TCZYX microscopy

Access pattern Chunks
Whole timepoints, arr[t] (1, 1, Z, Y, X)
Z-planes, arr[t, c, z] (1, 1, 1, Y, X)
XY tiles (1, 1, 1, tile_y, tile_x)
Full timeseries, arr[:, c, z] (T, 1, 1, Y, X)

Match the chunk to the access pattern so each read decodes only the chunks it touches. Sharded stores are handled: czarr replaces zarr's sharding_indexed codec with a variant that coalesces partial-shard reads.

Limitations

  • The lowlevel read path covers zstd, blosc, and shuffle. Other codec chains fall back to the zarr pipeline, GPU-decoded where a czarr codec exists.
  • Blosc is decode-only.
  • Real GPUDirect Storage requires the nvidia_fs kernel module; without it cuFile stages through a pinned host bounce. cuFile cannot read tmpfs.
  • cupy is a hard dependency; zarr's GPU buffer prototype is hard-coded to cupy.ndarray.

An experiment in AI-assisted development

As you can probably tell, most of this has been generated with AI tooling, this is just an experiment to see if this even works, and it has helped me resolve the issue of i/o bottlenecks in my own work.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

czarr-0.0.1a0.tar.gz (307.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

czarr-0.0.1a0-py3-none-any.whl (104.7 kB view details)

Uploaded Python 3

File details

Details for the file czarr-0.0.1a0.tar.gz.

File metadata

  • Download URL: czarr-0.0.1a0.tar.gz
  • Upload date:
  • Size: 307.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for czarr-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 b3ef7b9a1f414bd87140e3b955516987e82905096009b43590debc1fe07af2b3
MD5 7d1bf95491ea335d253ca1a0886de1aa
BLAKE2b-256 fa3fa419a480b6472965ebc05bc02660eb293f6d6fb14cb5526aadd253571b9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for czarr-0.0.1a0.tar.gz:

Publisher: release.yaml on srivarra/czarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file czarr-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: czarr-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 104.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for czarr-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f062bd15d75d76c255e3ec9b5dc3febd62028f06f8313e09f27a48a88be9328f
MD5 7be77e1ffa1d72642853e10c3b7708c0
BLAKE2b-256 66df3aa00230f2a88591f6a90ee7a5b2aa4b01019a7515eeb7b43f1b8928c8b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for czarr-0.0.1a0-py3-none-any.whl:

Publisher: release.yaml on srivarra/czarr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page