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

Uploaded CPython 3.14Windows x86-64

grain-0.2.18-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (610.2 kB view details)

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

grain-0.2.18-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (610.9 kB view details)

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

grain-0.2.18-cp314-cp314-macosx_11_0_arm64.whl (554.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

grain-0.2.18-cp313-cp313-win_amd64.whl (539.9 kB view details)

Uploaded CPython 3.13Windows x86-64

grain-0.2.18-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (610.2 kB view details)

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

grain-0.2.18-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (610.9 kB view details)

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

grain-0.2.18-cp313-cp313-macosx_11_0_arm64.whl (554.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

grain-0.2.18-cp312-cp312-win_amd64.whl (539.8 kB view details)

Uploaded CPython 3.12Windows x86-64

grain-0.2.18-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (610.2 kB view details)

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

grain-0.2.18-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (610.9 kB view details)

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

grain-0.2.18-cp312-cp312-macosx_11_0_arm64.whl (554.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

grain-0.2.18-cp311-cp311-win_amd64.whl (539.6 kB view details)

Uploaded CPython 3.11Windows x86-64

grain-0.2.18-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (611.6 kB view details)

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

grain-0.2.18-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (612.6 kB view details)

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

grain-0.2.18-cp311-cp311-macosx_11_0_arm64.whl (556.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: grain-0.2.18-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 547.8 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.18-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 fe83461d55e81c9c9cdba3d9d9ed0185db7b41cddb8e28223aa495ca3516877c
MD5 cd999efec0c1fa6fc7964e65fffc3f3b
BLAKE2b-256 a2c8d3f559b3691559054d57779ce9e9dbb832c7631b622e94c8c092ce26ca18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc7204490aff21620fbdbd69e088991a4ae1ebc31586456191c11f9f61a8c0e6
MD5 e7434876746722810a2198aa107999bf
BLAKE2b-256 b760b257f1173a6c71c67a1de81798427a7e73ceb71cd6573ccccf7f528018f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 09bef4e8290d06e79cfddc71e777d0b5f60316e5a43af61f8a3d0e6a2d9feccc
MD5 b5bc84173e95695f86809ffd464eab0d
BLAKE2b-256 0f3107c861e8b0a782d2b17b3e8a7b9191420d30d4a9ce86a9882502d4d883eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5986e756a0803012a74af4d34a506ed2877f6a86b8d1164227e8a67e09af1688
MD5 403d4e87f8435ff431377614265eb8e9
BLAKE2b-256 3cde14532d47c14bcfaeb79878621ea4f28863df60ec1ce29f43a9781a1a2167

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.18-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 539.9 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.18-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8d74e3f33403146fb9da0b101d7d18148e3979f5adc8d625237524cc144c0d24
MD5 57f64d64f55a06023b6c01ed39acfdcc
BLAKE2b-256 d4edd491cd9e6406d4eca43443939c6b303f8cd66386f861988813ed92038e01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61290a4af38fbddac41d6da1d19129df498dece53c3de4cc02e7ec557a0b0024
MD5 b15b879055425d88e14d95ecff59505f
BLAKE2b-256 9bf30d3269dd6796c187f808708b381f6d85a62e5022f45f00c938a7f3a605f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 229683c7714c3275cc4fee6cbc7356d47769eeaa286fbdc6af7a9542dcb468e5
MD5 ccb6e63b1ee635b50fff2981d9ff8a30
BLAKE2b-256 60d5590925b5fdf33218dde9f72322b88b65f4043c6a6a06cd00520465ac6915

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bec1c551574d3a1885ea0d1481586b4c2490a1332120bf626b459e2f9a6f1d06
MD5 c7e0cf04c54e5b715ad3a94000a935cf
BLAKE2b-256 a23d6ad2033ae65145bcef635741c0d351bfe18a6a241b803766490a432551ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.18-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 539.8 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.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c8a29696d98b2e84d8531df211006b2187475af7cebc45408023da6aa3ac1494
MD5 901c1d562d051d82ec9bcd841e404563
BLAKE2b-256 ee4b7ec021e2385094ab31f6e6dad3e6f5bb2251dff5c3543934c347ba7ada3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ecd87427b4050b695f9b9b5a41d8058208586d3f90a2e56f14a64f920aa47f8
MD5 9cb1c975b65289831b2f0e1943abc74e
BLAKE2b-256 5686237d99cc246f87536ca3f3764fe94e2e364dababfe382ad227f3153079de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1eb8f8424d3844944d1c37248b0430a5598b21f7ec5141119e0a70069edbd943
MD5 69415c14f1066ced1b2228d76eb858d4
BLAKE2b-256 c56013bf95936145419a4673f33262d239477e1dc7da30d1a576945e2cba84af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bcff4c0ec71cee0b8c26076e3b60d83897cd7586b8f182291969743fd79a7b9
MD5 ffeb4144ec2a66c2497f5f641b6e99e3
BLAKE2b-256 1f2059fb32fd6aadc40e0dbde586a62903646ad778413c78280ea8d1e18e73de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grain-0.2.18-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 539.6 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.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c16f4001983bee52a5a08e43569f46343815697d12da344ba6509af898fbca79
MD5 f69a1d6894bd9838b3d2410dfeac40ed
BLAKE2b-256 26713be5abc17985d678b08e9d2258248c70e9dfe41cdf374584227033c294b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08a80a029f8b9c84af9424540d91cf8e4e91fe092e0fb7e0bb460dcf0042f659
MD5 24ccefdbc44036a27f9d6ec99f8fb28c
BLAKE2b-256 453b1d52db9abf0b28344a209a6f351a68b4bdf62e4fef0f6a11ea91a0e4520d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cf9b9cfc59180b549c74307fd2ef5bc6f545ab78538b7661a5cfad71177d8418
MD5 81cfe6bcc46ac6b52e7cac52d3943ac8
BLAKE2b-256 d6a8c6a447fbf8d381bee37bf0b6e93fb86fe4dd30b8154ee912797308f24cba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grain-0.2.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dda2c25d2590e8aae180d58a92525945b31f71e59637a8fe37c2d1e4e502beb5
MD5 18e7e4ef3d85e0f4a930dac2d08bbb09
BLAKE2b-256 55928cf5d07cac2a24c0670f9a7e64f1cac1288c183221f516be3bcae7d0d1e3

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