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.dev20251006-cp313-cp313-win_amd64.whl (427.9 kB view details)

Uploaded CPython 3.13Windows x86-64

grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (509.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (509.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20251006-cp313-cp313-macosx_11_0_arm64.whl (436.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20251006-cp312-cp312-win_amd64.whl (427.8 kB view details)

Uploaded CPython 3.12Windows x86-64

grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (509.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (509.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20251006-cp312-cp312-macosx_11_0_arm64.whl (436.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20251006-cp311-cp311-win_amd64.whl (427.6 kB view details)

Uploaded CPython 3.11Windows x86-64

grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (510.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (510.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20251006-cp311-cp311-macosx_11_0_arm64.whl (439.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20251006-cp310-cp310-win_amd64.whl (425.9 kB view details)

Uploaded CPython 3.10Windows x86-64

grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (509.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (509.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20251006-cp310-cp310-macosx_11_0_arm64.whl (437.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cffa3356f8ed2f2142ef6ad3b115ac989ab9467ce015713bd81e3669695d54d8
MD5 9b9988cef357541b730bcfb5edae7e1d
BLAKE2b-256 e481ae825b78328b128e1b82b843ec5efed9a612c4377c87557c51a5d26bb545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0502d9145daa490e031ba31a322053a052a1a137438313d99bcc76ccbf28c6bc
MD5 b7408c7ef34f321c6a813225ac8b25ff
BLAKE2b-256 bbf2a2c30c580ac09f3130a1550e862be658eb79f7bcdcc0148885102c4431f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f7a13d6563cacfbc684006d366aac4eb016278408f23d000c12f3a99513aeae9
MD5 19d014ef66f91568600cd1d39c139101
BLAKE2b-256 116fb024afba589af80b651a78f6c73edebfbcad9e5400fb1a5f2de9f5bef1bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5bb00a227c443c1b8d546dcc8714515297e70c32ff144f8deaabc897353739c9
MD5 6ee936e7ac7bcaea89c6bcd520911019
BLAKE2b-256 fcaf351e7e95f3580df3bc5b0a1aeb34466f0219c4f13c99756c26c402255dfb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0cfbc0d4e493ac15adf7ba8dfc426f248b80e03f82a4ba2ffe8abd220b4b0a0d
MD5 ce8ee1763c438c95146a5ddd575112fc
BLAKE2b-256 998f7d0ecbdf436cda194403bec19e3405844f32c3bd4cf6c32946ff23ca7dd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c47a5783512d6ea8b3b5935d5e4c4124866a0d82cafaf9f00b4192a72e75b0aa
MD5 8d00782cab85d6ee098f8a24e5a71994
BLAKE2b-256 6e93e6858fadad65ea40c55c0e9879634d06c9c52eaa2c529c29a82c3cfda73c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 51040484acc97f046615334904b6eef2204ef80c6ed9f1d621b52b3e83a1ea74
MD5 c6723e9253000ec0de25462198485a3b
BLAKE2b-256 60f14f0d4aff034610da31f1ff447c99332c09d5b12bcfdb75503358b60c065f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc570f220dfa548a958bc21e4a5aff4bfabb5f8ca260e7d587f5fa1d1a95ea88
MD5 0b2d9ecad10de70bfb7c36a97b55bf78
BLAKE2b-256 b57cedfeaf7e7eb7556e8646edee9d90884d3972b075fca963bfb4423d54813c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fbc5b09607c85a5fcecbd818acf667b4222b856ea172aa45508385fa730aeb29
MD5 a681c2f5648d85c85afe15112aeb9ec4
BLAKE2b-256 e296addc20d5d738592cf6e1c1c747f4fbc3782dbfe76b5ea2b744d33a3903bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d08e22a5db259ff23287a7f926c5b99c00eb6808491b856d71739c3ae2f499b8
MD5 d5acdaed03424095f59e5c2801fc4cc8
BLAKE2b-256 0771e11b4022a4d3fb92d701556803736b01d81d554642bae8900ddde55deb98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 8d6090523a1c0d416f4c0d3a59e7a5b57003e155d6d5ebc6524c3626b477e2db
MD5 41f76baff5d43b3398c7348582e9d2ea
BLAKE2b-256 fb4a5048469426be30a92e3be539ff61505b629f25d520d82020619ff1989456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ba2a36d0f9fc84c4d4570e60cab016ab9b81151817c477c6941cc0b0dd05fcb
MD5 5c42baf65776a2c691708e579c4f9f1e
BLAKE2b-256 1c82a96afa5600745f65deb609311986d7b9f75a5de16b33e4ead7bc1927a48c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 80c4638ddafb48fb1b06a53464fe65c77d5db8da95f88b43b1b087ccf02601a8
MD5 a04b4767991046af9b1078b5e83bd04d
BLAKE2b-256 d828f6e629be591487897be4e1475f40344d02ca5a84f27ed58004d3696f75be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d1c9ce0316f0759e79540038599ea2add7983f575679a6b6f03fa1695b6fa514
MD5 d8f8c65fc86d1a4fd6577d992168d2d4
BLAKE2b-256 45ffe2b84d4fc134aaead986ffbafabd1be4ece65c495f31bd62c56a52e42312

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 60936dc3c16747e1fa86dc93778db51d97b23fcc258e79e60eae2fb7a633b8c5
MD5 04c7b7c14c645baae8fa5149481b8521
BLAKE2b-256 4609f14b2239be6150ad396cebc84b2b47717ae6a4639a5e4ae1fe6f8ca5985d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20251006-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c4bff4bc3b57b242c5259428e64ad6e2eadb0951586d8abd39df868994ee629
MD5 45e4be6452539eb5560ec4784890ebd2
BLAKE2b-256 b642cf6f5c6ca3e24ca26f81b7ce79849e53bb26a69a2eb7d87558b1e556225a

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