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.15.dev20251103

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

Total release size: 7.5 MB

Release files / grain_nightly-0.2.15.dev20251103-cp314-cp314-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp314-cp314-win_amd64.whl
Size 442.2 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
71e4c4a00af7297277550636cc788ec8e13dc3f3de39cab652382c3e8940a9e3
BLAKE2b-256 checksum
How to use checksums
19cbbdb5f7b2551d452b5e4ebf705487d22dbe666a2cfa24141c7dd04b1b9fe7
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.15.dev20251103-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 495.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
b23148b350ed2ed367c4f971a350b18ef6edd8a121157025d4b666ea9e99fe3f
BLAKE2b-256 checksum
How to use checksums
4011aada70fecd3a21038cfbb87f5521ece8565c4f7dcd19c8f5341a8bf9d0a3
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.15.dev20251103-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 494.6 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
dca5e6147de0e63a31e66418bde24fae39ae3a7729684d2bfff769b33be4dd3c
BLAKE2b-256 checksum
How to use checksums
555cf305ff6eb4ff5dc916af5da0a79c7105a0108988da4aa022aa75f378acd1
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.15.dev20251103-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp314-cp314-macosx_11_0_arm64.whl
Size 444.4 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0a3f965b9a72ff01e5f5eb2067d6aaabdfb5bcd8616065a3c367c378e14f1be0
BLAKE2b-256 checksum
How to use checksums
0e003adecb39855751c95db53e7a4697447f5dfb1f1f3855f5e34e27b1a7f23b
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.15.dev20251103-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp313-cp313-win_amd64.whl
Size 436.0 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8c5f1d5f190adaab153ace550188d16a1e38d9b05750931c9b46917bb0bb74ec
BLAKE2b-256 checksum
How to use checksums
ba57dc69e84396db48bde568053525f70bd04af9103ba3462197e5b882767005
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.15.dev20251103-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 495.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
5ce895e133d2fab176394d23a22c8134391b9938f77e0c9c1c60308b88f5f17c
BLAKE2b-256 checksum
How to use checksums
3e9e66dc917748a9e72694d94ce9551b49ef2c0dbb4e00a9016f793ef5b35b33
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.15.dev20251103-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 494.6 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
500d9f4995a5a5a9feec9239736a65c65d8cde7253d100d9c5b67dcfdc037af1
BLAKE2b-256 checksum
How to use checksums
03aa8ad327240449f851cd21de983ba7f3670c43b21cf5cbea4be4e205a1a37c
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.15.dev20251103-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp313-cp313-macosx_11_0_arm64.whl
Size 444.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
901abd14bb9de5702892fa878bdccc11b944295e45a8808695e0fb38d10e3440
BLAKE2b-256 checksum
How to use checksums
ef386f90d5159dc722c66a563cec462de0e59d29b21b4200cff39366216d2ad7
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.15.dev20251103-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp312-cp312-win_amd64.whl
Size 435.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
9cfb57a5f439d97f8dc717b264540c876d26bfc64be7fc8676e651f5e5832e38
BLAKE2b-256 checksum
How to use checksums
a1c7781fc7a2aa7f9281b432512db45e54174fbb6fb4b40ae1d08fe6bd2ddeae
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.15.dev20251103-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 495.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
375abc2df3a1f43e5b524327bf9271bf28a8f858f17d91c15c8a71d6adf62deb
BLAKE2b-256 checksum
How to use checksums
34a7527d01670cac62a158ed00cea9d9225f93f42e6921f154a6b1e4c78ff1c9
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.15.dev20251103-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 494.5 kB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
d3a83ff8fe620e3c7ad86b6c8eee3c7afe07bbf7d7e2a92f82eec3c1c78e1f38
BLAKE2b-256 checksum
How to use checksums
ca08ea29a11d85e766a51023982c6ece3aac05d3c9fafb447dc775c0a169c322
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.15.dev20251103-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp312-cp312-macosx_11_0_arm64.whl
Size 444.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6142b32676f4ad131a2974b3c45ba58c9a2e1ec97c7a31c69a03e4864cc2e324
BLAKE2b-256 checksum
How to use checksums
6036028dcd277860fc1fd8638c1dabc730e7061fa537df577f2db2c487bceb44
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.15.dev20251103-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp311-cp311-win_amd64.whl
Size 435.7 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c4f92bb1e0abdec7ade254cf9ea0c35ca9cad8e8fe665a19b1be105105a7e018
BLAKE2b-256 checksum
How to use checksums
f643df2104fed506dc0b9a20d4582d7ff554a1392498e64c9bb14d4140476dff
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.15.dev20251103-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 497.4 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
780e96acdc7125ebbd22169b91872fa248033f7342373a096006e2bcc6b2f9a5
BLAKE2b-256 checksum
How to use checksums
89789c7d372235b9926b3cc0b1a1fce2e0f77d74190b9e0a521131772f72de8c
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.15.dev20251103-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 496.3 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5b8f0f932b5bbc87440cef371b7c38ec9b28c439516a288576f60c94ed591beb
BLAKE2b-256 checksum
How to use checksums
7a24eb43af9fe0a1e366e9c9f5d632d8dec082d5056be1db4642b3ad05aad56e
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.15.dev20251103-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251103-cp311-cp311-macosx_11_0_arm64.whl
Size 447.0 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0909d6b24946c72e486c808687800b5d4f0d6a70ae2e0391e42d087ba5df7c52
BLAKE2b-256 checksum
How to use checksums
5d75d75576698a1d52ae0956e02585de391416d554efdbc46a8a59839ac43e2f
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