Skip to main content

Grain: A library for loading and transforming data for ML training.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

grain_nightly-0.2.13.dev20250825-cp313-cp313-win_amd64.whl (408.3 kB view details)

Uploaded CPython 3.13Windows x86-64

grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (499.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (498.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250825-cp313-cp313-macosx_11_0_arm64.whl (418.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl (408.2 kB view details)

Uploaded CPython 3.12Windows x86-64

grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (499.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (498.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250825-cp312-cp312-macosx_11_0_arm64.whl (418.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl (408.1 kB view details)

Uploaded CPython 3.11Windows x86-64

grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (501.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (499.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250825-cp311-cp311-macosx_11_0_arm64.whl (420.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl (406.4 kB view details)

Uploaded CPython 3.10Windows x86-64

grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (499.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (498.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250825-cp310-cp310-macosx_11_0_arm64.whl (419.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b3f3958cabf99342abd18decc3791ae6176024d820cfb35f2ea2214497a3ecea
MD5 c8a8295351756d8fc45694e298332002
BLAKE2b-256 24168a3a492eddfe427d97f2f8b88f02fc4f1e1f9a525b8b3cd25514e369d4e0

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 61529c84f3873e1ad0356c061fe0bc5718846e7376a05443abf73965fb224ee7
MD5 47c51912b50aa17815cc5a014b3e20ee
BLAKE2b-256 f6d0f08b5dbe27800e6409fc1f133821da6aa1654447351f08032f7191f508ad

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f2d674580d896195b8df30743fa7170dfb4239fb0181a7533529e97273395b93
MD5 1b1b1e1d0cb8138689a78c9d62a6cb65
BLAKE2b-256 5c36ea538bd738a6f205713ab29791345a78be9873c6286944234b5da6fcd89e

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e71b0e7ba3b0247e583da5e98e9ea13d6619fc00ad7ba09f31c3e846df883bd
MD5 111488844ab707126152590989b51b96
BLAKE2b-256 f2f909e207c188d99abf3ca59ec24ac19b281c2038a899d67a3d708ccee2ce96

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6a2f7cfa2590d50b14a332a93a4d5e45a9691695896e2fb039d47c7f54c38d71
MD5 590311f8d84c2ab26e15c9b463020618
BLAKE2b-256 e3749c1aa93aa07181c479bfde62e92f75c825e3f7735c3144031ba441659342

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f0eadcb1668b45a08a0c7e39acd89870ee139e491841ccfbbe045d1ad24ff370
MD5 5a214501bcc8a055b70a037c6b83f495
BLAKE2b-256 1b827bd04e2b48ebf85709913c0de3dac26baa0e4a7924bd19c26c4dcd3715fc

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 49d4d2d0257d9847e1f4cfe33740fb81c6c0e1196ca3a5107fcee34fdaaba380
MD5 04be95c1d3434fba86b9bc8a3854d1e8
BLAKE2b-256 2a170c166b299a3cf5e91ba19a9ad2226cd53d3253d6af3fdb1b8fe410727d19

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fac251c919a48cff1944c405469f183a52546f8b6250b967843153d3c06f7a3b
MD5 7593af1a27d5c94ca73d3b44a482ea9b
BLAKE2b-256 ccc1b5c5ae8d2f666dbb274355e8d36126b8222de7d3f86e15223e395cd26d3a

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ea278cfe6c591fced976fe4efe23eaf94d34b3778a203c1072fcdc4dcff4ba53
MD5 0fdf9edeed56038d259d7410f8b31280
BLAKE2b-256 7e715e753ed04a0c759415ca6986d1c9859e91384a27d6a28b943e52eeabbf88

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8ff4a442807d1ec4f9f181cf16f2716154c37ffb7f984267cd5c9c86411ea1ea
MD5 2d4d90c8c50880cc71aa7a80b59dc974
BLAKE2b-256 4c8271ef8acc72d725129a118f45748dfda1c62432385223afbdafc1660417cd

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 42698dd5ec14000fd7114fa53ecca5a21c6f9f857ffdb08d7965bb21d1400bac
MD5 f1b3b4f968c847a92630ac2d71d9f58f
BLAKE2b-256 e8296a518f01c013992b6ac6541914358cfcb874cd258957636718476fd78588

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e93c29e75cbfcad343036e2e109f2c0e6be6f8ca0be6e6d7cb222656dd7f5e2
MD5 5f19af199985e4041b64682eaef712c0
BLAKE2b-256 1a24fbad9d209f6a1aaa17106f6779939f307cd206dc144c6429ced711028539

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b86111ad8f02c0e9b714161ac60736cbb00332d8a85b6e02c2c2602863fd0477
MD5 2b50f0b5c2541a2a1d040001ed3e2787
BLAKE2b-256 5e27a9217f1a0544b09e1c4ecdb23f550f1bdc0b96fc57a7eade20da6710e8c0

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8aba74821e298085fa128a0c7eede63c5d5899b4baea1568efb434245ced9844
MD5 abaa006580558b2ec93e62a41461517b
BLAKE2b-256 f41db89e0e650fa31a5eab6db3b612485b2301daf862283e0431dc92bbea8690

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 4ff0326528cafdb7d4f832a7422753b725636a4660e97948968ded373038523a
MD5 7817a718bea4ff1a32253d14a4e585ab
BLAKE2b-256 8971e7ca5531a0554ce4d628e5c8b71cbf61cda02ff28dece12d584522db08ba

See more details on using hashes here.

File details

Details for the file grain_nightly-0.2.13.dev20250825-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250825-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 486f29c51eb8c32cb816568175fc272183790f180e34713099e42c8628266aa4
MD5 b0898cec1457bda0d015099b713e9fcd
BLAKE2b-256 847074457abd2c715fab0e6292e8390ffc3da53cc5f9a8f4a130f1e73e07ff5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page