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

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

Total release size: 7.8 MB

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

Download URL grain_nightly-0.2.15.dev20251201-cp314-cp314-win_amd64.whl
Size 463.8 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
904f82044392484d952d24c8d498fcd0c1a207347870bc31c9502cee59316431
BLAKE2b-256 checksum
How to use checksums
c45cc6d456f67e5257b782212d7853a504aee224b311da46383a094ec4e57758
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.dev20251201-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 517.0 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
76f85550f897f8e2fb500c0e18bd832227282f28e41504eac3166c75c2352859
BLAKE2b-256 checksum
How to use checksums
73f8c4237ee1ff1b11f90b327d8946591abf4e06aa3587b902711a56b32b0c9b
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.dev20251201-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 516.1 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
a7cfb3a7df367f7791e74e61ae39994519bc4d9e2d9a6dc02f086e55bd6a4012
BLAKE2b-256 checksum
How to use checksums
ae04d8398d797efda4c0ced1acffbe6359e5d6a17db179b4897be23b03202db4
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.dev20251201-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp314-cp314-macosx_11_0_arm64.whl
Size 465.9 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c23de6b11f580ce0512367b780f7860ee62e8eed185b83280e89ed8429fad8a2
BLAKE2b-256 checksum
How to use checksums
f6ef79879b1ac4e77809ca2c5facf703ebaf52986884ebc64fc8324c1c6b2d9f
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.dev20251201-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp313-cp313-win_amd64.whl
Size 457.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
ea73ab1dafb7385ea0ae3e569d86c4d1363a54af636465e263db70340870d5c0
BLAKE2b-256 checksum
How to use checksums
9893ba9187babfdf614312d89791bfe2655bd6f6401e4e9df915d73a4c2aab42
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.dev20251201-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 517.1 kB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a146bcb08eca37084608fc08379416626147175ae1ba77663d5bb900d827676d
BLAKE2b-256 checksum
How to use checksums
401dd21825e65e059a0e87722044152fe64bbfdb73a8eebbb2c4bc8b38894387
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.dev20251201-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 516.1 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
a62875cd4f3f06effe5a5350dd8ef80a57bdbe206b3ee054f5e225b7e13df7a0
BLAKE2b-256 checksum
How to use checksums
3c94b1f1d64f6773b3f5a7cebab6befca78f294dd2521c39d2174b96b545b028
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.dev20251201-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp313-cp313-macosx_11_0_arm64.whl
Size 465.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4d912943942cd974ea4ca786b0f18067d7809c3b2c6a7237e0a4ba4cc61c86b6
BLAKE2b-256 checksum
How to use checksums
7cb1c035da4cd0f64d3538b6824cf0fd0b78f5cf34db218794cc91a58cbebfa5
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.dev20251201-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp312-cp312-win_amd64.whl
Size 457.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
b8fbcd620779d955cc2a4e089ce83653dd144cd6f1cf132d8a46bb9e3071cabb
BLAKE2b-256 checksum
How to use checksums
33bbf97fb322d2311828d9f8403f49e4f03f38d2a5de304cf636973b116be7d7
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.dev20251201-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 516.8 kB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fdf001ec8433d7847fea3d0140065935f9a2316ef651ed1cdc786ef955803c71
BLAKE2b-256 checksum
How to use checksums
bd4059af0732c4cb230ccadb6cf308c0daf792a5689adefbf49ea17e5abcb962
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.dev20251201-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 516.0 kB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
1992f8be2983147d430f1bf83c59ff8fbdeac4c427faa0df04554e51b8830b96
BLAKE2b-256 checksum
How to use checksums
964f37ccb72d0643b99e601b4de975abba9aecf6e640bcf537a304acb569a890
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.dev20251201-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp312-cp312-macosx_11_0_arm64.whl
Size 465.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
63ce6f2e6593cf91d0c30d5f8bd772783ac2b3ffc7b4c0e693d45b311af52b3b
BLAKE2b-256 checksum
How to use checksums
281ec654a5577bbb25c11d9539c764a2dd5fecd4f9330927ea19c67beeaea0c6
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.dev20251201-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp311-cp311-win_amd64.whl
Size 457.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
5bd7d2eda849e6c00f9fae2ff86a1d9e7d0aad885989f13d03250e39e8d6b165
BLAKE2b-256 checksum
How to use checksums
62e7db84da06c4799934cc8cc9ac6c05a4be13d49c0e1d0a3e9d3ef5934cea47
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.dev20251201-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 518.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
2770e42e15d4c7449ed25303ddb555e57590666491226882617ec5f12b063893
BLAKE2b-256 checksum
How to use checksums
e20fb04b6e623c553a9045d55758ed4cd09b4e6a8dd66ff04102f1fbeb262035
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.dev20251201-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 517.7 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
8fe7395511c46fb942ca788b49a7b0eb7bb3be4b4d21ea571f80925a196a9c03
BLAKE2b-256 checksum
How to use checksums
c5865cf9e0fb79a4ac9139f102b3ca9dabdea99de0ab16303ce03ef706ef38e4
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.dev20251201-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.15.dev20251201-cp311-cp311-macosx_11_0_arm64.whl
Size 468.5 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ede0535142a0d2529fb01247326c922e0edf452a7131a84c60c672d95184d086
BLAKE2b-256 checksum
How to use checksums
297deca52ba9c628fe0825d098f92d05172b4ffb57e642c9e3c03030445b0475
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