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

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.dev20260112
File
grain_nightly-0.2.16.dev20260112-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
grain_nightly-0.2.16.dev20260112-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.dev20260112-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.dev20260112-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20260112-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
grain_nightly-0.2.16.dev20260112-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.dev20260112-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.dev20260112-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20260112-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
grain_nightly-0.2.16.dev20260112-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.dev20260112-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.dev20260112-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
grain_nightly-0.2.16.dev20260112-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
grain_nightly-0.2.16.dev20260112-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.dev20260112-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.dev20260112-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.dev20260112-cp314-cp314-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp314-cp314-win_amd64.whl
Size 533.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
7708e35eb6d849e5fd0e30a822b883a124b4ae4182a6d6f6f088455999dc6c39
BLAKE2b-256 checksum
How to use checksums
aaa555fef419e43696891f6d7c745aaa33f83c77c5a6668ad0aebd987de4917e
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.dev20260112-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 595.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
ba944ad08b9a5d961ea4eac1eb40c66b9a101b7589ee3980f3f78bc1f3319eaa
BLAKE2b-256 checksum
How to use checksums
a87b80d6a8ed069daf7233b425d31720ee4b69ffb210f4f10fd42b065820efb2
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.dev20260112-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 596.3 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
9ac457f3a458169410b3ee59a24c48830e921821d16fe1958b4a00fc0ba6fc9e
BLAKE2b-256 checksum
How to use checksums
a654208e5306bccf3987f54e4f469abf786f4f69049eddcb5f407ca04621c5e8
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.dev20260112-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp314-cp314-macosx_11_0_arm64.whl
Size 539.8 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1549019a27ce03dc0c1dd0f9404bd46606fc4708e4768a1cb6c1626a92183db2
BLAKE2b-256 checksum
How to use checksums
92f444ac09a6aee3d4dea833bfa2ecc05a674da93d3393f0ff03abe555e9c491
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.dev20260112-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp313-cp313-win_amd64.whl
Size 525.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
0b1e1dc1c7facd182d4ca18607554be2c97354ff263ade18fa064a0cabe2c61c
BLAKE2b-256 checksum
How to use checksums
26477bd6d0e21ef66d96140dbd7430ff15ebb38a2b4b140197d41ca71fcc51f3
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.dev20260112-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 595.6 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
44d4edf208f7c3f9d9c4c1a1e1cdb96c5c4ea5806c29430a546fb5e42e8e3b2d
BLAKE2b-256 checksum
How to use checksums
59148cbd1faec189d489f9f9680e6c9f9a0dd4ba81087826d3890b0e22c93cf0
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.dev20260112-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

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

Download URL grain_nightly-0.2.16.dev20260112-cp313-cp313-macosx_11_0_arm64.whl
Size 539.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
68ca356facbb327dde319ec5aa5e468677db71e564abde5156c63c207cb89c91
BLAKE2b-256 checksum
How to use checksums
15fee00901c5de82f89f000f97a2d04231bc668d254399cb91cdd05272e028e8
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.dev20260112-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp312-cp312-win_amd64.whl
Size 525.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
b03db816099307390bdd66c42471cd01982b6e1e4eadff778a3a4f8d0f8b0708
BLAKE2b-256 checksum
How to use checksums
2ce990facb89245ece63ed954a02d794cdf43af391ab303e1bc83ef215751caf
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.dev20260112-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 595.5 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
084d57ea3b461062ebf4d42496b8f61942cd2667e2e05189a1192fa7e9159f38
BLAKE2b-256 checksum
How to use checksums
543de8abccb43c6e5ffe5f4efd3872d3330c1f06f3abbb5ac86c4aa7897d54f9
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.dev20260112-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

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

Download URL grain_nightly-0.2.16.dev20260112-cp312-cp312-macosx_11_0_arm64.whl
Size 539.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
70719eac722417d6eb93e8c46f34f41e9af76bea14dddf347d3fef969530e6c8
BLAKE2b-256 checksum
How to use checksums
7352a61a06fafacedc451aa5a82ef65fbd619ac14273432e0dffda8c1ce124b9
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.dev20260112-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp311-cp311-win_amd64.whl
Size 525.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0b2670b4b68999334df133527a5a25c58e752027d61a8d7f73b9992151d6654e
BLAKE2b-256 checksum
How to use checksums
4a719775be10a3f23bdf98182e37d6989d119e8ca1b60b13314d7f24e0551454
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.dev20260112-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

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

Download URL grain_nightly-0.2.16.dev20260112-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 598.0 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
ffdd01aeefc5a1c912bcc7aa6f591af26124b33c3eef6ed614f5eda51719330d
BLAKE2b-256 checksum
How to use checksums
2db606f487ba5350e17cee51ef22a4997aa693638c64cb7fbf12a0f976d0a37c
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.dev20260112-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20260112-cp311-cp311-macosx_11_0_arm64.whl
Size 541.7 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2feac3a94e0ebd1a0086fb2651325701498aa86a8b46939ba68bfc3b663b5cad
BLAKE2b-256 checksum
How to use checksums
7f5aea93fbbfc29ae3f7dda75d5e876c96ea17fdafbbea51a875cb055e4f3de4
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