This release is a pre-release and may not be stable for production use.
Grain - Feeding JAX Models
Installation | Quickstart | Reference docs | Change logs
Grain is a Python library for reading and processing data for training and evaluating JAX models. It is flexible, fast and deterministic.
Grain allows to define data processing steps in a simple declarative way:
import grain
dataset = (
grain.MapDataset.source([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
.shuffle(seed=42) # Shuffles elements globally.
.map(lambda x: x+1) # Maps each element.
.batch(batch_size=2) # Batches consecutive elements.
)
for batch in dataset:
# Training step.
Grain is designed to work with JAX models but it does not require JAX to run and can be used with other frameworks as well.
Installation
Grain is available on PyPI and can be
installed with pip install grain.
Supported platforms
Grain does not directly use GPU or TPU in its transformations, the processing within Grain will be done on the CPU by default.
| Linux | Mac | Windows | |
|---|---|---|---|
| x86_64 | yes | no | no |
| aarch64 | yes | yes | n/a |
Quickstart
Citing Grain
To cite this repository:
@software{grain2023github,
author = {Marvin Ritter and Ihor Indyk and Aayush Singh and Andrew Audibert and Anoosha Seelam and Camelia Hanes and Eric Lau and Jacek Olesiak and Jiyang Kang and Xihui Wu},
title = {{Grain} - Feeding JAX Models},
url = {http://github.com/google/grain},
version = {0.2.12},
year = {2023},
}
The version number is intended to be that from pyproject.toml, and the year corresponds to the project's open-source release.
Existing users
Grain is used by MaxText, Gemma, kauldron, maxdiffusion and multiple internal Google projects.
Metadata
Release files for grain-nightly 0.2.13.dev20251006
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 7.5 MB
Release files / grain_nightly-0.2.13.dev20251006-cp313-cp313-win_amd64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 427.9 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cffa3356f8ed2f2142ef6ad3b115ac989ab9467ce015713bd81e3669695d54d8
|
|
BLAKE2b-256 checksum How to use checksums |
e481ae825b78328b128e1b82b843ec5efed9a612c4377c87557c51a5d26bb545
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 509.8 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0502d9145daa490e031ba31a322053a052a1a137438313d99bcc76ccbf28c6bc
|
|
BLAKE2b-256 checksum How to use checksums |
bbf2a2c30c580ac09f3130a1550e862be658eb79f7bcdcc0148885102c4431f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 509.4 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
f7a13d6563cacfbc684006d366aac4eb016278408f23d000c12f3a99513aeae9
|
|
BLAKE2b-256 checksum How to use checksums |
116fb024afba589af80b651a78f6c73edebfbcad9e5400fb1a5f2de9f5bef1bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 436.3 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5bb00a227c443c1b8d546dcc8714515297e70c32ff144f8deaabc897353739c9
|
|
BLAKE2b-256 checksum How to use checksums |
fcaf351e7e95f3580df3bc5b0a1aeb34466f0219c4f13c99756c26c402255dfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp312-cp312-win_amd64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 427.8 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0cfbc0d4e493ac15adf7ba8dfc426f248b80e03f82a4ba2ffe8abd220b4b0a0d
|
|
BLAKE2b-256 checksum How to use checksums |
998f7d0ecbdf436cda194403bec19e3405844f32c3bd4cf6c32946ff23ca7dd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 509.7 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c47a5783512d6ea8b3b5935d5e4c4124866a0d82cafaf9f00b4192a72e75b0aa
|
|
BLAKE2b-256 checksum How to use checksums |
6e93e6858fadad65ea40c55c0e9879634d06c9c52eaa2c529c29a82c3cfda73c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 509.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
51040484acc97f046615334904b6eef2204ef80c6ed9f1d621b52b3e83a1ea74
|
|
BLAKE2b-256 checksum How to use checksums |
60f14f0d4aff034610da31f1ff447c99332c09d5b12bcfdb75503358b60c065f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 436.2 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dc570f220dfa548a958bc21e4a5aff4bfabb5f8ca260e7d587f5fa1d1a95ea88
|
|
BLAKE2b-256 checksum How to use checksums |
b57cedfeaf7e7eb7556e8646edee9d90884d3972b075fca963bfb4423d54813c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp311-cp311-win_amd64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 427.6 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fbc5b09607c85a5fcecbd818acf667b4222b856ea172aa45508385fa730aeb29
|
|
BLAKE2b-256 checksum How to use checksums |
e296addc20d5d738592cf6e1c1c747f4fbc3782dbfe76b5ea2b744d33a3903bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 510.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d08e22a5db259ff23287a7f926c5b99c00eb6808491b856d71739c3ae2f499b8
|
|
BLAKE2b-256 checksum How to use checksums |
0771e11b4022a4d3fb92d701556803736b01d81d554642bae8900ddde55deb98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 510.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
8d6090523a1c0d416f4c0d3a59e7a5b57003e155d6d5ebc6524c3626b477e2db
|
|
BLAKE2b-256 checksum How to use checksums |
fb4a5048469426be30a92e3be539ff61505b629f25d520d82020619ff1989456
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 439.0 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3ba2a36d0f9fc84c4d4570e60cab016ab9b81151817c477c6941cc0b0dd05fcb
|
|
BLAKE2b-256 checksum How to use checksums |
1c82a96afa5600745f65deb609311986d7b9f75a5de16b33e4ead7bc1927a48c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp310-cp310-win_amd64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 425.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
80c4638ddafb48fb1b06a53464fe65c77d5db8da95f88b43b1b087ccf02601a8
|
|
BLAKE2b-256 checksum How to use checksums |
d828f6e629be591487897be4e1475f40344d02ca5a84f27ed58004d3696f75be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 509.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d1c9ce0316f0759e79540038599ea2add7983f575679a6b6f03fa1695b6fa514
|
|
BLAKE2b-256 checksum How to use checksums |
45ffe2b84d4fc134aaead986ffbafabd1be4ece65c495f31bd62c56a52e42312
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 509.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
60936dc3c16747e1fa86dc93778db51d97b23fcc258e79e60eae2fb7a633b8c5
|
|
BLAKE2b-256 checksum How to use checksums |
4609f14b2239be6150ad396cebc84b2b47717ae6a4639a5e4ae1fe6f8ca5985d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grain_nightly-0.2.13.dev20251006-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | grain_nightly-0.2.13.dev20251006-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 437.6 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c4bff4bc3b57b242c5259428e64ad6e2eadb0951586d8abd39df868994ee629
|
|
BLAKE2b-256 checksum How to use checksums |
b642cf6f5c6ca3e24ca26f81b7ce79849e53bb26a69a2eb7d87558b1e556225a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|