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

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

Download URL grain_nightly-0.2.13.dev20250908-cp313-cp313-win_amd64.whl
Size 416.0 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3d59d2b10e99219412bea0868d19416327e75e0a85ef7186c49f65f06294ef29
BLAKE2b-256 checksum
How to use checksums
5ba1ee8d56c0a36f563cfd278d4003713feb39056fc877ce1783fa219fd66de7
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.dev20250908-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 498.0 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
10a3d449420d4359a25c9609c37aebd9c44e082a510cba8825de802e1be28de4
BLAKE2b-256 checksum
How to use checksums
af59673cde48f7d6e604a1406a2a1a91c655e9503e157570aa41d08f2e4399d0
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.dev20250908-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.6 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
c527a49988ffca35e6f985b62cb969e852195bb71fda500166228763ff93de67
BLAKE2b-256 checksum
How to use checksums
10f3299665916d02665f461edc77b7b9b850c29d8a9b541290e5978efe5118a1
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.dev20250908-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp313-cp313-macosx_11_0_arm64.whl
Size 424.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4e09aacc586e422fad159f4f0e6fedd6e93774e499fc5dc09da6dbf3a90de14a
BLAKE2b-256 checksum
How to use checksums
1a5b83c85779effc276883a3c504627623b1d896ba8919295f36ac99ef13564b
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.dev20250908-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp312-cp312-win_amd64.whl
Size 415.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
1803ada26a93f21e28d5f2cb0b08e90d620388244c69722af87a390dee5f59a4
BLAKE2b-256 checksum
How to use checksums
7855cf3dba22c591e6f95b33c357ee4acc9e92817c04c07cc79010b378ccb6c6
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.dev20250908-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 497.9 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
206945f46788db28e05b96ecbe9ffe0476ac6ada99448730e48788b97d041320
BLAKE2b-256 checksum
How to use checksums
02a71eaac9484f135c449d1d45c4178a8c40e973bae7b5a684cc69f8a3818765
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.dev20250908-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.5 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
3f723950b21a20b158b67cd72ceceee5521322d6436433f226670a5c9af7c721
BLAKE2b-256 checksum
How to use checksums
676eccba308012a25d7520e7a9bce713ea6a77a748efa8476b9e1aea1385c0c5
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.dev20250908-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp312-cp312-macosx_11_0_arm64.whl
Size 424.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6d0781ecc24fb8e59393467abe95cb39ff08653bc7cc2e4b8a9c5f47e7defd86
BLAKE2b-256 checksum
How to use checksums
f7aa0fa279cfd611a6ff27daaf833ec2657bffbf46e7f9026ec80b825461292d
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.dev20250908-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp311-cp311-win_amd64.whl
Size 415.7 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
065b92ca24f109b21566c0d1db56bdd291db869a4db71628de7c977c0af8a815
BLAKE2b-256 checksum
How to use checksums
b901abb5cef041d9e330738245e427da0ed6809168963578923f28895aaef874
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.dev20250908-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 499.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1b9d9903042233251c9177724f0ec68cd4145d5becedbb11ffddfacb5105be18
BLAKE2b-256 checksum
How to use checksums
3a52b82265a587c1de40f356108cd9fdcf0d4afd9ba0d526018f19aa1b02b400
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.dev20250908-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 498.3 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
58dc47524a1e09f6dc2cd2199157a3fd175835107e5646b35ae0902fa1644378
BLAKE2b-256 checksum
How to use checksums
1ae1141649c9fadda3fd9afb5924c9492d2ff31385de4f78cd120b00c9fccc5f
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.dev20250908-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp311-cp311-macosx_11_0_arm64.whl
Size 427.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5be7b5e79d7e1d6d3db7c712e066b76c7a80097887e651394556859b3f380ff1
BLAKE2b-256 checksum
How to use checksums
621363f65d321be643381888552820ab809d9d2b79c14ab4af3bea3232b45a62
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.dev20250908-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp310-cp310-win_amd64.whl
Size 414.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
110b237d763cde701ac1fb4d92cfe8ba8d61b1b10861a79633acb021219362be
BLAKE2b-256 checksum
How to use checksums
3114f598e6d93abf058374b0909e585ccfd67c3f166603e3131f05d8bb527315
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.dev20250908-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 498.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8395cbee21cda180ab31d7cf35cd6a87f15fcb1d7668db841c218dd40d0656ac
BLAKE2b-256 checksum
How to use checksums
e608cf4f1946db6d26c3499e5dadc0448d15eb76b8f65dcc7e49c0685ae38cf4
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.dev20250908-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
750648785f4a8ecddfb907fdad71c8a8cb5d3eae24338de04dc4902dc04bcb13
BLAKE2b-256 checksum
How to use checksums
e438752e34e5cefe531b9785192844e7aba60bbd737ddd746f74caed6291b20b
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.dev20250908-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250908-cp310-cp310-macosx_11_0_arm64.whl
Size 425.8 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
925a4848e2b53f4e757907bd7836eec581181bb7954ba318e553091eca13a519
BLAKE2b-256 checksum
How to use checksums
aced1a5d5033b417cb95a84ddfa0da0917a4732cdda729857ac5fe4b7fe66e87
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