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

Uploaded CPython 3.14Windows x86-64

grain-0.2.17-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (605.4 kB view details)

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

grain-0.2.17-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (606.2 kB view details)

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

grain-0.2.17-cp314-cp314-macosx_11_0_arm64.whl (549.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

grain-0.2.17-cp313-cp313-win_amd64.whl (535.1 kB view details)

Uploaded CPython 3.13Windows x86-64

grain-0.2.17-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (605.5 kB view details)

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

grain-0.2.17-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (606.2 kB view details)

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

grain-0.2.17-cp313-cp313-macosx_11_0_arm64.whl (549.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain-0.2.17-cp312-cp312-win_amd64.whl (535.0 kB view details)

Uploaded CPython 3.12Windows x86-64

grain-0.2.17-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (605.4 kB view details)

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

grain-0.2.17-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (606.1 kB view details)

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

grain-0.2.17-cp312-cp312-macosx_11_0_arm64.whl (549.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain-0.2.17-cp311-cp311-win_amd64.whl (534.8 kB view details)

Uploaded CPython 3.11Windows x86-64

grain-0.2.17-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (606.8 kB view details)

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

grain-0.2.17-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (607.9 kB view details)

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

grain-0.2.17-cp311-cp311-macosx_11_0_arm64.whl (551.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: grain-0.2.17-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 543.0 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.17-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1411dcc38a91a7fac3b9d57559d05c7e5b94ab1421cabe8fd92cccc4714bc0a0
MD5 a7df550f417860c3f982318f4b6306c9
BLAKE2b-256 87ea928ad296c0617944e69f0180eabdafe4a4f4b76cfe33a7ba3bc3c5fcedf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e74053ac0a810afef3166b4f70721eb0af2bc1f4992574b6d693473a7d7d590
MD5 13730601749697e3d6a87cf5477beb11
BLAKE2b-256 4577995f6ae16bf31569314e89fb54af1d7260c33db97ed4a85eb4613839c4ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1692c94d03a411d2bb95036f0e3474052cd291c6fcc538cd2e3c7e79137942f4
MD5 4107cf080108dbf5541ffdac4865ad6e
BLAKE2b-256 4a16d134a74ea4f322a1c7fd007735a81de74d18c8a75b8c4647e00fb63569c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7a8fa732143ad3bf7666d5e2aa2ab434e55b220d2f43894f05fb556f7a6a98f
MD5 dd557314de810e8346b10beb4b02ce96
BLAKE2b-256 701dece18488373b0da592d4260ba79d9aae9de79d4160f71512795b23349a04

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.17-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 535.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.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d46374d9bc3737f82caadcff74edd258e8608c4709c2022055ffa0711162c0c1
MD5 a73307328adf568ca93e6b9f46c6f21a
BLAKE2b-256 3e28f84ce29e8b236a2fb008edfd633e3f3da9ab467f462e4187528972280dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 977e95e0f712ecff00c455e39e253592a4f2169ba1e76e586525bc9e5afccb69
MD5 2c97451e209c3aafa17db6996524b2e3
BLAKE2b-256 04db1b320909c73107e03d123069648bc273cf6ea7b3b2523f1d12807620e271

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e325f704846ba77e5a778994b222fe85f20ad1902fdf86d1aab2f4ad244f52e2
MD5 1bd275a2040a7dc933e79feee4e03f85
BLAKE2b-256 c0eb650a46974a1e3b9dd70e318feef0a06220677a41235ff55c6e4685ed4b2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b940c2ef3f7d718864303d1691526ec177be129247d25d9eb4f2631ac3297733
MD5 60b97f3ce3c42d020ee11f80432393db
BLAKE2b-256 ca086956081e847b8f8b12e7ea534dbb61a825b61672c3f66c328dff404d7a2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.17-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 535.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.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eac2625e37787adcc81f8dbb7f2c6b031430aa70e0c91ae4a90d4cfcfa9a9daa
MD5 37155a43f43e09d47dedff7eed930974
BLAKE2b-256 247ed4a18d60c0fde33657e9fc8a44918af7733cd64f1a5cb1ecebb883097b5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b0e47b309a0390c55b6df9661ca3471eb449a1f97c3555ab6cd7c25f08b250bf
MD5 e113cd63ea11392c56354e06c1f2756f
BLAKE2b-256 5114a3c176728d015adb68e3248a20c61def8bb4a0e2b2cb258cf7644f9e450b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 077cfdafb8be3db9a3e4191b4a20fa3e64929d5d7ea33fccb02e8db8dd7e75bb
MD5 d7fad8f49843a0d5ab268ccdb61473e9
BLAKE2b-256 70fdb63e383abf1ba1c539378ab844f006916e5d31131f9b7cb5004c9c31a9b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9b82a13e7ad0af71a703decb6ef231965b0edba372a57a3f7421e3b50a1877a
MD5 b62bcf19477abba0b0e02387b1f2607e
BLAKE2b-256 718ee209e267dd3ddc513f083d734ed25532d2b6276177750d714dae89223178

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.17-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 534.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.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5a47358a600c77448a064319142bb33cc3221c7a8dc6b28ecaa2fc9c8c5130a8
MD5 45bbfa727f8d78c02e41efb4e6c6d7a5
BLAKE2b-256 bd49c7d91db88023a29af54d8962ca96745a0c380e5e0b0df8532fb0ba5d047d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 13b0e6e96939779e49ce944d5a09ca9370540335f09ca5dd31830c08c28a35be
MD5 6b66b6bd3ac64470f7da259658887a94
BLAKE2b-256 f5a81881d3a2bf769b6b4808f06ff6babeeca0572f1f8ba1feb64cdb43e2968d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 da0aab889b0d430c756f59dfed404a1e2093a916ae72158966660c1b6dc89f44
MD5 2ee11f785450d50231629967241f5e72
BLAKE2b-256 55bf0aa949a396137e5c48ea061ebb3a56cae447b3f6e4d76951c979b04318f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b59467ad481f4665a972e1224d7ab0f80c449202c91b17272eeb1e831f295d5a
MD5 33b533bf0578f08d815c32f5a392e327
BLAKE2b-256 692c662b1fa43c5b31de49201dc2935cd73f765490a6c3e249f8c3463cb914fe

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