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

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

Download URL grain_nightly-0.2.13.dev20251013-cp313-cp313-win_amd64.whl
Size 428.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f12ab65bac035e36910c37d15baadb81a8bbc0d034a8bd01fc7d0f894f75da2c
BLAKE2b-256 checksum
How to use checksums
a5861d436344504ce4ec60dfcbc7f60f270d7141145c0ab032bc60bfa7c02055
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.dev20251013-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 510.6 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
28f691b1d7a5c67f17874b34f03e3e5b3370f0b52a1d7d3523edbac02a2bf276
BLAKE2b-256 checksum
How to use checksums
25de5cbcac86314c52994ef0b38befefeac0476936bc31e9560ab87ed7c9b82a
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.dev20251013-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 510.1 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
45c52f17874224b5f77fe1489506131a728f413dee7d8ee6021122f5d50b2677
BLAKE2b-256 checksum
How to use checksums
2c1e3fe802b7620ef4fd5eec275483aea51c77ceb23fa0317dca682957b2e27e
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.dev20251013-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp313-cp313-macosx_11_0_arm64.whl
Size 437.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a0bc7fbeed1947c9736b580041f210de27f79475809db3b2b3ab8b3cfd0c08f1
BLAKE2b-256 checksum
How to use checksums
80a7131c1d1be5357c032e0993f3e8a7634364cd522fdcb7b8e6eb3efd60f94f
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.dev20251013-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp312-cp312-win_amd64.whl
Size 428.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
5f065cc95cbd34e699a0bade2c43e0d77cc588ec2f8cf34c2897fc3bea1b7452
BLAKE2b-256 checksum
How to use checksums
035e3bacfb68c4cf667519e9f107bed855f712fde8699ec68d2046501945b123
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.dev20251013-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

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

Download URL grain_nightly-0.2.13.dev20251013-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 510.0 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
751a05a20f9888216fd2f34cb6d186721bdec685e43c836dcc78d54074a45222
BLAKE2b-256 checksum
How to use checksums
3c6dfb4772db8009a9bc00bab7d1cf23eeae1bdfe10ef270e4950c309f6f3965
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.dev20251013-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp312-cp312-macosx_11_0_arm64.whl
Size 437.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
78a7e685ef01ad05466c5d63926f39960a7f0aac7773d61dd02b507e07494f83
BLAKE2b-256 checksum
How to use checksums
59e9b93a7fe4f198aa52d1308c92ee2f4e1d69317189c51686dc8f8ec84a52be
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.dev20251013-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp311-cp311-win_amd64.whl
Size 428.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
47fe42b6a60cef96734506bf67eeeaeae38e9a3b8039cf25d9aa8f7a7c95537b
BLAKE2b-256 checksum
How to use checksums
2755a90049324b2959d82afcf48c22a6d1bae5eb09f50043fb225311672652f7
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.dev20251013-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 511.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
17e07cc46a92e1d06c85c3fc7c1cbb068e43da0b7f5cfbf662b31dee805d8f54
BLAKE2b-256 checksum
How to use checksums
5a500dd6a8431fbe9e5d5a9c1992016a198bdf4d5469488db4abdee09eed7274
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.dev20251013-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

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

Download URL grain_nightly-0.2.13.dev20251013-cp311-cp311-macosx_11_0_arm64.whl
Size 439.7 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ce3fe22401a2358fe30aab965666a2b93063c076496dd149adefecbd39ae728b
BLAKE2b-256 checksum
How to use checksums
032093bc0f71d73d36fa7c360234f8e86ab902de94316dce9346eb98a5ec0c0e
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.dev20251013-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20251013-cp310-cp310-win_amd64.whl
Size 426.7 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
6e62e40a370a6c1af8ae2e34f4e3a4c66a0ede833ac69274940df0cfa67ec7c8
BLAKE2b-256 checksum
How to use checksums
e72df48a4ccfee55d3cd09f5c4abaa8bd7da2f41548f17b8c08ce5cd1caec4ce
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.dev20251013-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

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

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

Download URL grain_nightly-0.2.13.dev20251013-cp310-cp310-macosx_11_0_arm64.whl
Size 438.3 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2fce9736722b949d6477b02a6471602727a02c15d7e4243615579c13818bc13e
BLAKE2b-256 checksum
How to use checksums
de89fc33f3bff4e3e7b486319dc4dd5d5640de90698ae436f06b9b583298f160
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