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 yes
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.16.dev20251229

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.16.dev20251229
File
grain_nightly-0.2.16.dev20251229-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
grain_nightly-0.2.16.dev20251229-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
grain_nightly-0.2.16.dev20251229-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
grain_nightly-0.2.16.dev20251229-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
grain_nightly-0.2.16.dev20251229-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
grain_nightly-0.2.16.dev20251229-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
grain_nightly-0.2.16.dev20251229-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
grain_nightly-0.2.16.dev20251229-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
grain_nightly-0.2.16.dev20251229-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
grain_nightly-0.2.16.dev20251229-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 9.0 MB

Release files / grain_nightly-0.2.16.dev20251229-cp314-cp314-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp314-cp314-win_amd64.whl
Size 531.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
aa67bd69f2c038e611506e9796fe27cae30412477e2a98c88db5f24ff67284ca
BLAKE2b-256 checksum
How to use checksums
994ba1e285fe3f28218d7c188cf6c1b355eb587a26f6aeb71aacd242c73454ff
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.16.dev20251229-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 593.7 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e612b56a4a0e4ec6d2705b0212abbc8137f7e53b0c5d325ffc31239a989ed6d3
BLAKE2b-256 checksum
How to use checksums
0e0fc938c55564d25fdfb3d1cd88c16c39bcbeb1b48130a70d5865cbabb20b9a
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.16.dev20251229-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.3 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
36dca2c38ca19c3b17a4e89c20c5740a0d5b580b36fec7ae66b1268f9a36ed95
BLAKE2b-256 checksum
How to use checksums
1d5ab5af4fc9286b1181a08c27ac1b8e4892741cf748e63d8f089f1c1abb9087
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.16.dev20251229-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp314-cp314-macosx_11_0_arm64.whl
Size 537.8 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9ee57cf3bb8ce4140ab6c5ae8472316fffe683c2d40cfd3c94532396961e3875
BLAKE2b-256 checksum
How to use checksums
6ad36a9338265d1a774403bf5126c6a09b73d321c288dc58d57861e95e97a777
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.16.dev20251229-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp313-cp313-win_amd64.whl
Size 523.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8b9dfbd9671bca0b018ba775b672f30f0f1dbe33e45dd49e185d6f09bbb1ccbe
BLAKE2b-256 checksum
How to use checksums
2a519f6ca569523feddf90a4ea5b4f35df3ec4b2117222e4e4f0ccd5cffa8d63
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.16.dev20251229-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 593.7 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d2a043909bf783ae515c2b81fdbfc9f29b5a65f046c2fd237996e388f2e9aa63
BLAKE2b-256 checksum
How to use checksums
66f7bd569d856af3f24aa6583603c27892c527f00fbc2a7c6dcea1b58484d73b
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.16.dev20251229-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.3 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5e5d88deec1f2c149954b3a32312811a12003ad08b039bc65afb8309dc1e006d
BLAKE2b-256 checksum
How to use checksums
514a61861ad9e65555051239d23ccf640e560267063506705559421a990e2a4a
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.16.dev20251229-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp313-cp313-macosx_11_0_arm64.whl
Size 537.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b3906e938063c35fcfa2c42015760887f0e25fb23cfc22d991ed0a52f421a111
BLAKE2b-256 checksum
How to use checksums
1108d7b9edaa5f56d9126f3c4696354546e593b4357bf771593183e2a19a4482
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.16.dev20251229-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp312-cp312-win_amd64.whl
Size 523.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
c9f1f7ee9ece4178048f2c7bc2421286fd0c71f3fa7f4d496d885d33c81ab0ce
BLAKE2b-256 checksum
How to use checksums
c4b261d5d54351778a5637fab88a62e798275cf78166585b8b323cfe58a5d9a3
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.16.dev20251229-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 593.6 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
05f3f0268a25bcba5f231b25f00f8685059064145cc17c8a235e3a6b022444c5
BLAKE2b-256 checksum
How to use checksums
c62d9947530dabe84e38606c21a3807b3f55010df1174b9dce9a27f84811f6a6
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.16.dev20251229-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.4 kB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
363f66799bd79990b843a68545551bf07e0b04b2d77e02297cb527ed80f5f398
BLAKE2b-256 checksum
How to use checksums
154d71f2725cb0195e0d535f6ca87634f7d87ac553e0ffc49dd8c7ff74e993ec
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.16.dev20251229-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp312-cp312-macosx_11_0_arm64.whl
Size 537.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d3552c92db62a6b4c2314b33e32d928c5708d49ccd0ab61ec0399d621e446495
BLAKE2b-256 checksum
How to use checksums
bd0444860e71da33577f344b64211277d0e92d9416cc08b1d493b83ced636726
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.16.dev20251229-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp311-cp311-win_amd64.whl
Size 523.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c0d8256dd25982114554e645a366e40151545209cd40aca545ea7cedd69ff730
BLAKE2b-256 checksum
How to use checksums
df24acfaf59eeec13b7c0f0c47659f822d57a84f47f75fb982f2f7c868179782
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.16.dev20251229-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 595.0 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3beda7d023b7552ec4c6cd6ff2d766b08d318f3a40686e0fc76f24dbd3de5872
BLAKE2b-256 checksum
How to use checksums
24886c13f64cf73c227f0bc9c7871a98184de977254d5048922cdcd07e0b5565
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.16.dev20251229-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 596.0 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
59324aacac3211a1fe1f88080edc674b13c27c1c4fda36b8755b0df4ea1fdf5d
BLAKE2b-256 checksum
How to use checksums
ec39a571e627b8400b9cebb2c1d50c234d0c41c104807bd265fc3f9c93c67a15
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.16.dev20251229-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251229-cp311-cp311-macosx_11_0_arm64.whl
Size 539.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b6302cca9c0b7ae346d19c0f1fcaddc3157f503f528cb7d43dc75d4fa4c7c858
BLAKE2b-256 checksum
How to use checksums
dd6cc8d82cd1b1d97ef93e704e98a2391018eaa44a5b8bae32f26e2d4d5b264f
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