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

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

Total release size: 8.8 MB

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

Download URL grain_nightly-0.2.16.dev20251208-cp314-cp314-win_amd64.whl
Size 521.4 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
ce1bc8b02ec49d47d18f90e0595a3f00431ae600e386f851f45a9726eb989607
BLAKE2b-256 checksum
How to use checksums
ddcdda8623128161d74efaeeeb82a314c35dbbf1503f8dd10ef412ff048462e4
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.dev20251208-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 583.5 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
48d6dd714c66dffa38b27650595123dbe6816f550a5998581f72dea7b8b60c6c
BLAKE2b-256 checksum
How to use checksums
5343a35eb9b24d1931cc20bff6ddc035f716c0c7a8241489075713108f165e77
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.dev20251208-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 584.1 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
42442a5e0a233798940e36743d644053220d42de13fdbb6344397d23b08a28f7
BLAKE2b-256 checksum
How to use checksums
6f0b839c40db45572a3cf258d50415018c28c6cdac315909c0c414481a0b7873
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.dev20251208-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp314-cp314-macosx_11_0_arm64.whl
Size 527.7 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5493081a5d07c9533d2f155725c8b483e6ee2b57e35d9c11c05f7d8aa0c77eee
BLAKE2b-256 checksum
How to use checksums
cf73b5253c587504a6ab1461de7352250a9c3f71ecf0b6a641b0757fe8712fc4
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.dev20251208-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp313-cp313-win_amd64.whl
Size 513.4 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3aba9147da7702e31f2185ddf8ae743cda41ac560c3a1b660b23a007d3b77efa
BLAKE2b-256 checksum
How to use checksums
2c2a2a7764939c1adc760cacb7cda341dcdd6d450027f274480b9bb78e27f023
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.dev20251208-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 583.5 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9ac3a3c04eafe35a46e9dc443b23252dc4cc3a7c4d8145af698fe35d8b98f429
BLAKE2b-256 checksum
How to use checksums
2b118da3c5ccae4d490794e3e7a23c8bc6d8ec15f7622f34a3a9f2e9f2d6844b
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.dev20251208-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

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

Download URL grain_nightly-0.2.16.dev20251208-cp313-cp313-macosx_11_0_arm64.whl
Size 527.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
40ddde8a9f4c718100ab28c59b1f133914840b4f68111531dc32de725dff42b4
BLAKE2b-256 checksum
How to use checksums
301a6b0d125f992d578f1461ff0b7d89b276743cc69a6a7f36adb8b7f9de9fff
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.dev20251208-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp312-cp312-win_amd64.whl
Size 513.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f8f347d1f190a5c6ba5ff9a48d9c49064c46b00d46cbabd1a4090f0b9c4d67c3
BLAKE2b-256 checksum
How to use checksums
a53711902dd98ee92e1275a9cc19d1c7f09df938fe34bb6dfb37cb3b51e4b950
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.dev20251208-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 583.4 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f8231a89b41cebfd30b4e640a2caa16e96e7db90095663ac6b257ed8abf09a99
BLAKE2b-256 checksum
How to use checksums
41fcbac58dcbc0fbbe92a961e867dc56bf383926c1cf6f72dd5c731a9a52e739
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.dev20251208-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

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

Download URL grain_nightly-0.2.16.dev20251208-cp312-cp312-macosx_11_0_arm64.whl
Size 527.6 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e4903daf09d7570e3870b70060e3587414349474445dcdc84e2d6de6e9ba896
BLAKE2b-256 checksum
How to use checksums
e84a944b0c05d138c266a012fcc8cf87fc0b27ad253e8c8470207d8c24e8235a
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.dev20251208-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp311-cp311-win_amd64.whl
Size 513.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
8021c51bf7c10b96ef66a90934f40d0fe39c34190f6d3696ac81f8549c6f5d22
BLAKE2b-256 checksum
How to use checksums
1081b7c5b59da8fafad1b27b12fbbf9880c6ca7d601ff2a1a88614c455682395
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.dev20251208-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 584.8 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
62e6aaf6c65bd776ea74f2fd09e11060decd64170d310ffea9e1be989605c513
BLAKE2b-256 checksum
How to use checksums
1d4b3c68072547761bfe2f18c42586de0cc077f2ef0edd7a5497ffb2ba89fefb
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.dev20251208-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251208-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 585.8 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
96aee659a9f3cdf923d3724f66bb548bc0689a87e1596f2702948203f7491c08
BLAKE2b-256 checksum
How to use checksums
0db6515327d9761e6317105f4693e54290f6c9bedb09d3e2d6a7ad00773298c3
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.dev20251208-cp311-cp311-macosx_11_0_arm64.whl

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