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

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

Total release size: 7.4 MB

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

Download URL grain_nightly-0.2.13.dev20250922-cp313-cp313-win_amd64.whl
Size 418.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
69365b7179741ca551b104af9ee83b45d93b82ef8c525d6ffb6fb91e7fe4824f
BLAKE2b-256 checksum
How to use checksums
5033c66814859989ae97939c567c5c0e89f0c4ebcaa51151c767b3f985d0b1bf
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.dev20250922-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.6 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6784cf672fcfe78d3ecd73b02768bdf9f87f4f8110436c846d05f23f7da08243
BLAKE2b-256 checksum
How to use checksums
5b2659a5a45532a99e9e2cb09d7dd0b2fd711cf06377773cd89ad7227448aa59
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.dev20250922-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 500.2 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
9fe718366009158027c9802d218d5d78c477646d83052ac090c5bda7f9b541ac
BLAKE2b-256 checksum
How to use checksums
73932f68f0b6e358756373b22d472749d698edab5ccb0d010fb835b4f62ef1a0
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.dev20250922-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp313-cp313-macosx_11_0_arm64.whl
Size 427.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2acccea19cc4f16cd9e388a856629612e9059ed4ea1a4b49d9abea00b21ac2d7
BLAKE2b-256 checksum
How to use checksums
5d1eabc9a64eef64f1c4e00e86228f8a2143322a348ee10d92125ad7263b2832
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.dev20250922-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp312-cp312-win_amd64.whl
Size 418.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
271138fa6984f86c02604b070c07f0b2725ce035ae76565e4ced962a037e6f04
BLAKE2b-256 checksum
How to use checksums
44065011779deef28236580461b1fb78d8a0390779ff3b6ee4f7a23c428eb928
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.dev20250922-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.5 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
beffd6e204f2fe06b16e5204ec47673ee1b58d5e6e9d13d6b7fd34c6aecf7a3f
BLAKE2b-256 checksum
How to use checksums
69f072e129bda593125d0aae26fc54ebf0ee8998d71c856171b37622f9a57204
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.dev20250922-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 500.0 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
06dc00d1258d84e9b3f220efce1666353e781d57ef938837450a51c602a1abc0
BLAKE2b-256 checksum
How to use checksums
f564b77e5c6cbde80d9cf48225714a91fd581d7bb28b0b7df9f498134d4bf541
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.dev20250922-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp312-cp312-macosx_11_0_arm64.whl
Size 427.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9210b30a2ffbc761b0884ea90ddf554036d5fc996e4b1f192d71397d3516901f
BLAKE2b-256 checksum
How to use checksums
b51ece7a0920276af1a8e90510e1023cea5f77caa6778245f54167aa7a539dc2
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.dev20250922-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp311-cp311-win_amd64.whl
Size 418.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ddf79f992c0e1717eff99d81d42ec89c928d4305312c86386a1e3a324340d79e
BLAKE2b-256 checksum
How to use checksums
d5931143bde817beaf90e2326cc4d1a3cf2b06f3bf72f498dc5e458aed55d029
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.dev20250922-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 501.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6266cbacbfdfd26801601bed3882c76f7e8d29708e375a2e1c8cdccbdcb2130e
BLAKE2b-256 checksum
How to use checksums
1b27c9e3490811cea12da86900a75e0f2e1158405f77b830091728370bc07247
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.dev20250922-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

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

Download URL grain_nightly-0.2.13.dev20250922-cp311-cp311-macosx_11_0_arm64.whl
Size 429.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b46a309a1d33a30d6a8acab5166e31244d198b204de067211312f79c8c42331
BLAKE2b-256 checksum
How to use checksums
09d34d1c82cc7d5e0b278d4c2181ab77c3ea12bc9f519d5642127f558a26c75b
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.dev20250922-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250922-cp310-cp310-win_amd64.whl
Size 416.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
f497f528620e14102eb0e062c15b83df90cef5ddd1d6e768a9e2118ac0a827c1
BLAKE2b-256 checksum
How to use checksums
37555e90efa32b3fa4690404e55705c998396d7b4aba969eb2b69f00c8efde9e
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.dev20250922-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

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

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

Download URL grain_nightly-0.2.13.dev20250922-cp310-cp310-macosx_11_0_arm64.whl
Size 428.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2fcac79dfb1724c5ebae98c16abb4ff5e742bf594e915b5bac7ac2b7bccfc0c0
BLAKE2b-256 checksum
How to use checksums
124bd0d6870cf1d30d4dd492fa8bce1888f7d1c87ddd2053418d3656a1bbe537
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