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.13.dev20250901

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

Download URL grain_nightly-0.2.13.dev20250901-cp313-cp313-win_amd64.whl
Size 409.2 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
af240e505cea32428540b2b0a080ab9255198903213f322c972146735e9e1b52
BLAKE2b-256 checksum
How to use checksums
796aa02bfa8c9ed20410cd2fe7ef0946ad463acd4b7e1e3011f93519e7bea291
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.13.dev20250901-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5a0773b0ceadfd676551796f5d63cbe20fd3a81b323debe5e162ff94dc3b94fc
BLAKE2b-256 checksum
How to use checksums
6d8968de2d07fb38a787dee2dcb5618406d3be4587e45e7b6344b076bfe0fde9
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.13.dev20250901-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 499.4 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
796511e57b94a65e047eabaa7a8cd5117832400738a803cc95036e7eff1ad26e
BLAKE2b-256 checksum
How to use checksums
80e084b28c52eb7f753a8c1ef8c73a6366efadf31a3f59b6ab721478355b4354
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.13.dev20250901-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp313-cp313-macosx_11_0_arm64.whl
Size 419.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
20e5b8c046be24373f2d5f2a0697cd709a4a21473bbcd4476b428cce8ecff319
BLAKE2b-256 checksum
How to use checksums
958c8f9d132a73f7af4d1fcd84d8f006e348154f0818d0abeeffb07aefa15a6b
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.13.dev20250901-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp312-cp312-win_amd64.whl
Size 409.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f9667f1ade11050d5347b5251b0589f6f9c2f3467685b9d7cc8bad49e4a0e586
BLAKE2b-256 checksum
How to use checksums
c417255abd52a7ba2f4eefb3f88a9e36c1687470e15031fb2f16b7a0ab28571c
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.13.dev20250901-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7ef02597cd0b80a6610125adb59493debebb54aecc1d08942da374ff936d3575
BLAKE2b-256 checksum
How to use checksums
8914f00b9a3716f6893c784061812b69bc6449b78deccf456a8999827da8a4cf
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.13.dev20250901-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 499.2 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
b57f9682e832cd84045cb86b0ae4b98bc439f89292c60e203cb6961352a6e421
BLAKE2b-256 checksum
How to use checksums
693fea5132abc4ae67cb9c98af306c8241f602c521994d98e3975745e73a7779
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.13.dev20250901-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp312-cp312-macosx_11_0_arm64.whl
Size 419.2 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
643eb08414eb74bda6407c69295d89ad770c42d8ffebb3e03328ba03af6b14a6
BLAKE2b-256 checksum
How to use checksums
efe36a5ac01a96637340dab60e72095453aa7aec6acbb978fb8c625ec6e3e785
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.13.dev20250901-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp311-cp311-win_amd64.whl
Size 409.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c42d7dc36d506b375e9e5c0401bcd4e3a2062ed68097041eb6be7f893934ef4b
BLAKE2b-256 checksum
How to use checksums
a8761ead3b61eabc5dbb85114eeba3446c1a3b8521e388c175c989c485a32781
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.13.dev20250901-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 502.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
dfd3870ee776f8363bfe97177446dd3dfb4453c69a76cf53cffc970fdddd840e
BLAKE2b-256 checksum
How to use checksums
0884433b104b2df238edc97a9bb2ec39aa2309e8b69e6d04e6d3c25d507e9fca
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.13.dev20250901-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 500.7 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
5d4b25c0a31013c343bc18b8bad37411d0c08bae54e36e3ddaeff03fce38112f
BLAKE2b-256 checksum
How to use checksums
4f5461a76d4aafe9be761afa8aeb1e7c7009fab3eb7357e677ee7f53045a02ad
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.13.dev20250901-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp311-cp311-macosx_11_0_arm64.whl
Size 421.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
98c0d32594b740e8478429acff93c60180f7005890271d59b616d3b0d008ccf8
BLAKE2b-256 checksum
How to use checksums
34e4fbe46fddc966695d7048fcac025e105650547ec95e74da139d019e8a2ace
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.13.dev20250901-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp310-cp310-win_amd64.whl
Size 407.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
f6266c7421982f4370eed7fbbbb98e671c53f0b661907a23480405ea5be8a99f
BLAKE2b-256 checksum
How to use checksums
7087bd89aba3e0ed144f7ddcf9ec6cba8ae7aa578f3eeffad8a3732677734288
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.13.dev20250901-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 500.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
426e29b89f62f34ac6397bb4ce44b2e6890a4b66a6b5e7ea99f600b5451f8fb6
BLAKE2b-256 checksum
How to use checksums
74244e5c4b81abb0fd98964e3b8f7ae6c0df6365e1e9cb992d9b7ddc67f60338
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.13.dev20250901-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 499.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
7877c3b785140182afcc5076bae17c7f6ac52290ed6dc2a02556f2444c5269b8
BLAKE2b-256 checksum
How to use checksums
81708995ecdedf4540e7c24760a9788fa3f1192b8e205c3cade6f046001211f1
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.13.dev20250901-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.13.dev20250901-cp310-cp310-macosx_11_0_arm64.whl
Size 420.5 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0d649fc3c5e810664486ced1184d1a6faa2e9f016dcd4429e3f2f627b46c275f
BLAKE2b-256 checksum
How to use checksums
bb7097a7981902aae0c88f4ea7c339563a23463405935709d17ef866a6ac5235
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