litdata 0.2.75__tar.gz → 0.2.76__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. litdata-0.2.76/CODE_OF_CONDUCT.md +76 -0
  2. litdata-0.2.76/CONTRIBUTING.md +102 -0
  3. litdata-0.2.76/GOVERNANCE.md +38 -0
  4. {litdata-0.2.75 → litdata-0.2.76}/MANIFEST.in +2 -0
  5. {litdata-0.2.75/src/litdata.egg-info → litdata-0.2.76}/PKG-INFO +155 -6
  6. {litdata-0.2.75 → litdata-0.2.76}/README.md +152 -3
  7. {litdata-0.2.75 → litdata-0.2.76}/requirements.txt +1 -1
  8. {litdata-0.2.75 → litdata-0.2.76}/setup.py +1 -0
  9. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/__about__.py +1 -1
  10. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/__init__.py +6 -0
  11. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/data_processor.py +8 -0
  12. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/readers.py +2 -1
  13. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/utilities.py +10 -3
  14. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/__init__.py +2 -0
  15. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/cache.py +2 -2
  16. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/client.py +133 -29
  17. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/combined.py +1 -1
  18. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/config.py +4 -4
  19. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/dataloader.py +7 -3
  20. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/dataset.py +170 -5
  21. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/downloader.py +105 -15
  22. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/item_loader.py +1 -1
  23. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/parallel.py +10 -3
  24. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/reader.py +9 -2
  25. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/resolver.py +2 -0
  26. litdata-0.2.76/src/litdata/streaming/temporal.py +212 -0
  27. litdata-0.2.76/src/litdata/streaming/window.py +316 -0
  28. litdata-0.2.76/src/litdata/streaming/window_mmap.py +102 -0
  29. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/writer.py +29 -3
  30. litdata-0.2.76/src/litdata/utilities/_nfs_direct_io.c +107 -0
  31. litdata-0.2.76/src/litdata/utilities/affinity.py +207 -0
  32. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/base.py +3 -1
  33. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/dataset_utilities.py +16 -10
  34. litdata-0.2.76/src/litdata/utilities/direct_io.py +185 -0
  35. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/parquet.py +2 -2
  36. {litdata-0.2.75 → litdata-0.2.76/src/litdata.egg-info}/PKG-INFO +155 -6
  37. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/SOURCES.txt +8 -0
  38. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/requires.txt +2 -2
  39. litdata-0.2.75/CONTRIBUTING.md +0 -355
  40. {litdata-0.2.75 → litdata-0.2.76}/LICENSE +0 -0
  41. {litdata-0.2.75 → litdata-0.2.76}/setup.cfg +0 -0
  42. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/__main__.py +0 -0
  43. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/__init__.py +0 -0
  44. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/commands.py +0 -0
  45. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/handler/__init__.py +0 -0
  46. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/handler/cache.py +0 -0
  47. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/handler/optimize.py +0 -0
  48. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/cli/parser.py +0 -0
  49. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/constants.py +0 -0
  50. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/debugger.py +0 -0
  51. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/exceptions.py +0 -0
  52. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/helpers.py +0 -0
  53. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/imports.py +0 -0
  54. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/__init__.py +0 -0
  55. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/complete.py +0 -0
  56. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/functions.py +0 -0
  57. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/processing/media_folder.py +0 -0
  58. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/raw/__init__.py +0 -0
  59. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/raw/dataset.py +0 -0
  60. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/raw/indexer.py +0 -0
  61. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/raw/types.py +0 -0
  62. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/requirements.py +0 -0
  63. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/async_prefetch.py +0 -0
  64. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/collate.py +0 -0
  65. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/compression.py +0 -0
  66. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/dataset_update.py +0 -0
  67. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/elastic.py +0 -0
  68. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/framed_zstd.py +0 -0
  69. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/fs_provider.py +0 -0
  70. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/posix_fast.py +0 -0
  71. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/sampler.py +0 -0
  72. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/serializers.py +0 -0
  73. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/shuffle.py +0 -0
  74. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/streaming/timing.py +0 -0
  75. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/types.py +0 -0
  76. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/__init__.py +0 -0
  77. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/_pytree.py +0 -0
  78. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/breakpoint.py +0 -0
  79. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/broadcast.py +0 -0
  80. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/encryption.py +0 -0
  81. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/env.py +0 -0
  82. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/format.py +0 -0
  83. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/hf_dataset.py +0 -0
  84. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/hf_fs.py +0 -0
  85. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/keys_index.py +0 -0
  86. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/packing.py +0 -0
  87. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/shuffle.py +0 -0
  88. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/subsample.py +0 -0
  89. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/torch_utils.py +0 -0
  90. {litdata-0.2.75 → litdata-0.2.76}/src/litdata/utilities/train_test_split.py +0 -0
  91. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/dependency_links.txt +0 -0
  92. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/entry_points.txt +0 -0
  93. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/not-zip-safe +0 -0
  94. {litdata-0.2.75 → litdata-0.2.76}/src/litdata.egg-info/top_level.txt +0 -0
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socioeconomic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at community@lightning.ai. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ For answers to common questions about this code of conduct, see
74
+ https://www.contributor-covenant.org/faq
75
+
76
+ [homepage]: https://www.contributor-covenant.org
@@ -0,0 +1,102 @@
1
+ # Contributing to LitData
2
+
3
+ We welcome all contributions, whatever your level of experience — bug fixes, features, examples, and docs improvements are all appreciated.
4
+
5
+ By participating, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). New to open source? Start with [GitHub's guide to your first contribution](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
6
+
7
+ ## What we're looking for
8
+
9
+ - **Bug fixes** — especially streaming correctness, resumption, distributed sampling, and cloud storage backends.
10
+ - **Features** — optimize/map pipelines, item loaders, serializers, and new data formats.
11
+ - **Integrations and examples** — streaming a new dataset type or storage provider.
12
+ - **Docs** — clarifications, missing docstrings, better examples.
13
+ - **Performance** — throughput or memory regressions, ideally with a reproducible benchmark.
14
+
15
+ ## How to contribute
16
+
17
+ 1. **Open an issue** first, so we can align on scope. For bugs, include your setup, expected vs. actual behaviour, and a minimal reproduction. For features, explain the motivation with a use case.
18
+ 2. **Fork the repo** and create a branch off `main`. Name it `<type>/<issue-id>_<short-name>`, for example `bugfix/237_uneven-batches`. Types we use: `bugfix`, `feature`, `docs`, `tests`.
19
+ 3. **Write a test first** where you can: one that fails on `main` and passes with your change.
20
+ 4. **Open a pull request** against `main`, describing what changed and why, and linking the issue.
21
+
22
+ Looking for somewhere to start? Try a [good first issue](https://github.com/Lightning-AI/litdata/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) or [help wanted](https://github.com/Lightning-AI/litdata/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22), and comment so we can assign it to you. [PR #237](https://github.com/Lightning-AI/litdata/pull/237) is a good example to model yours on. And if you can't find the fix, a PR with just a failing test is still a valuable contribution — we can finish it together.
23
+
24
+ ## Development setup
25
+
26
+ We use [uv](https://docs.astral.sh/uv/getting-started/installation/) and `make`, the same as CI.
27
+
28
+ ```bash
29
+ # 1. clone your fork
30
+ git clone https://github.com/{YOUR_USERNAME}/litdata.git
31
+ cd litdata
32
+
33
+ # 2. create and activate an environment
34
+ # any Python version in `python_requires` (see setup.py) works
35
+ uv venv --python 3.12
36
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
37
+
38
+ # 3. install dependencies and pre-commit hooks
39
+ make setup
40
+ ```
41
+
42
+ That's it — you're ready to go! 🎉
43
+
44
+ If `make` is missing: `sudo apt-get install build-essential` on Debian-based systems, `brew install make` on macOS. On [Lightning Studio](https://lightning.ai/studios), skip step 2.
45
+
46
+ ## Running tests
47
+
48
+ Tests use [pytest](https://docs.pytest.org/en/stable/) and live in `tests/`, mirroring `src/litdata/`. Add yours to the file covering that area, or create one.
49
+
50
+ ```bash
51
+ pytest tests/ -v # everything
52
+ pytest tests/streaming/test_dataset.py -v # one file
53
+ pytest tests/streaming/test_dataset.py::test_streaming_dataset # one test
54
+ ```
55
+
56
+ Style is enforced by [ruff](https://docs.astral.sh/ruff/) via pre-commit. `make setup` installs the hooks, so they run automatically on every commit. To check everything before pushing:
57
+
58
+ ```bash
59
+ pre-commit run --all-files
60
+
61
+ # using uvx
62
+ uvx pre-commit run --all-files
63
+ ```
64
+
65
+ ## Guidelines
66
+
67
+ - Keep pull requests focused — one logical change per PR.
68
+ - Write tests for new functionality, and a regression test alongside any bug fix.
69
+ - Follow the existing code style (enforced via [ruff](https://docs.astral.sh/ruff/) and pre-commit).
70
+ - All code should be your own original work; third-party snippets must be attributed, and new dependencies kept at least as permissive as our [Apache-2.0 license](LICENSE).
71
+
72
+ ## Reviews and merging
73
+
74
+ Anyone in the community is welcome to review — you don't have to be a maintainer, and an extra pair of eyes always helps.
75
+
76
+ Not ready for review but want CI to run? Open a **draft PR**, and prefix the title with **\[blocked by #<number>\]** if it depends on another PR.
77
+
78
+ Merging needs green CI and approval from a [code owner](.github/CODEOWNERS) for the paths you touched. Reviews can take a few days; if your PR goes quiet for a week, feel free to ping. See [GOVERNANCE.md](GOVERNANCE.md) for how decisions get made.
79
+
80
+ ## Keeping your branch up to date
81
+
82
+ If `main` moves on while your PR is open, rebase rather than merge, so history stays linear. Point your fork at upstream once:
83
+
84
+ ```bash
85
+ git remote add upstream https://github.com/Lightning-AI/litdata.git
86
+ git remote -v # origin = your fork, upstream = Lightning-AI
87
+ ```
88
+
89
+ Then, whenever you need to catch up:
90
+
91
+ ```bash
92
+ git fetch --all --prune
93
+ git rebase upstream/main
94
+ # resolve any conflicts, following git's instructions
95
+ git push -f origin {BRANCH_NAME} # -f is needed after a rebase
96
+ ```
97
+
98
+ ## Getting help
99
+
100
+ Stuck? You don't have to figure it out alone — ask on [Discord](https://discord.com/invite/MWAEvnC5fU) for the quickest answer, [open an issue](https://github.com/Lightning-AI/litdata/issues) to report a bug, or browse the [documentation](https://lightning.ai/docs/litdata).
101
+
102
+ Thanks for helping make LitData better! 💜
@@ -0,0 +1,38 @@
1
+ # Governance
2
+
3
+ LitData is an open source project backed by [Lightning AI](https://lightning.ai/), released under the [Apache-2.0](LICENSE) license.
4
+
5
+ ## Roles and responsibilities
6
+
7
+ **Maintainers** review and merge contributions, triage issues, guide technical direction, and cut releases. The current maintainers are listed under [Maintainers](README.md#maintainers) in the README; ownership is scoped by path in [.github/CODEOWNERS](.github/CODEOWNERS).
8
+
9
+ **Contributors** are anyone contributing code, tests, docs, triage, or review. See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.
10
+
11
+ **Emeritus maintainers** are past maintainers, recorded under [Emeritus Maintainers](README.md#emeritus-maintainers) and not requested for review.
12
+
13
+ Maintainers are invited on the strength of sustained contribution, with the agreement of the current maintainers. A maintainer may step down, or be moved to emeritus status after a long period of inactivity, by a pull request updating the README roster and [.github/CODEOWNERS](.github/CODEOWNERS).
14
+
15
+ ## Decision making
16
+
17
+ Changes land through pull requests against `main`; direct pushes are not used. A pull request needs passing CI and approval from a maintainer who owns the affected paths. Larger changes — new public APIs, breaking changes, new dependencies, changes to the on-disk chunk format or index schema — should start as an issue. Maintainers work by consensus and resolve disagreements in the open.
18
+
19
+ ## Communication
20
+
21
+ GitHub issues and pull requests are the source of truth for decisions. Discussion also happens on [Discord](https://discord.com/invite/MWAEvnC5fU), but anything affecting the project is recorded on GitHub.
22
+
23
+ ## Releases
24
+
25
+ LitData follows `MAJOR.MINOR.PATCH` versioning, with the version in [src/litdata/\_\_about\_\_.py](src/litdata/__about__.py).
26
+
27
+ - **Cadence:** cut as needed rather than on a fixed calendar, once a meaningful set of fixes or features has landed on `main`. Regressions and security fixes ship as soon as they are ready.
28
+ - **Criteria:** `main` is green across the CI matrix, including tests, typing, packaging, documentation, simulator, and benchmark checks.
29
+ - **Process:** a maintainer bumps the version and publishes a GitHub Release, which builds and publishes the distributions to PyPI via trusted publishing.
30
+ - **Supported versions:** supported Python and dependency ranges are documented in the project configuration and tested in CI. LitData is validated against the latest two PyTorch minor releases; support for a PyTorch or Python version is dropped only in a minor release and announced in the release notes.
31
+
32
+ ## Code of Conduct
33
+
34
+ All participants follow the [Code of Conduct](CODE_OF_CONDUCT.md). Reports go to community@lightning.ai.
35
+
36
+ ## Changing this document
37
+
38
+ By pull request, with approval from at least two maintainers.
@@ -43,3 +43,5 @@ prune notebook*
43
43
  prune temp*
44
44
  prune test*
45
45
  prune benchmark*
46
+
47
+ include src/litdata/utilities/_nfs_direct_io.c
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: litdata
3
- Version: 0.2.75
3
+ Version: 0.2.76
4
4
  Summary: The Deep Learning framework to train, deploy, and ship AI products Lightning fast.
5
5
  Home-page: https://github.com/Lightning-AI/litdata
6
6
  Download-URL: https://github.com/Lightning-AI/litdata
@@ -27,7 +27,7 @@ Classifier: Programming Language :: Python :: 3.14
27
27
  Requires-Python: >=3.10
28
28
  Description-Content-Type: text/markdown
29
29
  License-File: LICENSE
30
- Requires-Dist: torch
30
+ Requires-Dist: torch>=2.4.0
31
31
  Requires-Dist: torchvision
32
32
  Requires-Dist: lightning-utilities
33
33
  Requires-Dist: filelock
@@ -44,7 +44,7 @@ Requires-Dist: lightning-sdk==2026.2.6; extra == "extras"
44
44
  Requires-Dist: orjson; extra == "extras"
45
45
  Requires-Dist: pillow; extra == "extras"
46
46
  Requires-Dist: polars; extra == "extras"
47
- Requires-Dist: pyarrow<25.0.0; extra == "extras"
47
+ Requires-Dist: pyarrow; extra == "extras"
48
48
  Requires-Dist: tqdm; extra == "extras"
49
49
  Requires-Dist: uvloop; sys_platform != "win32" and extra == "extras"
50
50
  Requires-Dist: viztracer; extra == "extras"
@@ -109,6 +109,7 @@ Dynamic: summary
109
109
  <p align="center">
110
110
  <a href="https://lightning.ai/">Lightning AI</a> •
111
111
  <a href="#quick-start">Quick start</a> •
112
+ <a href="#litdata-vs-torchdata">vs torchdata</a> •
112
113
  <a href="#speed-up-model-training">Optimize data</a> •
113
114
  <a href="#transform-datasets">Transform data</a> •
114
115
  <a href="#modality">Modality</a> •
@@ -140,6 +141,24 @@ LitData provides tools to preprocess and optimize datasets into a format that st
140
141
 
141
142
  &nbsp;
142
143
 
144
+ ## LitData vs torchdata <a id="litdata-vs-torchdata"></a>
145
+
146
+ Different layers, not competitors: **LitData is a streaming layer with its own on-disk format, plus a no-conversion path for files you already have; [torchdata](https://github.com/meta-pytorch/data) is a toolkit of dataloading primitives with no format of its own.**
147
+
148
+ | | LitData | torchdata |
149
+ |--|--|--|
150
+ | Storage format | Own chunked binary format via [`optimize()`](#option-2-optimize-for-maximum-performance-); also reads Parquet, MDS, [raw files](#stream-raw) | None. Bring your own |
151
+ | Remote data | Chunk-level streaming from S3, GCS, Azure, R2, HF Hub. Async batched downloads, prefetch, local cache, retries | Per-file reads (`FileLister` / `FileReader`, fsspec + smart_open). No chunk cache or prefetch pipeline |
152
+ | Main API | `StreamingDataset` / `StreamingDataLoader`, `CombinedStreamingDataset` | `torchdata.nodes` iterators you chain yourself, `StatefulDataLoader` |
153
+ | Mid-epoch resume | `StreamingDataLoader.state_dict()` / `load_state_dict()` | `StatefulDataLoader.state_dict()` / `load_state_dict()` |
154
+ | Transforms | [`map()`](#transform-datasets) / `optimize()`. Preprocessing jobs that run before training and write a new dataset, distributed across machines | `ParallelMapper`. Transforms samples in the live pipeline, re-run every epoch |
155
+
156
+ **Rule of thumb:** reach for **LitData** in most cases. It handles the streaming, caching, shuffling and resume for you. Reach for **torchdata** when you only want bare-bones primitives and are happy to build the loading pipeline yourself.
157
+
158
+ The two compose rather than compete: a `StreamingDataset` is an `IterableDataset`, so `torchdata.nodes.IterableWrapper` can pull straight from it.
159
+
160
+ &nbsp;
161
+
143
162
  # Looking for GPUs?
144
163
  Over 340,000 developers use [Lightning Cloud](https://lightning.ai/?utm_source=litdata&utm_medium=referral&utm_campaign=litdata) - purpose-built for PyTorch and PyTorch Lightning.
145
164
  - [GPUs](https://lightning.ai/pricing?utm_source=litdata&utm_medium=referral&utm_campaign=litdata) from $0.19.
@@ -156,6 +175,11 @@ First, install LitData:
156
175
  pip install litdata
157
176
  ```
158
177
 
178
+ <!-- torch-support -->
179
+ LitData supports the two most recent PyTorch minor releases, currently **2.14** and **2.13**; and
180
+ requires **PyTorch 2.4 or newer**. CI exercises all three. Those versions are declared in
181
+ [`.github/torch-support.json`](.github/torch-support.json), which drives the CI matrix.
182
+
159
183
  Choose your workflow:
160
184
 
161
185
  🚀 [Speed up model training](#speed-up-model-training)
@@ -487,6 +511,12 @@ Wrap each file so a caption is not treated as a path: Text(path=...), Image(path
487
511
 
488
512
  Examples (path on disk → optimize → batch): [examples/modality](examples/modality).
489
513
 
514
+ For temporal arrays, use `optimize(..., item_loader=TemporalArrayLoader(field_groups=[["clock", "valid"]]))`
515
+ and `StreamingDataset(..., item_loader=TemporalArrayLoader()).read_window(index, start=7, frames=64)`.
516
+ LitData owns field grouping, window offsets, range reads and decoding; the application keeps its sampling policy.
517
+ When in-place mmap is disabled (`LITDATA_POSIX_FAST=0`), local window reads request only the selected byte ranges without Python file buffering. Operating-system caching still applies; this setting does not enable direct I/O.
518
+ See the [built-in window example](examples/temporal_arrays) for a small training adapter and request-count tradeoffs.
519
+
490
520
  ----
491
521
 
492
522
  # Hugging Face Datasets 🤗 <a id="huggingface-datasets"></a><a id="stream-hf"></a>
@@ -2558,9 +2588,9 @@ optimize(
2558
2588
  )
2559
2589
  ```
2560
2590
 
2561
- ### Lightning Studio `/teamspace/...` paths (direct bucket I/O)
2591
+ ### Lightning Studio `/teamspace/...` paths
2562
2592
 
2563
- In Lightning Studios, data connections appear under `/teamspace/...`. **Prefer these paths in LitData** — optimize/map uploads and StreamingDataset downloads use the **backing object store URL** (and temporary credentials when needed), which is much faster than reading every file through the FUSE mount.
2593
+ In Lightning Studios, data connections appear under `/teamspace/...`. **Prefer these paths in LitData**: object-store connections use their backing URL and temporary credentials when needed. Mounted Lightning Storage filesystems are read and written in place, without redirecting the dataset to a download cache.
2564
2594
 
2565
2595
  | Path prefix | What LitData does |
2566
2596
  |-------------|-------------------|
@@ -2570,7 +2600,7 @@ In Lightning Studios, data connections appear under `/teamspace/...`. **Prefer t
2570
2600
  | `/teamspace/gcs_connections/<name>/...` | Direct GCS |
2571
2601
  | `/teamspace/s3_folders/<name>/...` | S3 folder connection |
2572
2602
  | `/teamspace/gcs_folders/<name>/...` | GCS folder connection |
2573
- | `/teamspace/lightning_storage/<name>/...` | Lightning-managed object storage (R2-style) |
2603
+ | `/teamspace/lightning_storage/<name>/...` | Direct R2 for object-store connections; in-place file access for mounted filesystems |
2574
2604
  | `/teamspace/datasets/...` | Teamspace datasets mount → project datasets bucket |
2575
2605
 
2576
2606
  ```python
@@ -2608,6 +2638,52 @@ if __name__ == "__main__":
2608
2638
  &nbsp;
2609
2639
 
2610
2640
 
2641
+ ### GPU-local CPU and NUMA memory affinity
2642
+
2643
+ On Linux, opt in to placing each training rank and its DataLoader workers on the CPUs and RAM local to its GPU:
2644
+
2645
+ ```python
2646
+ import os
2647
+
2648
+ from litdata import StreamingDataLoader, StreamingDataset
2649
+ from litdata import get_gpu_affinity
2650
+
2651
+
2652
+ def main():
2653
+ local_rank = int(os.environ.get("LOCAL_RANK", "0"))
2654
+ affinity = get_gpu_affinity(local_rank, bind_memory=True)
2655
+ affinity.bind()
2656
+
2657
+ dataset = StreamingDataset("/path/to/optimized/data")
2658
+ loader = StreamingDataLoader(
2659
+ dataset,
2660
+ batch_size=32,
2661
+ num_workers=4,
2662
+ worker_init_fn=affinity,
2663
+ multiprocessing_context="spawn",
2664
+ persistent_workers=True,
2665
+ pin_memory=True,
2666
+ )
2667
+ for batch in loader:
2668
+ train_step(batch) # Your training step.
2669
+
2670
+
2671
+ if __name__ == "__main__":
2672
+ main()
2673
+ ```
2674
+
2675
+ Launch this example with `torchrun --nproc_per_node=8 train.py`, adjusting the GPU count. `get_gpu_affinity` uses PyTorch's **logical CUDA device** and its PCI NUMA topology, so CUDA visibility and device reordering are respected. It initializes CUDA in the rank process. The returned `NumaAffinity` object contains only the node, CPU IDs and memory-binding option; it can be pickled and applied in workers without querying CUDA. It also works with `torch.utils.data.DataLoader`.
2676
+
2677
+ - Bind the rank before creating its reader threads, model and loader. Also pass the plan as `worker_init_fn`, particularly with spawned workers. To run an existing worker initializer, call `affinity(worker_id)` first in a top-level picklable callable, then run the existing initializer.
2678
+ - CPU selection intersects the GPU-local CPUs with the calling thread's current affinity mask. An empty intersection or unknown topology raises an error; it does not select a remote node. Multiple GPUs can share one NUMA node; these helpers do not reserve or divide CPUs between GPUs.
2679
+ - `bind_memory=True` uses `libnuma.so.1` (the `libnuma1` system package) to request and verify `MPOL_BIND`. CPU-only placement, `bind_memory=False`, does not require libnuma. Kernel or container restrictions on memory binding produce an error.
2680
+ - Binding affects the **calling thread and future child threads/processes**. Existing sibling threads retain their policies, and pages already allocated are not migrated. Call the helper early; `pin_memory=True` alone does not select a NUMA node. A strict binding limits allocations to that node's available memory.
2681
+ - This is optional and does not change existing loaders. Locality does not guarantee a throughput gain; compare the same workload with and without memory binding.
2682
+
2683
+ If the GPU topology is known already, use `get_numa_affinity(numa_node, bind_memory=True)` to build a plan without initializing CUDA. This also supports older PyTorch builds that do not expose PCI identifiers in CUDA device properties. GPU discovery requires those properties (available in PyTorch 2.8). Create plans before narrowing a parent process's CPU mask; a child resolving a different GPU after inheriting that narrowed mask will raise rather than silently expand it. Apply a previously resolved plan to that child instead.
2684
+
2685
+ See the [Linux NUMA policy documentation](https://docs.kernel.org/admin-guide/mm/numa_memory_policy.html) for policy inheritance and allocation semantics.
2686
+
2611
2687
  ## Features for transforming datasets
2612
2688
 
2613
2689
  <details>
@@ -2989,6 +3065,8 @@ Papers that train or stream with LitData (`optimize` / `StreamingDataset`). Scho
2989
3065
  * Thomas Chaton ([tchaton](https://github.com/tchaton))
2990
3066
  * Bhimraj Yadav ([bhimrazy](https://github.com/bhimrazy))
2991
3067
  * Deependu ([deependujha](https://github.com/deependujha))
3068
+ * Peyton Gardipee ([pwgardipee](https://github.com/pwgardipee))
3069
+ * David Edey ([dhedey](https://github.com/dhedey))
2992
3070
 
2993
3071
 
2994
3072
  ## Emeritus Maintainers
@@ -3003,3 +3081,74 @@ Papers that train or stream with LitData (`optimize` / `StreamingDataset`). Scho
3003
3081
  * Adrian Wälchli ([awaelchli](https://github.com/awaelchli))
3004
3082
 
3005
3083
  </details>
3084
+
3085
+ ### Direct reads on Linux NFS
3086
+
3087
+ For a working set larger than client RAM, direct I/O can avoid filling the client's
3088
+ page cache with streamed payloads. It is an opt-in performance option: benchmark
3089
+ it with your access pattern. Server-side caches still apply. This support is
3090
+ currently limited to Linux x86_64/aarch64 and regular files on NFS; other
3091
+ filesystems raise an error rather than silently using buffered reads.
3092
+
3093
+ For LitData window reads, no compiler or preload library is needed:
3094
+
3095
+ ```python
3096
+ from litdata import StreamingDataset, TemporalArrayLoader
3097
+
3098
+ windows = StreamingDataset(
3099
+ "/mnt/dataset",
3100
+ item_loader=TemporalArrayLoader(),
3101
+ window_direct_io=True,
3102
+ )
3103
+ sample = windows.read_window(0, start=128, frames=64)
3104
+ ```
3105
+
3106
+ `window_direct_io=True` supports `read_window` and `aread_window` on uncompressed,
3107
+ unencrypted datasets. It disables the window mmap path and ordinary dataset
3108
+ indexing/iteration. Keep sampling in your application and call window reads from
3109
+ your DataLoader workers. Defaults remain unchanged.
3110
+
3111
+ Custom Python loaders can use the same reader without converting to LitData:
3112
+
3113
+ ```python
3114
+ from litdata.utilities.direct_io import open_nfs_direct
3115
+
3116
+ with open_nfs_direct("/mnt/dataset/payload.bin") as handle:
3117
+ handle.seek(123)
3118
+ data = handle.read(4096)
3119
+ ```
3120
+
3121
+ This returns an unbuffered, read-only `FileIO` handle. Open it inside each worker,
3122
+ close it normally, and handle short reads when an exact byte count is required.
3123
+ Linux NFS permits unaligned byte ranges; this helper does not generalize that
3124
+ assumption to local disks. Do not mmap the same payload or modify files during reads.
3125
+
3126
+ #### Experimental launcher for Lance and other native readers
3127
+
3128
+ A native reader opens its own files, so the Python opener above cannot change its
3129
+ behavior. The launcher below builds a small C preload helper and starts your
3130
+ command with it. A system C compiler (`cc`) and mounted `/proc` are required.
3131
+ Only read-only regular files under the resolved root with the selected suffixes
3132
+ receive `O_DIRECT`. Metadata and writes retain their existing behavior.
3133
+
3134
+ ```bash
3135
+ python -m litdata.utilities.direct_io \
3136
+ --root /mnt/dataset --suffix .lance -- \
3137
+ python train.py --data /mnt/dataset
3138
+ ```
3139
+
3140
+ Use `--suffix .bin` for a native reader of binary payload files, or repeat
3141
+ `--suffix` to select several types. Run from a foreground terminal and wait for
3142
+ all workers to finish. The temporary compiled helper is removed when the command
3143
+ exits. A Python application can use `nfs_direct_io_environment(root,
3144
+ suffixes=[".lance"])` as a context manager and pass its returned environment to
3145
+ `subprocess.run(..., env=env, check=True)`.
3146
+
3147
+ This is experimental integration support, not an upstream Lance configuration
3148
+ option. It supports dynamically linked libc `open`/`openat` readers, including the
3149
+ tested Lance `file+uring` path. It does not enable io_uring by itself, change
3150
+ already-open files, or affect the current Python process. Readers using mmap,
3151
+ static binaries, raw open syscalls, or io_uring open operations are unsupported.
3152
+ Do not use it for applications that detach workers after their parent exits.
3153
+ Use an immutable dataset and verify the reader's actual direct-I/O path before
3154
+ interpreting cache-bypass or throughput results. No speedup is guaranteed.