litdata 0.2.74__tar.gz → 0.2.75__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 (85) hide show
  1. {litdata-0.2.74/src/litdata.egg-info → litdata-0.2.75}/PKG-INFO +1 -1
  2. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/__about__.py +1 -1
  3. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/dataset.py +5 -5
  4. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/item_loader.py +35 -7
  5. {litdata-0.2.74 → litdata-0.2.75/src/litdata.egg-info}/PKG-INFO +1 -1
  6. {litdata-0.2.74 → litdata-0.2.75}/CONTRIBUTING.md +0 -0
  7. {litdata-0.2.74 → litdata-0.2.75}/LICENSE +0 -0
  8. {litdata-0.2.74 → litdata-0.2.75}/MANIFEST.in +0 -0
  9. {litdata-0.2.74 → litdata-0.2.75}/README.md +0 -0
  10. {litdata-0.2.74 → litdata-0.2.75}/requirements.txt +0 -0
  11. {litdata-0.2.74 → litdata-0.2.75}/setup.cfg +0 -0
  12. {litdata-0.2.74 → litdata-0.2.75}/setup.py +0 -0
  13. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/__init__.py +0 -0
  14. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/__main__.py +0 -0
  15. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/__init__.py +0 -0
  16. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/commands.py +0 -0
  17. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/handler/__init__.py +0 -0
  18. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/handler/cache.py +0 -0
  19. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/handler/optimize.py +0 -0
  20. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/cli/parser.py +0 -0
  21. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/constants.py +0 -0
  22. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/debugger.py +0 -0
  23. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/exceptions.py +0 -0
  24. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/helpers.py +0 -0
  25. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/imports.py +0 -0
  26. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/__init__.py +0 -0
  27. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/complete.py +0 -0
  28. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/data_processor.py +0 -0
  29. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/functions.py +0 -0
  30. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/media_folder.py +0 -0
  31. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/readers.py +0 -0
  32. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/processing/utilities.py +0 -0
  33. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/raw/__init__.py +0 -0
  34. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/raw/dataset.py +0 -0
  35. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/raw/indexer.py +0 -0
  36. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/raw/types.py +0 -0
  37. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/requirements.py +0 -0
  38. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/__init__.py +0 -0
  39. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/async_prefetch.py +0 -0
  40. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/cache.py +0 -0
  41. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/client.py +0 -0
  42. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/collate.py +0 -0
  43. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/combined.py +0 -0
  44. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/compression.py +0 -0
  45. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/config.py +0 -0
  46. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/dataloader.py +0 -0
  47. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/dataset_update.py +0 -0
  48. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/downloader.py +0 -0
  49. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/elastic.py +0 -0
  50. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/framed_zstd.py +0 -0
  51. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/fs_provider.py +0 -0
  52. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/parallel.py +0 -0
  53. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/posix_fast.py +0 -0
  54. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/reader.py +0 -0
  55. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/resolver.py +0 -0
  56. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/sampler.py +0 -0
  57. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/serializers.py +0 -0
  58. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/shuffle.py +0 -0
  59. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/timing.py +0 -0
  60. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/streaming/writer.py +0 -0
  61. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/types.py +0 -0
  62. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/__init__.py +0 -0
  63. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/_pytree.py +0 -0
  64. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/base.py +0 -0
  65. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/breakpoint.py +0 -0
  66. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/broadcast.py +0 -0
  67. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/dataset_utilities.py +0 -0
  68. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/encryption.py +0 -0
  69. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/env.py +0 -0
  70. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/format.py +0 -0
  71. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/hf_dataset.py +0 -0
  72. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/hf_fs.py +0 -0
  73. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/keys_index.py +0 -0
  74. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/packing.py +0 -0
  75. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/parquet.py +0 -0
  76. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/shuffle.py +0 -0
  77. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/subsample.py +0 -0
  78. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/torch_utils.py +0 -0
  79. {litdata-0.2.74 → litdata-0.2.75}/src/litdata/utilities/train_test_split.py +0 -0
  80. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/SOURCES.txt +0 -0
  81. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/dependency_links.txt +0 -0
  82. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/entry_points.txt +0 -0
  83. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/not-zip-safe +0 -0
  84. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/requires.txt +0 -0
  85. {litdata-0.2.74 → litdata-0.2.75}/src/litdata.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: litdata
