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

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

Download URL grain_nightly-0.2.16.dev20251222-cp314-cp314-win_amd64.whl
Size 530.3 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1b6d2207bcb6ea0361e3ea0a2cec480a974a2648d1cf610d00062525f4d0126f
BLAKE2b-256 checksum
How to use checksums
aa1ab6e4e675cbe906a038ac073a4f60251265227b8e4850c9527c57e91b587f
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.dev20251222-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 592.4 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cc803563db62d303164741f0344a7e4f7d3c3732cd534574c229487410b31fca
BLAKE2b-256 checksum
How to use checksums
10a680a8e59c0c754d62f0c0e29fc9da6ae60270ac4ab5718e4e08fb8fb2926a
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.dev20251222-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 593.0 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
82c6a3929b086436536248754606c332c618b9762ab93c2dcfacc1b5bdba3a1a
BLAKE2b-256 checksum
How to use checksums
dd8258e9f9dc38590177b7dcce3ef9e39afa693c39df3b3bdffcefe73fe0a5fa
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.dev20251222-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp314-cp314-macosx_11_0_arm64.whl
Size 536.5 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
45b96a790806cd91e35c905e3db8b24d321efa79e985493f4826838e874a93f2
BLAKE2b-256 checksum
How to use checksums
c61c4c000ad8b8c1a296ce4aa301e4b0c1664b67750f94ff22d1805006c95a46
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.dev20251222-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp313-cp313-win_amd64.whl
Size 522.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
bc82542994b171829246f8ac80df17ac5c496d2deffbc3940424b974db2ac70d
BLAKE2b-256 checksum
How to use checksums
942f7b189ca1f88930fafb95e8a6d74c620c8b324a96ea3f4378c2d0aaae8b43
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.dev20251222-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 592.4 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
eff42e12efde6c939f69d017e5e38b7b1fd56359d202927e878c6112c7465d13
BLAKE2b-256 checksum
How to use checksums
354bfe82c1568f2104e89c94f127da6e100c63f758060498a07822ed5eb5c9a2
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.dev20251222-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 593.0 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
a607828226ce6aa7e9162a443030527d84d2a688fd1429dabef96f2537559be7
BLAKE2b-256 checksum
How to use checksums
016048d8711b7098a7894ccf1bf187767630faaa91974d31d1695b755b944a89
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.dev20251222-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp313-cp313-macosx_11_0_arm64.whl
Size 536.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bc0267e532d95c32cf3163957614f8827f8c3812b819c4595b279105900d30f6
BLAKE2b-256 checksum
How to use checksums
dbc7017e1164e06dc77a63410dadd7e4b4490715014b3b855b7b7b6b5cdf63e6
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.dev20251222-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp312-cp312-win_amd64.whl
Size 522.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
8768b4641dbcde802f62923273149d8810e2251930ec7ff18cc5a876ea0a6bfe
BLAKE2b-256 checksum
How to use checksums
e00a2374403ee1c09e1436fc77c725c0c03c8176b268e6ae4a5197be350c6445
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.dev20251222-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 592.3 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f24daf963965dd7a63353334601f257b5a1563c8777c34b22338dced640dfa68
BLAKE2b-256 checksum
How to use checksums
45cf06f8cfd5688d963c031c4d3f357871c29099cbc38f74102fd7eb61b1b38a
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.dev20251222-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 593.0 kB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
da5c5628ac20f1d04f6340644eb5c0eef2b1ed1d9f162f774d7b06fe90c81476
BLAKE2b-256 checksum
How to use checksums
c65e9bf45e71c3da9aae988ad9c4ea3354080de11f1b4798fdbbd91ceef3a18e
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.dev20251222-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp312-cp312-macosx_11_0_arm64.whl
Size 536.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1b396e6ae7544fe937f73ca494a85efb153348e761ce79f280687441c78f724f
BLAKE2b-256 checksum
How to use checksums
7dc246f11d6fb97015c74c2bb5326a48c0c9258bf33fcc6a26deca329fc36070
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.dev20251222-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp311-cp311-win_amd64.whl
Size 521.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ad40d2cf79b948f4046d98273ffe127ba5ac1e2636020c6ea5c00bb05f9045be
BLAKE2b-256 checksum
How to use checksums
f7ab7c4003dcfde31db9adafda9e4afc129b8ff4eb8a802c937cacf821bf005f
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.dev20251222-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 593.7 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2d82fa19c6e3f99fe6d92524c97666ead951adc2800d302579b7826397083f69
BLAKE2b-256 checksum
How to use checksums
cc952680dca77150fec993602c445799473fa76b361e348668a48d97a7ff988f
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.dev20251222-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.7 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
170a00cbdf57481cb056cb8fb65673179c5efc340bb69e2d8f8d1c6f68f61127
BLAKE2b-256 checksum
How to use checksums
e0212f36bf990939a653f282787bd8ea34e81788aa9855c0ac61301a69e67717
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.dev20251222-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251222-cp311-cp311-macosx_11_0_arm64.whl
Size 538.5 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7bb6880ad9e02727f9224361b1798992f818ee0cc622e4160320522d595be05c
BLAKE2b-256 checksum
How to use checksums
3c03b97628da4aa7a77ada8395a677100812fdb916318813ee074ddf5fb1f223
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