tensorferry 0.2.0__tar.gz → 0.2.1__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 (35) hide show
  1. {tensorferry-0.2.0/src/tensorferry.egg-info → tensorferry-0.2.1}/PKG-INFO +1 -1
  2. {tensorferry-0.2.0 → tensorferry-0.2.1}/pyproject.toml +1 -1
  3. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/store.py +26 -4
  4. {tensorferry-0.2.0 → tensorferry-0.2.1/src/tensorferry.egg-info}/PKG-INFO +1 -1
  5. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_progress.py +10 -6
  6. {tensorferry-0.2.0 → tensorferry-0.2.1}/LICENSE +0 -0
  7. {tensorferry-0.2.0 → tensorferry-0.2.1}/MANIFEST.in +0 -0
  8. {tensorferry-0.2.0 → tensorferry-0.2.1}/README.md +0 -0
  9. {tensorferry-0.2.0 → tensorferry-0.2.1}/scripts/bench_remote.py +0 -0
  10. {tensorferry-0.2.0 → tensorferry-0.2.1}/setup.cfg +0 -0
  11. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/__init__.py +0 -0
  12. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/_pool.py +0 -0
  13. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/api.py +0 -0
  14. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/backend.py +0 -0
  15. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/cache.py +0 -0
  16. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/formats.py +0 -0
  17. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/jax.py +0 -0
  18. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/loader.py +0 -0
  19. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/plan.py +0 -0
  20. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/progress.py +0 -0
  21. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry/torch.py +0 -0
  22. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/SOURCES.txt +0 -0
  23. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/dependency_links.txt +0 -0
  24. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/requires.txt +0 -0
  25. {tensorferry-0.2.0 → tensorferry-0.2.1}/src/tensorferry.egg-info/top_level.txt +0 -0
  26. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/__init__.py +0 -0
  27. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/_files.py +0 -0
  28. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/conftest.py +0 -0
  29. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_cache.py +0 -0
  30. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_formats.py +0 -0
  31. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_jax.py +0 -0
  32. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_loader.py +0 -0
  33. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_remote.py +0 -0
  34. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_store.py +0 -0
  35. {tensorferry-0.2.0 → tensorferry-0.2.1}/tests/test_torch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorferry
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Streaming checkpoint loading for NumPy, JAX, and PyTorch
5
5
  Author: Revanta
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tensorferry"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  readme = "README.md"
9
9
  description = "Streaming checkpoint loading for NumPy, JAX, and PyTorch"
10
10
  requires-python = ">=3.12"
@@ -178,6 +178,10 @@ class CallbackStore:
178
178
  return self.size_fn(name)
179
179
 
180
180
 
181
+ # Chunk size for obstore streaming reads when download progress is tracked (obstore's default is 10 MiB).
182
+ _PROGRESS_CHUNK_BYTES = 512 << 10
183
+
184
+
181
185
  class ObjectStore:
182
186
  """Hub authentication uses the supplied token or the locally configured Hugging Face token."""
183
187
 
@@ -211,11 +215,29 @@ class ObjectStore:
211
215
  if stop <= start:
212
216
  return b""
213
217
  if self._is_remote and _download.get() is not None:
214
- chunks: list[Buffer] = []
215
- for chunk in obstore.get(self.store, name, options={"range": (start, stop)}):
218
+ result = obstore.get(self.store, name, options={"range": (start, stop)})
219
+ stream = result.stream(min_chunk_size=_PROGRESS_CHUNK_BYTES)
220
+ first = next(stream, None)
221
+ if first is None:
222
+ return b""
223
+ _record_read(first)
224
+ span = getattr(result, "range", None)
225
+ expected = stop - start if span is None else span[1] - span[0]
226
+ if len(first) >= expected:
227
+ return first
228
+ out = np.empty(expected, np.uint8)
229
+ at = len(first)
230
+ out[:at] = np.frombuffer(first, np.uint8)
231
+ for chunk in stream:
216
232
  _record_read(chunk)
217
- chunks.append(chunk)
218
- return chunks[0] if len(chunks) == 1 else b"".join(chunks)
233
+ n = len(chunk)
234
+ if at + n > out.size:
235
+ grown = np.empty(at + n, np.uint8)
236
+ grown[:at] = out[:at]
237
+ out = grown
238
+ out[at : at + n] = np.frombuffer(chunk, np.uint8)
239
+ at += n
240
+ return out[:at]
219
241
  data = obstore.get_range(self.store, name, start=start, end=stop)
220
242
  if self._is_remote:
221
243
  _record_read(data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorferry
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Streaming checkpoint loading for NumPy, JAX, and PyTorch
5
5
  Author: Revanta
6
6
  License-Expression: Apache-2.0
@@ -155,6 +155,7 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
155
155
  chunk1_recorded, release_chunk2 = threading.Event(), threading.Event()
156
156
  split = weights.nbytes // 2
157
157
  prefetched = []
158
+ stream_chunk_sizes: list[int] = []
158
159
 
159
160
  def stream_get(backend, name, *, options):
160
161
  result = get(backend, name, options=options)
@@ -162,13 +163,15 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
162
163
  if isinstance(byte_range, tuple) and byte_range[0] > 0:
163
164
  data = bytes(result.bytes())
164
165
 
165
- def chunks():
166
- yield data[:split]
167
- chunk1_recorded.set()
168
- assert release_chunk2.wait(10)
169
- yield data[split:]
166
+ class _FakeResult:
167
+ def stream(self, min_chunk_size: int = 10 << 20):
168
+ stream_chunk_sizes.append(min_chunk_size)
169
+ yield data[:split]
170
+ chunk1_recorded.set()
171
+ assert release_chunk2.wait(10)
172
+ yield data[split:]
170
173
 
171
- return chunks()
174
+ return _FakeResult()
172
175
  start, stop = result.range
173
176
  prefetched.append(stop - start)
174
177
  return result
@@ -183,6 +186,7 @@ def test_download_progress_streams_chunks_and_untracked_uses_get_range(monkeypat
183
186
  release_chunk2.set()
184
187
  np.testing.assert_array_equal(pending.result(timeout=10)["weights"], weights)
185
188
  assert progress.snapshot() == (before + weights.nbytes, before + weights.nbytes)
189
+ assert stream_chunk_sizes == [512 << 10]
186
190
  finally:
187
191
  release_chunk2.set()
188
192
 
File without changes
File without changes
File without changes
File without changes
File without changes