3
- Version: 0.2.74
3
+ Version: 0.2.75
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
@@ -14,7 +14,7 @@
14
14
 
15
15
  import time
16
16
 
17
- __version__ = "0.2.74"
17
+ __version__ = "0.2.75"
18
18
  __author__ = "Lightning AI et al."
19
19
  __author_email__ = "pytorch@lightning.ai"
20
20
  __license__ = "Apache-2.0"
@@ -117,11 +117,11 @@ class StreamingDataset(IterableDataset):
117
117
  IDs from that first-run shuffler assignment, not a different bucket layout.
118
118
  batch_decode: How many items to deserialize together after a chunk is local.
119
119
  ``"auto"`` (default) picks from the data format and mean sample size
120
- (256 for text/nested, down to 1 for multi-MB images/video).
121
- ``0`` is per item, ``N`` is an aligned window, ``"all"`` is the whole chunk.
122
- Shuffle permutes items inside the same window so training still hits the
123
- cache. ``LITDATA_BATCH_DECODE`` / ``LITDATA_BATCH_ROWS`` apply only when
124
- this is ``"auto"``.
120
+ (256 for text/nested; 1 for JPEG/image/audio so each row is decoded
121
+ once). ``0`` is per item, ``N`` is an aligned window, ``"all"`` is the
122
+ whole chunk. Shuffle permutes items inside the same window so cheap
123
+ leaves still hit the cache. ``LITDATA_BATCH_DECODE`` /
124
+ ``LITDATA_BATCH_ROWS`` apply only when this is ``"auto"``.
125
125
  item_shuffle_window: In-chunk shuffle block size (pairs with ``batch_decode``).
126
126
  ``None`` / ``"auto"`` (default) is 256, or ``LITDATA_ITEM_SHUFFLE_WINDOW``.
127
127
  ``0`` / ``"full"`` is a full in-chunk permutation. Blocks are shuffled,
@@ -63,7 +63,9 @@ _BATCH_SKIP = object()
63
63
  # Cap for cheap leaves (text / nested JSON). Images/video scale down from avg bytes.
64
64
  _DEFAULT_BATCH_ROWS = 256
65
65
  _AUTO_WINDOW_BYTES = 16 << 20 # ~16MB of on-disk samples per decode window
