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

Uploaded CPython 3.13Windows x86-64

grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (500.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (500.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250922-cp313-cp313-macosx_11_0_arm64.whl (427.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250922-cp312-cp312-win_amd64.whl (418.5 kB view details)

Uploaded CPython 3.12Windows x86-64

grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (500.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (500.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250922-cp312-cp312-macosx_11_0_arm64.whl (427.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250922-cp311-cp311-win_amd64.whl (418.3 kB view details)

Uploaded CPython 3.11Windows x86-64

grain_nightly-0.2.13.dev20250922-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (501.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250922-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (500.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250922-cp311-cp311-macosx_11_0_arm64.whl (429.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

grain_nightly-0.2.13.dev20250922-cp310-cp310-win_amd64.whl (416.6 kB view details)

Uploaded CPython 3.10Windows x86-64

grain_nightly-0.2.13.dev20250922-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (500.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

grain_nightly-0.2.13.dev20250922-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (500.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

grain_nightly-0.2.13.dev20250922-cp310-cp310-macosx_11_0_arm64.whl (428.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 69365b7179741ca551b104af9ee83b45d93b82ef8c525d6ffb6fb91e7fe4824f
MD5 de6a01da8561bfec963fb2d62cbb68e8
BLAKE2b-256 5033c66814859989ae97939c567c5c0e89f0c4ebcaa51151c767b3f985d0b1bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6784cf672fcfe78d3ecd73b02768bdf9f87f4f8110436c846d05f23f7da08243
MD5 0d3751e123d21c75f74b85f8272d62b2
BLAKE2b-256 5b2659a5a45532a99e9e2cb09d7dd0b2fd711cf06377773cd89ad7227448aa59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 9fe718366009158027c9802d218d5d78c477646d83052ac090c5bda7f9b541ac
MD5 b9b46c24b44c5c6cf6c7e2b1419554d8
BLAKE2b-256 73932f68f0b6e358756373b22d472749d698edab5ccb0d010fb835b4f62ef1a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2acccea19cc4f16cd9e388a856629612e9059ed4ea1a4b49d9abea00b21ac2d7
MD5 bfac1aa6e15aec7d6eaff7e644860dc7
BLAKE2b-256 5d1eabc9a64eef64f1c4e00e86228f8a2143322a348ee10d92125ad7263b2832

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 271138fa6984f86c02604b070c07f0b2725ce035ae76565e4ced962a037e6f04
MD5 a0ee91f2109fd22521e37da668c57a3a
BLAKE2b-256 44065011779deef28236580461b1fb78d8a0390779ff3b6ee4f7a23c428eb928

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 beffd6e204f2fe06b16e5204ec47673ee1b58d5e6e9d13d6b7fd34c6aecf7a3f
MD5 d48eb46ea36216d209510ab93a5c2a88
BLAKE2b-256 69f072e129bda593125d0aae26fc54ebf0ee8998d71c856171b37622f9a57204

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 06dc00d1258d84e9b3f220efce1666353e781d57ef938837450a51c602a1abc0
MD5 d3dbdc169fe06feea194b2e917b75aed
BLAKE2b-256 f564b77e5c6cbde80d9cf48225714a91fd581d7bb28b0b7df9f498134d4bf541

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9210b30a2ffbc761b0884ea90ddf554036d5fc996e4b1f192d71397d3516901f
MD5 d5dab4a0f17c25c25c6c091f8e7b49b8
BLAKE2b-256 b51ece7a0920276af1a8e90510e1023cea5f77caa6778245f54167aa7a539dc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ddf79f992c0e1717eff99d81d42ec89c928d4305312c86386a1e3a324340d79e
MD5 87091dd98882d0b05c55765476dabf3b
BLAKE2b-256 d5931143bde817beaf90e2326cc4d1a3cf2b06f3bf72f498dc5e458aed55d029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6266cbacbfdfd26801601bed3882c76f7e8d29708e375a2e1c8cdccbdcb2130e
MD5 9d015a4c62cd546c39fbd06351b0421d
BLAKE2b-256 1b27c9e3490811cea12da86900a75e0f2e1158405f77b830091728370bc07247

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 b3291f5e4c4a7e6dad3b9fa8457e22fb8b5b378a3592a59bfee580e960d409d0
MD5 de28ebe41730b0e56126d98e4befff95
BLAKE2b-256 b24b2fb6b28682812ea489ed760bc6a87ca538aba17cf218e4818200048b18fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b46a309a1d33a30d6a8acab5166e31244d198b204de067211312f79c8c42331
MD5 4758e1a3503b857afc8dedf7f32a40e9
BLAKE2b-256 09d34d1c82cc7d5e0b278d4c2181ab77c3ea12bc9f519d5642127f558a26c75b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f497f528620e14102eb0e062c15b83df90cef5ddd1d6e768a9e2118ac0a827c1
MD5 1c1445a0cc1ec559ad88d3650f1f3c03
BLAKE2b-256 37555e90efa32b3fa4690404e55705c998396d7b4aba969eb2b69f00c8efde9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 a0dca2fdc9871461cb23240eebd7d84c14637d22028ec7ff57ae2c03dd599304
MD5 96f37fc6f3e0bca6ef8437f4d1c18c86
BLAKE2b-256 dfc97ebcad780d0caa7ca20d69380e2a8838d338b181b49935d55e909e423120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 140fa06ae8223c837d1d398eaf0108810698d67fb5030c23a86687d534df5524
MD5 431e02a3994e8a685ca93cfb69cf6f03
BLAKE2b-256 d5906389c964340bdd4c3e83b6119ee3fa53be38b2d9d60d66f835aec1c3b517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain_nightly-0.2.13.dev20250922-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2fcac79dfb1724c5ebae98c16abb4ff5e742bf594e915b5bac7ac2b7bccfc0c0
MD5 f6f02e3b405c9b55cc8615d1d9e2b11d
BLAKE2b-256 124bd0d6870cf1d30d4dd492fa8bce1888f7d1c87ddd2053418d3656a1bbe537

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