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

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.dev20250825
File
grain_nightly-0.2.13.dev20250825-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
grain_nightly-0.2.13.dev20250825-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.dev20250825-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.dev20250825-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
grain_nightly-0.2.13.dev20250825-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.dev20250825-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.dev20250825-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
grain_nightly-0.2.13.dev20250825-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.dev20250825-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.dev20250825-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
grain_nightly-0.2.13.dev20250825-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.dev20250825-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.dev20250825-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 7.3 MB

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

Download URL grain_nightly-0.2.13.dev20250825-cp313-cp313-win_amd64.whl
Size 408.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b3f3958cabf99342abd18decc3791ae6176024d820cfb35f2ea2214497a3ecea
BLAKE2b-256 checksum
How to use checksums
24168a3a492eddfe427d97f2f8b88f02fc4f1e1f9a525b8b3cd25514e369d4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 499.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
61529c84f3873e1ad0356c061fe0bc5718846e7376a05443abf73965fb224ee7
BLAKE2b-256 checksum
How to use checksums
f6d0f08b5dbe27800e6409fc1f133821da6aa1654447351f08032f7191f508ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 498.4 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
f2d674580d896195b8df30743fa7170dfb4239fb0181a7533529e97273395b93
BLAKE2b-256 checksum
How to use checksums
5c36ea538bd738a6f205713ab29791345a78be9873c6286944234b5da6fcd89e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp313-cp313-macosx_11_0_arm64.whl
Size 418.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9e71b0e7ba3b0247e583da5e98e9ea13d6619fc00ad7ba09f31c3e846df883bd
BLAKE2b-256 checksum
How to use checksums
f2f909e207c188d99abf3ca59ec24ac19b281c2038a899d67a3d708ccee2ce96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl
Size 408.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6a2f7cfa2590d50b14a332a93a4d5e45a9691695896e2fb039d47c7f54c38d71
BLAKE2b-256 checksum
How to use checksums
e3749c1aa93aa07181c479bfde62e92f75c825e3f7735c3144031ba441659342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 499.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f0eadcb1668b45a08a0c7e39acd89870ee139e491841ccfbbe045d1ad24ff370
BLAKE2b-256 checksum
How to use checksums
1b827bd04e2b48ebf85709913c0de3dac26baa0e4a7924bd19c26c4dcd3715fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 498.3 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
49d4d2d0257d9847e1f4cfe33740fb81c6c0e1196ca3a5107fcee34fdaaba380
BLAKE2b-256 checksum
How to use checksums
2a170c166b299a3cf5e91ba19a9ad2226cd53d3253d6af3fdb1b8fe410727d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp312-cp312-macosx_11_0_arm64.whl
Size 418.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fac251c919a48cff1944c405469f183a52546f8b6250b967843153d3c06f7a3b
BLAKE2b-256 checksum
How to use checksums
ccc1b5c5ae8d2f666dbb274355e8d36126b8222de7d3f86e15223e395cd26d3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl
Size 408.1 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ea278cfe6c591fced976fe4efe23eaf94d34b3778a203c1072fcdc4dcff4ba53
BLAKE2b-256 checksum
How to use checksums
7e715e753ed04a0c759415ca6986d1c9859e91384a27d6a28b943e52eeabbf88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 501.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8ff4a442807d1ec4f9f181cf16f2716154c37ffb7f984267cd5c9c86411ea1ea
BLAKE2b-256 checksum
How to use checksums
4c8271ef8acc72d725129a118f45748dfda1c62432385223afbdafc1660417cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 499.7 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
42698dd5ec14000fd7114fa53ecca5a21c6f9f857ffdb08d7965bb21d1400bac
BLAKE2b-256 checksum
How to use checksums
e8296a518f01c013992b6ac6541914358cfcb874cd258957636718476fd78588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp311-cp311-macosx_11_0_arm64.whl
Size 420.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5e93c29e75cbfcad343036e2e109f2c0e6be6f8ca0be6e6d7cb222656dd7f5e2
BLAKE2b-256 checksum
How to use checksums
1a24fbad9d209f6a1aaa17106f6779939f307cd206dc144c6429ced711028539
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl
Size 406.4 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
b86111ad8f02c0e9b714161ac60736cbb00332d8a85b6e02c2c2602863fd0477
BLAKE2b-256 checksum
How to use checksums
5e27a9217f1a0544b09e1c4ecdb23f550f1bdc0b96fc57a7eade20da6710e8c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 499.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8aba74821e298085fa128a0c7eede63c5d5899b4baea1568efb434245ced9844
BLAKE2b-256 checksum
How to use checksums
f41db89e0e650fa31a5eab6db3b612485b2301daf862283e0431dc92bbea8690
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 498.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4ff0326528cafdb7d4f832a7422753b725636a4660e97948968ded373038523a
BLAKE2b-256 checksum
How to use checksums
8971e7ca5531a0554ce4d628e5c8b71cbf61cda02ff28dece12d584522db08ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.13.dev20250825-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250825-cp310-cp310-macosx_11_0_arm64.whl
Size 419.5 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
486f29c51eb8c32cb816568175fc272183790f180e34713099e42c8628266aa4
BLAKE2b-256 checksum
How to use checksums
847074457abd2c715fab0e6292e8390ffc3da53cc5f9a8f4a130f1e73e07ff5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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