66
- _HEAVY_LEAF = frozenset(
66
+ # C++ / per-row deserialize is not amortizable. A window smaller than
67
+ # ``item_shuffle_window`` (default 256) re-decodes the same JPEG ~16×.
68
+ _PER_ITEM_LEAF = frozenset(
67
69
  {
68
70
  "jpeg",
69
71
  "pil",
@@ -76,6 +78,11 @@ _HEAVY_LEAF = frozenset(
76
78
  "nifti",
77
79
  "tiff",
78
80
  "jpeg_array",
81
+ }
82
+ )
83
+ _HEAVY_LEAF = frozenset(
84
+ {
85
+ *_PER_ITEM_LEAF,
79
86
  "tensor",
80
87
  "no_header_tensor",
81
88
  "graph",
@@ -129,14 +136,22 @@ def _leaf_key(name: str) -> str:
129
136
  return name.split(":", 1)[0].lower()
130
137
 
131
138
 
139
+ def _item_only_batch(batch_rows: int | None) -> bool:
140
+ """``0`` / ``1`` decode the requested row; ``-1`` / ``N>1`` keep a window."""
141
+ return batch_rows is not None and 0 <= batch_rows <= 1
142
+
143
+
132
144
  def _auto_batch_rows(data_format: list[str] | None, chunks: list | None = None) -> int:
133
145
  """Pick a window from leaf types and mean on-disk sample size.
134
146
 
135
- Text/nested stay at 256 (measured winner). A 2MB JPEG would turn 256 into
136
- a multi-GB Python spike, so heavy leaves scale toward 1.
147
+ Text/nested stay at 256 (measured winner). JPEG / image / audio always use
148
+ 1 (decode only the requested row) so shuffle cannot re-decode a dropped
149
+ window. Large tensors still scale toward 1 from mean on-disk bytes.
137
150
  """
138
151
  avg = _avg_sample_bytes(chunks)
139
152
  keys = [_leaf_key(name) for name in (data_format or [])]
153
+ if any(key in _PER_ITEM_LEAF for key in keys):
154
+ return 1
140
155
  heavy = any(key in _HEAVY_LEAF for key in keys)
141
156
  if avg >= 1 << 20:
142
157
  return 1
@@ -695,6 +710,7 @@ class PyTreeLoader(BaseItemLoader):
695
710
  self._framed_meta: dict[int, FramedHeader] = {}
696
711
  self._framed_decompressor: Any | None = None
697
712
  self._framed_inflate_buf: bytes | memoryview | None = None
713
+ self._framed_inflate_key: tuple[int, int] | None = None
698
714
  self._compression_level = "chunk"
699
715
  self._sample_compression = False
700
716
 
@@ -891,10 +907,19 @@ class PyTreeLoader(BaseItemLoader):
891
907
  and len(rows) == n_items
892
908
  ):
893
909
  return rows[table_idx - first]
894
- raw = inflate_frame(view, header, frame_i, self._framed_compressor())
895
- self._framed_inflate_buf = raw
910
+ inflate_key = (chunk_index, frame_i)
911
+ if self._framed_inflate_key == inflate_key and self._framed_inflate_buf is not None:
912
+ raw = self._framed_inflate_buf
913
+ else:
914
+ raw = inflate_frame(view, header, frame_i, self._framed_compressor())
915
+ self._framed_inflate_buf = raw
916
+ self._framed_inflate_key = inflate_key
896
917
  base = header.offsets[first]
897
918
  local_offsets = [int(off) - base for off in header.offsets[first : first + n_items + 1]]
919
+ if _item_only_batch(self._batch_rows):
920
+ local_i = table_idx - first
921
+ decoded = self._batch_deserialize_payload(raw, local_offsets, chunk_index, local_i, local_i + 1)
922
+ return decoded[0]
898
923
  decoded = self._batch_deserialize_payload(raw, local_offsets, chunk_index, 0, n_items)
899
924
  return self._store_decode_window(chunk_index, first, decoded, table_idx)
900
925
 
@@ -927,10 +952,10 @@ class PyTreeLoader(BaseItemLoader):
927
952
  arrow = self._try_arrow_footer_rows(view, chunk_index, table_idx)
928
953
  if arrow is not _BATCH_SKIP:
929
954
  return arrow
930
- if not batch_rows:
955
+ if _item_only_batch(batch_rows):
931
956
  return _BATCH_SKIP
932
957
  return self._fill_decode_window_mmap(chunk_index, table_idx, batch_rows)
933
- if not batch_rows:
958
+ if _item_only_batch(batch_rows):
934
959
  with open(chunk_filepath, "rb") as handle:
935
960
  blob = handle.read()
936
961
  header = self._resolve_framed_header(chunk_index, blob)
@@ -1418,6 +1443,7 @@ class PyTreeLoader(BaseItemLoader):
1418
1443
  state["_framed_meta"] = {}
1419
1444
  state["_framed_decompressor"] = None
1420
1445
  state["_framed_inflate_buf"] = None
1446
+ state["_framed_inflate_key"] = None
1421
1447
  # Compiled unflatten closures aren't picklable; rebuild after unpickle.
1422
1448
  state["_unflatten"] = None
1423
1449
  state["_sizes_struct"] = None
@@ -1453,6 +1479,8 @@ class PyTreeLoader(BaseItemLoader):
1453
1479
  self._framed_meta = {}
1454
1480
  self._framed_decompressor = None
1455
1481
  self._framed_inflate_buf = None
1482
+ if not hasattr(self, "_framed_inflate_key"):
1483
+ self._framed_inflate_key = None
1456
1484
  data_spec = getattr(self, "_data_spec", None)
1457
1485
  if isinstance(data_spec, TreeSpec):
1458
1486
  self._unflatten = _compile_treespec_unflatten(data_spec)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: litdata
3
- Version: 0.2.74
3
+ Version: 0.2.75
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes