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

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

Total release size: 8.9 MB

Release files / grain_nightly-0.2.16.dev20251215-cp314-cp314-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp314-cp314-win_amd64.whl
Size 523.8 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
c74a9844b6869e1fc9f7fcc8393650eca3a20695d5ef188ec8c74cad8c4747ed
BLAKE2b-256 checksum
How to use checksums
2a52e768e209f0b1e72fcefa1c3e0f97b22715b6314095b186b9cfdb65baed23
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.dev20251215-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 585.9 kB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
18aabc2d8fe238c0e757cf1188bfdf895a44b593c6fdb88feb8c758d6cd6a197
BLAKE2b-256 checksum
How to use checksums
d2e05d20f68aaa375c7b951593da137d43c39970791bb7dda7efdcdfeeb697cd
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.dev20251215-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 586.5 kB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
14055ee5c68b6f998211acf9240916484dec1b5a2d3685a647ec8a5af1da2f4d
BLAKE2b-256 checksum
How to use checksums
1587ade7ad6e05f9b6821754202407285c42790964a90d99783b3d612857e6b7
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.dev20251215-cp314-cp314-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp314-cp314-macosx_11_0_arm64.whl
Size 530.0 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4604a1821dc521dc98e6ef426a1eb1a8f7c6f09c2002de48073bad729ef51d14
BLAKE2b-256 checksum
How to use checksums
d4c053fc23f9f6a3aaa4bc81d51034c837cf5d4d61934ddd64693831a6852876
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.dev20251215-cp313-cp313-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp313-cp313-win_amd64.whl
Size 515.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
fb297010a18fa28a14ba4dd8ef745d74d10bf74684a2a885ecba885aeab1baac
BLAKE2b-256 checksum
How to use checksums
431717cc138976095d5171f65b2bed4288a245848571e992732049e196fd5021
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.dev20251215-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

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

Download URL grain_nightly-0.2.16.dev20251215-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 586.5 kB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
ab5f92bb5142056ce56338201cebf87f6157b3dc3ce1e2116963a9c45947813e
BLAKE2b-256 checksum
How to use checksums
16d3f5b4c3a557fd92b9d877c74eaca9d26061312844c4b07fbe9aba452c3b8d
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.dev20251215-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp313-cp313-macosx_11_0_arm64.whl
Size 530.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
de628fccca022ca963f8a58ceb6638476a58c2744f90cf4477dd4a5686e757df
BLAKE2b-256 checksum
How to use checksums
4e67a9a4b55df55d20e0b4209fa7ffe93afcba563908c99467a4909431deb117
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.dev20251215-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp312-cp312-win_amd64.whl
Size 515.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
dd9325add2f265a4e8637e8745e66e425a9d193e200a61de9886ac90b8f86f3c
BLAKE2b-256 checksum
How to use checksums
0eaad4c592404e8108ed128334d709600a848636ffc4ce96f8ce38808a567f19
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.dev20251215-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 585.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
0e58657cd8e23a5eb64e701d98c87c8253c298165e64a29f3fec5211a76094ff
BLAKE2b-256 checksum
How to use checksums
7ca318254aaa8d8f754c3d6f80b5ddb70e97dc305095a9a394c62dc712f03041
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.dev20251215-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 586.5 kB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
7dd83bc6c0339575c2525940679ed525405d555d26e2972d7e994f9ae208e1a5
BLAKE2b-256 checksum
How to use checksums
8ebc9b5a7dfe5cc398458c48f9ffa1d28799967d8ebf394cca92bae3aa36b138
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.dev20251215-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp312-cp312-macosx_11_0_arm64.whl
Size 529.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8efac519695bd4d12447f13e14d0d7071519f61326181d47f5f8e0302bd7a504
BLAKE2b-256 checksum
How to use checksums
620f6072e3c7e5dd8cce3fc17b0eb22c7e4495c73fba2166442238dd24a8e4d6
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.dev20251215-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp311-cp311-win_amd64.whl
Size 515.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c957ff54a7ee86a30e51ff8740409beb14ec8ffdaef8edcd3f8f7c5ebc7d9edc
BLAKE2b-256 checksum
How to use checksums
52faab866c5352a6d3d0c94e9fda310d940ff163e963412ffa9ba991ab11264e
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.dev20251215-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 587.2 kB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1b0cef11efbc325c53f3cbaf36ad07314ab083471037173caf92f0e400c95d7f
BLAKE2b-256 checksum
How to use checksums
97380d94ad039ef2e6885f2269442b43396b578b814328f044670e39dfa42563
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.dev20251215-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 588.2 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
48ac1374bbff0ecb0c5f9280422de39fbd8d22289ea257ff043ffdcff702236c
BLAKE2b-256 checksum
How to use checksums
49614462d276dd3a0cb5e9dae367cfa3a8ae0cced69a3b5dc2f5a68d5642989c
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.dev20251215-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.16.dev20251215-cp311-cp311-macosx_11_0_arm64.whl
Size 531.9 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
af2a221fb6357ae35beea4112052b1dced9f650081b7a3fc882b0ad98911d545
BLAKE2b-256 checksum
How to use checksums
43f0cad45f136a23844cac0b806c0446ed41dd6a84572f08e7f6c18a4cc2620a
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