Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Grain - Feeding JAX Models

Continuous integration PyPI version

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.dev20250929

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 grain-nightly 0.2.13.dev20250929
File
grain_nightly-0.2.13.dev20250929-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
grain_nightly-0.2.13.dev20250929-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
grain_nightly-0.2.13.dev20250929-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
grain_nightly-0.2.13.dev20250929-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
grain_nightly-0.2.13.dev20250929-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
grain_nightly-0.2.13.dev20250929-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
grain_nightly-0.2.13.dev20250929-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
grain_nightly-0.2.13.dev20250929-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
grain_nightly-0.2.13.dev20250929-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
grain_nightly-0.2.13.dev20250929-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 7.5 MB

Release files / grain_nightly-0.2.13.dev20250929-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp313-cp313-win_amd64.whl
Size 426.1 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
6adf19892e18ebbe54ded1057a36baccc282f649a4eb83810d1214e5c0db1e87
BLAKE2b-256 checksum
How to use checksums
675f8838f0882310bb6af9efb61acef8eed78ab0b7acea8301f4b64201142aeb
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.dev20250929-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 508.0 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
35df2a008d750d7ddf7a59dbc07690379b05cd07ac6ceee3bb10d347f22f8ae4
BLAKE2b-256 checksum
How to use checksums
76f47400aa6e8ee77ef30ba9b3dfe438bb4e4d4c1e1d403ac7dd2788299afd55
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.dev20250929-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 507.6 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
faf968f8a3103e53252f4e113b50a4e29827c75ec0cacb25389def9b3cb7dfcf
BLAKE2b-256 checksum
How to use checksums
32c3a00e458f36f4fb4a713ba0c607fdca40a59d4c6198ce98880599c7530a23
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.dev20250929-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp313-cp313-macosx_11_0_arm64.whl
Size 434.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ac02c1390a9a798f03e1c128437f74e713aa131f1fae926cc92b402bc91b97c7
BLAKE2b-256 checksum
How to use checksums
8da991f7434a7ab0565095bd741a6fb908f87d0e32e9d03ab64e3f675575dca8
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.dev20250929-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp312-cp312-win_amd64.whl
Size 426.0 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
4ad74d66b2e123290af8ac8ec36279b38f3a0fa62304fedb7a9aa2ba8b6d21f7
BLAKE2b-256 checksum
How to use checksums
a80dc129bf9a659de4b75834934d3a82c9e84a3389707d76316ceff29ba862b2
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.dev20250929-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 507.9 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c8a350ce6431e57050339829dc32fef0187a2da5d78f935c83279c96bdf52df7
BLAKE2b-256 checksum
How to use checksums
b956076a12770de81da5a57c79061778a2485acdf43f0dd4137cd361b5cd1b74
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.dev20250929-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 507.4 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
b5f9201a573b6c013b4f5ac3c2b266d057b770c4559ddcaad5449385818bf603
BLAKE2b-256 checksum
How to use checksums
f1213ad6d3c47a45b3582909cc8abde9350d2a5d2ed75d808a50114f7151a5b7
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.dev20250929-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp312-cp312-macosx_11_0_arm64.whl
Size 434.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c3afb31906eb3f41562bcf760cfb13073fcf4eb92985e56016f8079457c7866c
BLAKE2b-256 checksum
How to use checksums
e69765e1133e53485fdcf6cdd2f9ca39ff8046a18eb41fa4d4b72e88b8ab12ff
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.dev20250929-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp311-cp311-win_amd64.whl
Size 425.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d4416d9376bc316b64788e8bc55ecded12177cb4b3b18e24deb3f5a4047457fc
BLAKE2b-256 checksum
How to use checksums
a18fb7b5f4b767f97654a62e84588be3c0611ea7f130d2dbc1f171a987381fa8
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.dev20250929-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 509.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
873b81a1f5e21db13419f70f53953cda83532607e047dafe27a573f627f20d2f
BLAKE2b-256 checksum
How to use checksums
5903262bec782632e782571caa2f37cdf855525478bb1edf844cfb2e243ecc6b
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.dev20250929-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 508.3 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
dff2b52a4b0ad5fdd7099ced92134d4b4c6e24283a8ff1539f61312f408a69b7
BLAKE2b-256 checksum
How to use checksums
021c352d3494d79596d44c7c4e8fa2b2c8153f5af75182adaaf907386dfbb33e
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.dev20250929-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp311-cp311-macosx_11_0_arm64.whl
Size 437.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7ed1b0c0fb46068863b31b13ebe36ba794cc18745a2b9a3a4b938876300e1d3e
BLAKE2b-256 checksum
How to use checksums
03d72ac786327dbf6676c49ed10a0539253f0caea1a4d9169530654e148c8505
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.dev20250929-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp310-cp310-win_amd64.whl
Size 424.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
35935a0d96e2c6da1959b499dc25c973b64ee7c00fc675018e0054c6ac606b2b
BLAKE2b-256 checksum
How to use checksums
3d07a0a5d695fa530c30f6132d260bac6a5be1b67d07cf968ece26309d84b580
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.dev20250929-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 508.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
986826d64e5d22d3454225d8fb3e4405976ef24cd5b1a95b553e234572651b65
BLAKE2b-256 checksum
How to use checksums
05a220d22ec9cbcd066030ce0783b1aa7d7acdc4eac2f36a2ad58e9dfd699f70
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.dev20250929-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 507.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
86360f8cacfbd1e90e50b43682bfa976ed37f10a4320ca576021c3eb4d371493
BLAKE2b-256 checksum
How to use checksums
fadb2eab3fd82d44fb3dde0665564c0ecd06652af12ca52850369b2e4df9290c
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.dev20250929-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250929-cp310-cp310-macosx_11_0_arm64.whl
Size 435.8 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bc066ad5b41d5af919b1007ed9e5527f2ca2aceb45b001c8a0c05660d5abec01
BLAKE2b-256 checksum
How to use checksums
c73b257577ab963cf68469c33b9eef98a1e8344f48f6533b69408d8676ca96b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

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