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.14.dev20251020

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

Total release size: 7.6 MB

Release files / grain_nightly-0.2.14.dev20251020-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp313-cp313-win_amd64.whl
Size 429.2 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
aa1a0597689ce91649ce6388685e502ada7afc2174a225ceb3663beb9ef6d5ad
BLAKE2b-256 checksum
How to use checksums
66c185c70974681a376bd6ecd9ce2166639f30aa80663af8f8c49b66cc646208
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.14.dev20251020-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 511.1 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e4e9ffcb6c99bd78cb49aaa025b019c99d925ed644499bae1bfc17219fa72513
BLAKE2b-256 checksum
How to use checksums
e6bde438c1f68a6e84fde3336acf82b45f8cf090885cda73672dfc67ec8c039c
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.14.dev20251020-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 510.7 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
a8886d4df656afd03a9bcd04263deadbdb2ff7d8b3b12bef13673054f2126a96
BLAKE2b-256 checksum
How to use checksums
dc8d9399c3af8f7d72eacaf58aba64ca0f57b1322fd65e6353151b7c6a9155e6
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.14.dev20251020-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp313-cp313-macosx_11_0_arm64.whl
Size 437.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e459e8b5986790d3e0d62e01d141be6c13a6d932da34129b1d5865fa2b218980
BLAKE2b-256 checksum
How to use checksums
7b35ffbea175f377e1ab73960d00b6c0891ac5f01a1bc39d839bb97f116fc451
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.14.dev20251020-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp312-cp312-win_amd64.whl
Size 429.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
1d6706e7569134b88ccbcb243affaf7cdc0f78024d546d24a35e00cf0a1ce5a4
BLAKE2b-256 checksum
How to use checksums
0fc5522a7e1e192e3717331e62486e4bd6e39118dba6607846852b5b8ceed4d5
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.14.dev20251020-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 511.0 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2348d6a75c47b755f3a47457ad403eef66a7d217880495ed66d5c21466634cc7
BLAKE2b-256 checksum
How to use checksums
1370465b0d09f1a105062aa93cfc3480514a7fefadb529c273202430cbc37703
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.14.dev20251020-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 510.5 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
17ae3c74d39b990a73e2c7831a7a8e0b9b0fb082c676acd829051e83e6a9b2fc
BLAKE2b-256 checksum
How to use checksums
8f493e9f4e977fee9a427b511720183676cb462d81da99075e1d6f459a1a5fdc
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.14.dev20251020-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp312-cp312-macosx_11_0_arm64.whl
Size 437.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b2f0af299d4ec0c570272e5f0c71b64cf8feaeb0f1c5fafe92c5bb6b7209686
BLAKE2b-256 checksum
How to use checksums
f1a900287dddd0936a4c9360808c78e8e793c838be056c209763e1ddd89bc20b
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.14.dev20251020-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp311-cp311-win_amd64.whl
Size 428.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
5aa2e38bc20b2bc9b70b2cd325a0af1f516a357c2fd88b2f4e1cb22b4c67840e
BLAKE2b-256 checksum
How to use checksums
77c1592f5ce4bccd1df1703734c750ddcefdea06b09654451d0f07eae29f304d
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.14.dev20251020-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 512.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
43983b74aa9b0f62cb927995031551396fe9e2b22d32a30eebd51f7e3255d78c
BLAKE2b-256 checksum
How to use checksums
482b67fecc0a43fdb66f2e4598d88ed0259a7c848d7a786dd4d13493352fb5c7
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.14.dev20251020-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 511.4 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
ccdb4d0067a38060cd546bb19c57f2aef79a2ab68b47e78e8d8d6701ce1ca4e1
BLAKE2b-256 checksum
How to use checksums
0e41179b2bbfbdb9f889ce4e75b3b292e6d2b5ada8a7d446d639aef92830a722
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.14.dev20251020-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp311-cp311-macosx_11_0_arm64.whl
Size 440.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f8216ee0e8be1560ca6399d2637de9008fe6ad06edd392106d2e0c9227ec5ec7
BLAKE2b-256 checksum
How to use checksums
1f22cd12aac01c8c3603639a6b0d35d9cde175ac627a4398a99511f96ba2be04
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.14.dev20251020-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp310-cp310-win_amd64.whl
Size 427.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
e9ab1a0226e4da6f8b21c03b7aa80dba8534378c69a56c38f6f32122e490d263
BLAKE2b-256 checksum
How to use checksums
906a4209a19262e404b9117f96de45b3091764a49478de0ab6c96b3971817028
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.14.dev20251020-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 511.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3964d531120c91ac8bc42481170038dfe3a6fb0af950fd1650bfcf0d5578b02f
BLAKE2b-256 checksum
How to use checksums
a9a52eec2951cec4d5e283988f2abfcbdc4ed201d97651cf3416825cbf5e80e7
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.14.dev20251020-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 510.6 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
46f95ffa6180715d62ca3edae5fd3ef15d772d8fffec69546581da97fae04bd8
BLAKE2b-256 checksum
How to use checksums
1bb43e6b989a9f374e73b55e162b2890ad8f857e854509a90495cb01afac48a6
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.14.dev20251020-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251020-cp310-cp310-macosx_11_0_arm64.whl
Size 438.9 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2226e21af0a49e90491dfebfab55b25c95ca1127e445044c26be4dfa93060246
BLAKE2b-256 checksum
How to use checksums
d4cedf3955e4f348b09bfd850e54e23bf8e7c549759975823348c569577526f0
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