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

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

Download URL grain_nightly-0.2.16.dev20260105-cp314-cp314-win_amd64.whl
Size 531.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
44e11ea9d16effbc58572555d055e30ff1db9181b788a1edcf34b9587569ef24
BLAKE2b-256 checksum
How to use checksums
c2d0b87b0ad6231b4f279581fb7f3347f32296156915077246e8629d39b088ad
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.dev20260105-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 593.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
6a3995fc9308d1864a6bed9c8a2bdeb2f681e160200ae9cd447a29301b3242f3
BLAKE2b-256 checksum
How to use checksums
d6c16d8100182abd4db2a3c69cc47e87047500bca0b9a0f9546b82235d1978a3
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.dev20260105-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.3 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3b353f293fa37ad123cccca1eac5721159360c8d1ebca184000e23353f0aa7c8
BLAKE2b-256 checksum
How to use checksums
12c596bd703cac2047dfe362cceab3bc7db34beeff1d346434a0807c88600dd3
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.dev20260105-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp314-cp314-macosx_11_0_arm64.whl
Size 537.8 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b6b6a3bd0943ae82ab52b838fc1c1eb09ffd8b64852ffe8ed7645f1e06515331
BLAKE2b-256 checksum
How to use checksums
19e33a3b6dadefd49dd37e9e217cedacc3e16e7c725f670ffed94f86429c74e8
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.dev20260105-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp313-cp313-win_amd64.whl
Size 523.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
7bbcc824c5b09e2255825c143b69d5d6541c4158856cbfe473c9399f2f77c7aa
BLAKE2b-256 checksum
How to use checksums
e7ed0eee2cc18f7e9c9a312c83a789eba0ea631a6efb24063f16f799d02c1137
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.dev20260105-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

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

Download URL grain_nightly-0.2.16.dev20260105-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 594.3 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
9f912b7c9518bfa8aaa45f62755e9deefc7a09d1f11400865900d7281dc3048f
BLAKE2b-256 checksum
How to use checksums
9570835b6677fe7135819f25976f9cf8da272ccec63f9429c090410ef23fd6c3
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.dev20260105-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp313-cp313-macosx_11_0_arm64.whl
Size 537.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e13772697236131158e9352bbf1c0236448870fbf70bb8c1dd89e00a6de4d984
BLAKE2b-256 checksum
How to use checksums
0e9fa076a25d083f0b01888f84b8289923efec866c48810375345a6077c82f6f
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.dev20260105-cp312-cp312-win_amd64.whl

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

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

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

Download URL grain_nightly-0.2.16.dev20260105-cp312-cp312-macosx_11_0_arm64.whl
Size 537.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dc78443ef0460d55ec718bfaadb08071e3131723465a73d50e314e6f9abe1b46
BLAKE2b-256 checksum
How to use checksums
a2d447603e8962e66a180312ba38cfee61cdda449f803c02a3ade579832fe4ff
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.dev20260105-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp311-cp311-win_amd64.whl
Size 523.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
86c14c26003657fffa4e3d2113f26cc14cb582a4ebdbcd592453c855ff99558b
BLAKE2b-256 checksum
How to use checksums
ab9f24349c786e8479e7105607808e33b557428f8019a1abf555efdcd71c307c
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.dev20260105-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

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

Download URL grain_nightly-0.2.16.dev20260105-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 596.0 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
69443093517447fb1bf12867296cb28cc7eab59f6744f33d0671d57fe64706b3
BLAKE2b-256 checksum
How to use checksums
69cf4596bde3d8db7178574245f9f83a2bb8e1f68c309bfadc6743cd7680b83b
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.dev20260105-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20260105-cp311-cp311-macosx_11_0_arm64.whl
Size 539.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8ec50a8f5deab21d8587b5ceaada7be101ee646de2debb76cf9c07819e3c0a57
BLAKE2b-256 checksum
How to use checksums
37cfbdc13520088758aa72540a9595f6481f6f38da8677a77bcac837607dfa39
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