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

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

Download URL grain_nightly-0.2.14.dev20251027-cp313-cp313-win_amd64.whl
Size 431.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
72096d60450da94066b66880e1cbac046c79242926cf83d8209e9762435d7106
BLAKE2b-256 checksum
How to use checksums
d82d3014caccacb3a344ba1f4044dc838c57c0f8aaa9e8417887e481a9bd96e6
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.dev20251027-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

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

Download URL grain_nightly-0.2.14.dev20251027-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 513.3 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
39d5c93c759c9e90cb96df08b56579dc87016dacbe5e62a1a68ab9bfee10daa2
BLAKE2b-256 checksum
How to use checksums
c2da40041535457641ef29cd623ae93c58bea6f5ed3f657a4bfe449fe58cb123
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.dev20251027-cp313-cp313-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp313-cp313-macosx_11_0_arm64.whl
Size 440.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4da119aee80502ee8fd90544089479a27b1e789fb3bb513a87f652a075a8be69
BLAKE2b-256 checksum
How to use checksums
e806743c6621292141b0f73cd6f18975a29a86a114a9a538b93889b357ee65a8
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.dev20251027-cp312-cp312-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp312-cp312-win_amd64.whl
Size 431.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7845b51f0699d8275b47c75759fe2b2692eb7e27afdb1a54622be9ec7b338c12
BLAKE2b-256 checksum
How to use checksums
c62ceb53c61b894c9ccdb6b681a0e7622a1403826913b7d8d91d705e49963747
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.dev20251027-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 513.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a08675d11e1aa4a07c3ed03e323709bea8e008e4f991192e10a16a57b8ae65a8
BLAKE2b-256 checksum
How to use checksums
94538ebd4256da8b2151f483cc0bfda1c40201d45c88ecb8c4b2973c79306227
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.dev20251027-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 513.2 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
3f7d4c57038fc31580fc3a1c98f3c960f1a9a27316b94ec526d29a171394c690
BLAKE2b-256 checksum
How to use checksums
40a0c973f3f04e2ec862ae4df42ae8154e2e1c4983b88428360bd80255fb5a4b
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.dev20251027-cp312-cp312-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp312-cp312-macosx_11_0_arm64.whl
Size 440.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
25710673de55d99fc1bff4fc8457d2abad2815be18dbeab89614e67a3a3e41f2
BLAKE2b-256 checksum
How to use checksums
e5a54c69d62f2ae23a205f0320ee5b5e4a3381e1871556c524cab5b7a81c3bb6
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.dev20251027-cp311-cp311-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp311-cp311-win_amd64.whl
Size 431.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e7469e559b6a52890cb5d69069fd9af9ae5d8c28dab2d7ede675acef0a5489f6
BLAKE2b-256 checksum
How to use checksums
2b744526c2b406e81daf119de0143de9b8ab2d84fe4d9ee67ad347ed224f3035
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.dev20251027-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 514.7 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b65be44bc1f62e42ed8b876a48b3302acd430059c369004779714f839868541b
BLAKE2b-256 checksum
How to use checksums
035968426fba199ab7a40fb788e3f111f985b7617c453a27a73091cdc7cdc045
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.dev20251027-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 514.0 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
8f290fc387719737047941423c6c45dbad7f5849c0bd7c9b09989f7efcf0b10f
BLAKE2b-256 checksum
How to use checksums
20d3daa6e9bd024222b2017526edf7619c46751b822ae5dc5da6407ca3728e27
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.dev20251027-cp311-cp311-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp311-cp311-macosx_11_0_arm64.whl
Size 442.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3c070ab4c863b51d62fee625c962cc7dac51eb077080c8f0283e56af2bc02731
BLAKE2b-256 checksum
How to use checksums
ba1e6d1c03c387608517dd0e1c831ab9989b51a7df00b6efbecc9ad720c40c1c
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.dev20251027-cp310-cp310-win_amd64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp310-cp310-win_amd64.whl
Size 429.7 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c0f14b58e6eb2b3cb6598698928ddfa7716b57f3671b52abf04833ac438672fc
BLAKE2b-256 checksum
How to use checksums
3fe8b0e83832cabdf9880646a7fe65c85f44fe7a05ac3ea0a1e3cb1cc8e3df0c
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.dev20251027-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 513.8 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6eba4e9080599cb18553f4ca0f115cf098ae5ccc1371e3cb8839099c18152ba0
BLAKE2b-256 checksum
How to use checksums
5756ad9168f399eef9e02ac6684f13f895becfadfaf121decdce237d25218edb
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.dev20251027-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 513.2 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
6334f3dca4562b3ea970eedec3fc2f04ecaa4c8471cf27d1d25c88203233fcfd
BLAKE2b-256 checksum
How to use checksums
0cd510fdd3a31118ee3cdbb2491b540f338fc59532c6f78df63929db8904308d
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.dev20251027-cp310-cp310-macosx_11_0_arm64.whl

Download URL grain_nightly-0.2.14.dev20251027-cp310-cp310-macosx_11_0_arm64.whl
Size 441.4 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d8df88106a9d01883f61fbc25fd202e821a7ff828864e86e5635faa8ced6e9b2
BLAKE2b-256 checksum
How to use checksums
afa7951b94d78696ee42d08bcd33c592b2934cee9f024a29a691648a7fc88028
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