Jittable data loading utilities for JAX.
Project description
Cyreal - Another JAX DataLoader
grainfor the corporations,cyrealfor the people
Pure jax utilities for iterating over finite and infinite datasets without ever touching torch or tensorflow. Dataloaders are fast and support jax.jit, jax.grad, jax.lax.scan, and other function transformations.
Installation
pip install cyreal
The only dependency is jax.
Quick Start
Write fast torch-style dataloaders without torch
import jax
import jax.numpy as jnp
from cyreal.transforms import BatchTransform, DevicePutTransform
from cyreal.loader import DataLoader
from cyreal.rl import set_loader_policy_state, set_source_policy_state
from cyreal.sources import ArraySource
from cyreal.datasets import MNISTDataset
train_data = MNISTDataset(split="train").as_array_dict()
pipeline = [
# Load dataset into memory-backed array
ArraySource(train_data, ordering="shuffle"),
# Batch it
BatchTransform(batch_size=128),
# Move the batch to the GPU
DevicePutTransform(),
]
loader = DataLoader(pipeline)
state = loader.init_state(jax.random.key(0))
for epoch in range(2):
for batch, mask in loader.iterate(state):
... # train your network!
Go ahead and jit the loader, it is stateless
for epoch in range(2):
for _ in range(loader.steps_per_epoch):
batch, state, mask = jax.jit(loader.next)(state)
... # Train your network
For maximum throughput, jit an entire training epoch, fusing together loads of operations
model_state = {"params": jnp.array(0)}
def update(model_state, batch, mask):
model_state = {"params": model_state['params'] + 1}
return model_state, None
for epoch in range(2):
state, model_state, _ = loader.scan_epoch(state, model_state, update)
Examples and Documentation
See our documentation for more examples.
- Do you enjoy premature optimization? Why not
jitthe entire training epoch? - For the dirty and impure, we support logging metrics from within a
jitted loader. - Got yourself a huge dataset? Stream from a disk-backed source.
- Afraid of finite datasets? We provide
gymnax-backed data sources for online reinforcement learning. - Are you a starving researcher/temporarily embarrassed hyperscaler? We support continual learning via reservoir sampling and replay buffers.
We also provide full end to end training examples
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cyreal-0.1.4.tar.gz.
File metadata
- Download URL: cyreal-0.1.4.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f155e1f901941d6846b2bd391749e15a5da3b058f35d6fdc0828791c955788f
|
|
| MD5 |
9bae7321eb5dd8e4fbfb5c460f6461d7
|
|
| BLAKE2b-256 |
9468701dc9be5d00f33dae702a76bbc605c1376f2076e77cfedee5fded9aa3ac
|
Provenance
The following attestation bundles were made for cyreal-0.1.4.tar.gz:
Publisher:
python-publish.yml on smorad/cyreal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cyreal-0.1.4.tar.gz -
Subject digest:
3f155e1f901941d6846b2bd391749e15a5da3b058f35d6fdc0828791c955788f - Sigstore transparency entry: 766609097
- Sigstore integration time:
-
Permalink:
smorad/cyreal@6862da209866387b711c56656cc708e132a94359 -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/smorad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6862da209866387b711c56656cc708e132a94359 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cyreal-0.1.4-py3-none-any.whl.
File metadata
- Download URL: cyreal-0.1.4-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58d75b2c95ec9b2800224e010c87601c0a0a4f0cb86fa26e1590b7c10887229f
|
|
| MD5 |
b69780613b829583145a7b8bf31bff66
|
|
| BLAKE2b-256 |
dd88eff2084a4420f4d2c6e1e219bf0a1841d0889621c872fc6fa0bf94bb6fcb
|
Provenance
The following attestation bundles were made for cyreal-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on smorad/cyreal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cyreal-0.1.4-py3-none-any.whl -
Subject digest:
58d75b2c95ec9b2800224e010c87601c0a0a4f0cb86fa26e1590b7c10887229f - Sigstore transparency entry: 766609100
- Sigstore integration time:
-
Permalink:
smorad/cyreal@6862da209866387b711c56656cc708e132a94359 -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/smorad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6862da209866387b711c56656cc708e132a94359 -
Trigger Event:
release
-
Statement type: