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

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-0.2.15-cp314-cp314-win_amd64.whl (451.3 kB view details)

Uploaded CPython 3.14Windows x86-64

grain-0.2.15-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (504.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

grain-0.2.15-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (503.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

grain-0.2.15-cp314-cp314-macosx_11_0_arm64.whl (453.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

grain-0.2.15-cp313-cp313-win_amd64.whl (445.1 kB view details)

Uploaded CPython 3.13Windows x86-64

grain-0.2.15-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (504.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

grain-0.2.15-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (503.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

grain-0.2.15-cp313-cp313-macosx_11_0_arm64.whl (453.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain-0.2.15-cp312-cp312-win_amd64.whl (445.0 kB view details)

Uploaded CPython 3.12Windows x86-64

grain-0.2.15-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (504.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

grain-0.2.15-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (503.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

grain-0.2.15-cp312-cp312-macosx_11_0_arm64.whl (453.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain-0.2.15-cp311-cp311-win_amd64.whl (444.8 kB view details)

Uploaded CPython 3.11Windows x86-64

grain-0.2.15-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (506.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

grain-0.2.15-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (505.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

grain-0.2.15-cp311-cp311-macosx_11_0_arm64.whl (456.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file grain-0.2.15-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: grain-0.2.15-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 451.3 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grain-0.2.15-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d57493fa4361316755cb0564f87e62d1da1dedae4eed53acf179ec029668dee5
MD5 e7ffda5266e0d00491f8bfb553cf1098
BLAKE2b-256 019f79da919a231f525145c6038d4e8a9200caef0f6c93e0e0239626f00759ae

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e1a5e20ffc29391c48b5d8f818742f4ecce957fe59ccff971c139721d31a0bf4
MD5 095018d17a81619468b8e286b3e417e2
BLAKE2b-256 62c92708bddbd4ee834c1da87211dce06b47133ca222e2b3355104f1e22d755f

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fedbb410486890c6e410c8d78934097b2755aa2363fbd6137b920ea5be104530
MD5 2f848874660766e58ec9464a61fbe142
BLAKE2b-256 1ce1f9b2b6a2fd9094a43a8b4a10092a464c18eef949c20b23fd31f266443aaf

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36e1413c275741712918e528f3f65ca254ce51d60160a2b9558c020147f38e98
MD5 dde443c8c7c0f48b16df23b4587b6373
BLAKE2b-256 087c674cd938b010c776bb2695bbca4a24e2db8e25c86edf0c113a637ef1834d

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: grain-0.2.15-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 445.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grain-0.2.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9d3cc6edfa4d0de341de0d03ba4a8612d94639bed97fe63af3951db8305c96c0
MD5 154e3726a47a6ee2da1496299bdf69c8
BLAKE2b-256 87e7334f97d5a6a65470b18256dfc64ae62416c0404b028186844bc7adc43508

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae2635e3bd18b77a7add7152ee91b22aba553fa44a066aefa009d1b923ade4f2
MD5 2ad4f3b52fc286f8350053ffaa60eb11
BLAKE2b-256 84f9376c47f9ebbe2be10605f4860e254a1633aed90405bcc25a089b787abce9

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4766dc1355448cf7b3bdd3cc4f4639bc3433c66c5502954380b9a8f4c2b3fc94
MD5 74810624fd012c03f75cac56dc233e69
BLAKE2b-256 498f2f1dbcf35703bef636f39e77230a53b704576978a6aab66047015abd31d3

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df0c4af1442f71effc80a5b44bb33fe5aabb7b3d82d5a3ac035ae40431935c77
MD5 538f93c2df8cb189faf86efa54c92742
BLAKE2b-256 58353a342a358e3a2bb8327bdc3fa4f50999928809f067fda428280e4f9e7ec0

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: grain-0.2.15-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 445.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grain-0.2.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cc58394bdddd5db1b1e1e2878899a1e78014f60046ead82415011eca36475287
MD5 dfad7b473d82d54646bbaa5fb805357c
BLAKE2b-256 e17064e158aa8069a04f04cb39921cf1ec74c996e2b509a27c41a11c8d181ebb

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fecc1553e539b946ed7f3508261f98309d07f899c06af1954186cf7d6a4613b2
MD5 af8710d7e74d217fe972a7f4774ee431
BLAKE2b-256 ab8f6ce73a60e25b57dc767a27685032bd28f50f3ea9e462a1b513f214dc1f3d

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9bbf2c57a92fae5d883e04bda35d373202f026cbd9952b9bdd831bda2c60ddd7
MD5 a284710283fcc5c109a1d22c0176ed15
BLAKE2b-256 b123b8d9c905d45d3802f7c5ad7e5a435820c2b5dfdfcebfbdd288e0647c72f5

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 149b195ebd2a2e06e00019af5e83d7d6fef18b6149471ba0baaf6bdfac1a0558
MD5 7ef08bcab442a29fe870877f6c5e3f5a
BLAKE2b-256 8f303467942b46ac3c83191ad235dc6fc89ab21e9e61c1080396d0c0eb31d1f3

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: grain-0.2.15-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 444.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grain-0.2.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7e8d7114f079cb3cfa9953e699cb44a44b179e9fb2ca4f61e8b7ac8ca90c33ce
MD5 b646d5731409c9459a3c00df9ab2df29
BLAKE2b-256 c8741ce374a211b7f9a989a29303d6be973579297baf9bd34820072234e44f51

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fcac68693f539f5421560250fe906c62b00daeb58a28a56ac7b8d9dad2ba7483
MD5 2c4618277f3c68e311753ad5d208b50b
BLAKE2b-256 add3c837702f14e03235cfb4a48186fca966dda5d9a8d8b149bad210a5273137

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 60f5ded548e58251af4a7429779c472cdb5ab716a448c32e500e6eb79957c5e9
MD5 bc394811533eae73d873ac44e6d5efb7
BLAKE2b-256 b549fbeba469025a82872fd426d95304409351621db94c31175e4f8fc47d37d5

See more details on using hashes here.

File details

Details for the file grain-0.2.15-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for grain-0.2.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63b90d0719a97c25a8b30057e224436dfaf3ba975e5baadaf8b3417235a09631
MD5 75ebb161463f44cac8bc343234305820
BLAKE2b-256 2a66045ed6f44ec8bb1fff6070c9ea6dfc05812ed14d1530b2005b1dbe4526ca

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