layerpool 0.1.2__tar.gz → 0.1.3__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 (33) hide show
  1. {layerpool-0.1.2 → layerpool-0.1.3}/PKG-INFO +1 -1
  2. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/__init__.py +1 -1
  3. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/blocks.py +16 -1
  4. {layerpool-0.1.2 → layerpool-0.1.3}/.gitignore +0 -0
  5. {layerpool-0.1.2 → layerpool-0.1.3}/LICENSE +0 -0
  6. {layerpool-0.1.2 → layerpool-0.1.3}/README.md +0 -0
  7. {layerpool-0.1.2 → layerpool-0.1.3}/pyproject.toml +0 -0
  8. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/__main__.py +0 -0
  9. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/api.py +0 -0
  10. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/backends/__init__.py +0 -0
  11. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/backends/common.py +0 -0
  12. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/backends/mlx_backend.py +0 -0
  13. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/cli.py +0 -0
  14. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/codec.py +0 -0
  15. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/control.py +0 -0
  16. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/data.py +0 -0
  17. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/driver.py +0 -0
  18. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/export.py +0 -0
  19. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/fetch.py +0 -0
  20. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/hf.py +0 -0
  21. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/job.py +0 -0
  22. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/losses.py +0 -0
  23. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/net.py +0 -0
  24. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/planner.py +0 -0
  25. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/pool.py +0 -0
  26. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/selfcheck.py +0 -0
  27. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/telemetry.py +0 -0
  28. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/trainers.py +0 -0
  29. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/tunnel.py +0 -0
  30. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/ui/app.js +0 -0
  31. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/ui/index.html +0 -0
  32. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/ui/style.css +0 -0
  33. {layerpool-0.1.2 → layerpool-0.1.3}/src/layerpool/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: layerpool
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Train one model on all of your devices: layers split across GPUs, Apple Silicon and CPUs, with your own training code.
5
5
  Project-URL: Homepage, https://github.com/abdallah-swe/layerpool
6
6
  Project-URL: Repository, https://github.com/abdallah-swe/layerpool
@@ -1,6 +1,6 @@
1
1
  import importlib
2
2
 
3
- __version__ = "0.1.2"
3
+ __version__ = "0.1.3"
4
4
 
5
5
 
6
6
  def __getattr__(name):
@@ -276,7 +276,7 @@ def _prune_ranges(repo: str, keep: str):
276
276
  with open(os.path.join(keep, "layerpool_part.json"), "w", encoding="utf-8") as f:
277
277
  json.dump(marker, f)
278
278
  now = time.time()
279
- for name in os.listdir(RANGE_CACHE):
279
+ for name in os.listdir(RANGE_CACHE) if os.path.isdir(RANGE_CACHE) else ():
280
280
  folder = os.path.join(RANGE_CACHE, name)
281
281
  if folder == keep:
282
282
  continue
@@ -394,6 +394,8 @@ def load_blocks(repo: str, lay: dict, first: int, last: int, device, dtype, quan
394
394
  prefix = lay["stack"] + "."
395
395
  missing = {k for k in info.get("missing_keys", []) if k.startswith(prefix)}
396
396
  blocks = list(model.get_submodule(lay["stack"]))
397
+ if quantized:
398
+ _compute_in(blocks, dtype)
397
399
  if not quantized and in_place:
398
400
  saved = None if random_init else os.path.join(out, "model.safetensors")
399
401
  blocks = _as_in_full_model(blocks, config, lay, first, device, missing if not random_init else set(), repo, saved, dtype)
@@ -406,6 +408,19 @@ def load_blocks(repo: str, lay: dict, first: int, last: int, device, dtype, quan
406
408
  return blocks
407
409
 
408
410
 
411
+ def _compute_in(blocks, dtype):
412
+ """A 4-bit checkpoint names the 16-bit type it was made to compute in, mostly bfloat16, and its 16-bit weights load in that
413
+ type. GPUs without bfloat16 in hardware (a T4) emulate it, several times slower, so the blocks compute in the device's own."""
414
+ import torch
415
+ for block in blocks:
416
+ for mod in block.modules():
417
+ if type(mod).__name__ == "Linear4bit":
418
+ mod.compute_dtype, mod.compute_type_is_set = dtype, True
419
+ for value in [*block.parameters(), *block.buffers()]:
420
+ if value.dtype in (torch.float16, torch.bfloat16) and value.dtype != dtype:
421
+ value.data = value.data.to(dtype)
422
+
423
+
409
424
  def _as_in_full_model(loaded: list, config, lay: dict, first: int, device, missing: set, repo: str, saved: str | None = None,
410
425
  dtype=None) -> list:
411
426
  """The blocks as the full model builds them, holding the loaded weights. A model built with fewer blocks numbers them from 0
File without changes
File without changes
File without changes
File without changes
File without changes