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.12.dev20250818

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

Download URL grain_nightly-0.2.12.dev20250818-cp313-cp313-win_amd64.whl
Size 407.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
6f1f2217d9dc24d664ce9a12fc9dfde939c0d07a9220e049f6932427d29e0875
BLAKE2b-256 checksum
How to use checksums
5fbff95322cfa61f627f5563a0f3aa048313aa149744eec6a3c1d49f471f5d54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 498.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3089560685de3ae12418ff046a8d86225fc0c1bdd7760147d462c4255a48718d
BLAKE2b-256 checksum
How to use checksums
be9cbcf990d1129e96991358b80f92adef595428b5eaa034b3a2f5439c702f74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.4 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
96108d88fabf49358f19a9308081c99a372b399b5c4970ab43f1b488c1191a56
BLAKE2b-256 checksum
How to use checksums
7757db2819cc56a9fee3f8b67b12ef8f5dc4b333fb4b3ed551e4cfb1ebf81648
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp313-cp313-macosx_11_0_arm64.whl
Size 417.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e00150dfeeb07439c4461748badb2de9aee7e4febfef49b24d36e0084a499dd
BLAKE2b-256 checksum
How to use checksums
41505d8603c7810699d19c75a6dfd9dfcea58ed2e633482cf2e4a549c8b66a01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp312-cp312-win_amd64.whl
Size 407.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
79025716c318b51c9bec5e42778c3003e0fe2bdefec678c6a0c041b2eb16b338
BLAKE2b-256 checksum
How to use checksums
570728383b125ed9e3c96eade879455e074d034dbbedcd44a7dde44157999197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 498.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
64f0f0d54979fcf6d812f88ff04264e4b540061137a7ef1586f93b0e0f15ff29
BLAKE2b-256 checksum
How to use checksums
a0e6f88897612ca97901abe881d58afde4c2ca98533d1d3b6d9fcf300eaad6c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.3 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
cb00480a9127104ec4c1bcadd43c6f78212fccbf0202c5b2611ca3222789d70e
BLAKE2b-256 checksum
How to use checksums
f148707ecc96642d584faafdacf4b8e25c81a281bdf20b42c0e7c4b8029157d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp312-cp312-macosx_11_0_arm64.whl
Size 417.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
30f283a018744175f724578030a15aa55f7b51d0304d3a55e802068a656a5034
BLAKE2b-256 checksum
How to use checksums
1037252055332141dc9e6c3ea1f77c905ce9393e5ce68528124bdad4bb9ef105
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp311-cp311-win_amd64.whl
Size 407.1 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
cd713fd3dbd9df3e2e895368dc49149bd05e44db25a2800aa7351145d3ed6cd1
BLAKE2b-256 checksum
How to use checksums
07d39216cb62cac67d8a132cedf5b705c9e6100ecd69ebb883ef0f047365a581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
04b06700a08d9754137c135286b87bfb3980dca9a8093caba7c8c425e4b7cd2a
BLAKE2b-256 checksum
How to use checksums
cc316e3a8c3729c70dd108e28b13c0a74e817d407bbab165003fe8cf4b04b87f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 498.7 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
3a2f7f688ab0710db34982ddfc0046b5d7a12cd2e53ab7ee10f280b4970a60d1
BLAKE2b-256 checksum
How to use checksums
656969992ac016ce38f7c5d6b867c770413f2e765c21b06934ed614548c00472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp311-cp311-macosx_11_0_arm64.whl
Size 419.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
41ab7e54fe20979e1b6035a9e15aed91874e9a983e64da9cd0ce1c9248cb8b19
BLAKE2b-256 checksum
How to use checksums
c91e183b13c35650206e64abf2be845210cc767cc572c2ea5a80f07ffed159fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp310-cp310-win_amd64.whl
Size 405.4 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
bfbc999344ee55396751eb510320bea971f409713d276f978bd10df7dc512c63
BLAKE2b-256 checksum
How to use checksums
9848910515749f344568a40fddcc57770ca43dd222d1b9f4302ed5296349b5f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 498.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
aec789cc13f391ab785fef642ebbfda7fc80cbf01572ae10c6314e49d32d951f
BLAKE2b-256 checksum
How to use checksums
2c5def062d2748303b98082986fe75e01777ff34a05dc5e0ea063abfec4ecb6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 497.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
48e45620a1afadb5ed9a4a8a6b01d3ff1bf91b0aa414b54977a35a67f5edab9c
BLAKE2b-256 checksum
How to use checksums
18f16b87bc7c79a295c6503b2e30b3db6a1a55c054ff38c0bf82e9aa6b5183ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / grain_nightly-0.2.12.dev20250818-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.12.dev20250818-cp310-cp310-macosx_11_0_arm64.whl
Size 418.5 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b7967091ac3a249060cb115489a7d75966a7a374488b688a8a37ef2fc94bf14e
BLAKE2b-256 checksum
How to use checksums
5500619a692e25a18703a7fdd4c84a3beda2b011280c75c254f8712db0b6020e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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