dumpsterpanda 0.2.1__tar.gz → 0.2.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 (47) hide show
  1. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/PKG-INFO +1 -1
  2. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/pyproject.toml +1 -1
  3. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/__init__.py +1 -1
  4. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/app.py +5 -1
  5. dumpsterpanda-0.2.3/src/trash_panda/cli/config.py +68 -0
  6. dumpsterpanda-0.2.3/src/trash_panda/cli/hardware.py +71 -0
  7. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/hardware.py +7 -0
  8. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/LICENSE +0 -0
  9. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/README.md +0 -0
  10. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/__init__.py +0 -0
  11. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/info.py +0 -0
  12. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/names.py +0 -0
  13. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/plan.py +0 -0
  14. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/cli/trace.py +0 -0
  15. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/__init__.py +0 -0
  16. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/blocks.py +0 -0
  17. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/checkpoint.py +0 -0
  18. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/config.py +0 -0
  19. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/coordinator.py +0 -0
  20. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/depth.py +0 -0
  21. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/early.py +0 -0
  22. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/formats.py +0 -0
  23. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/hooks.py +0 -0
  24. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/loader.py +0 -0
  25. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/measure.py +0 -0
  26. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/order_file.py +0 -0
  27. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/planner.py +0 -0
  28. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/report.py +0 -0
  29. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/stage.py +0 -0
  30. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/offload/trace.py +0 -0
  31. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/paths.py +0 -0
  32. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/__init__.py +0 -0
  33. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/load.py +0 -0
  34. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/server.py +0 -0
  35. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/app.js +0 -0
  36. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/bars.js +0 -0
  37. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/data.js +0 -0
  38. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/files.js +0 -0
  39. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/index.html +0 -0
  40. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/memory.js +0 -0
  41. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/memorychart.js +0 -0
  42. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/package.json +0 -0
  43. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/panels.js +0 -0
  44. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/style.css +0 -0
  45. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/svg.js +0 -0
  46. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/timeline.js +0 -0
  47. {dumpsterpanda-0.2.1 → dumpsterpanda-0.2.3}/src/trash_panda/ui/static/usage.js +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dumpsterpanda
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: Run models bigger than your GPU: layer-by-layer weight streaming across GPU, RAM and disk.
5
5
  License: AGPL-3.0-only
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dumpsterpanda"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "Run models bigger than your GPU: layer-by-layer weight streaming across GPU, RAM and disk."
5
5
  authors = ["yla382"]
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  """trash-panda: run models bigger than your GPU by streaming weights across GPU, RAM and disk."""
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.3"
4
4
 
5
5
  # The offload API is imported lazily so that `import trash_panda` works even where torch is not installed yet.
6
6
  _OFFLOAD_NAMES = (
@@ -5,6 +5,8 @@ try:
5
5
  except ImportError:
6
6
  raise SystemExit("The command line needs extra packages: pip install 'dumpsterpanda[cli]'")
7
7
 
8
+ from .config import config_command
9
+ from .hardware import hardware_command
8
10
  from .info import info_command
9
11
  from .plan import plan_command
10
12
  from .trace import trace_command
@@ -14,12 +16,14 @@ app = typer.Typer(no_args_is_help=True, add_completion=False, help="trash-panda:
14
16
 
15
17
  @app.callback()
16
18
  def _root() -> None:
17
- """The root of the commands: `trash-panda plan ...`, `trash-panda info ...`, `trash-panda trace ...`."""
19
+ """The root of the commands: `trash-panda plan ...`, `trash-panda info ...`, `trash-panda trace ...`, `trash-panda config`, `trash-panda hardware`."""
18
20
 
19
21
 
20
22
  app.command("plan")(plan_command)
21
23
  app.command("info")(info_command)
22
24
  app.command("trace")(trace_command)
25
+ app.command("config")(config_command)
26
+ app.command("hardware")(hardware_command)
23
27
 
24
28
 
25
29
  def main() -> None:
@@ -0,0 +1,68 @@
1
+ """`trash-panda config`: every setting and environment variable, with the value it has now."""
2
+
3
+ import os
4
+ from dataclasses import fields
5
+
6
+ import typer
7
+ from rich.console import Console
8
+ from rich.table import Table
9
+ from rich.text import Text
10
+
11
+ from .. import paths
12
+
13
+ console = Console()
14
+
15
+
16
+ def _show(value) -> str:
17
+ return str(value).lower() if isinstance(value, bool) else str(value)
18
+
19
+
20
+ def rows() -> list:
21
+ """(variable, value, state) for every variable, the folders first. The state is "default" (not set), "set" or "invalid"."""
22
+ from ..offload import config
23
+
24
+ out = []
25
+ for var, value in (("TRASH_PANDA_HOME", paths.cache_dir()), ("TRASH_PANDA_TRACE_DIR", paths.trace_dir())):
26
+ out.append((var, str(value), "set" if os.environ.get(var, "").strip() else "default"))
27
+ for field in fields(config.DEFAULTS):
28
+ var = config.ENV_PREFIX + field.name.upper()
29
+ default = getattr(config.DEFAULTS, field.name)
30
+ raw = os.environ.get(var)
31
+ if not raw: # an empty variable counts as not set, as in config.current()
32
+ out.append((var, _show(default), "default"))
33
+ continue
34
+ try:
35
+ out.append((var, _show(config._parse(field.name, default, raw)), "set"))
36
+ except ValueError:
37
+ out.append((var, raw, "invalid"))
38
+ return out
39
+
40
+
41
+ def _unknown(known) -> list:
42
+ """TRASH_PANDA_ variables in the environment that nothing reads, which is usually a typo."""
43
+ return sorted(name for name in os.environ if name.upper().startswith("TRASH_PANDA_") and name.upper() not in known)
44
+
45
+
46
+ def config_command() -> None:
47
+ """Show every setting and environment variable with its current value. A value nobody has set is marked (default)."""
48
+ shown = rows()
49
+ table = Table()
50
+ table.add_column("Variable", no_wrap=True)
51
+ table.add_column("Value", overflow="fold")
52
+ for var, value, state in shown:
53
+ cell = Text(value)
54
+ if state == "default":
55
+ cell.append(" (default)", style="dim")
56
+ elif state == "set":
57
+ cell.stylize("bold")
58
+ else:
59
+ cell.append(" (invalid)", style="red")
60
+ table.add_row(var, cell)
61
+ console.print(table)
62
+
63
+ unknown = _unknown({var for var, _, _ in shown})
64
+ if unknown:
65
+ console.print("Not a trash-panda variable, so it is ignored: " + ", ".join(unknown), markup=False)
66
+ if any(state == "invalid" for _, _, state in shown):
67
+ console.print("A value marked invalid cannot be read, and the library raises an error when it runs.", markup=False)
68
+ raise typer.Exit(1)
@@ -0,0 +1,71 @@
1
+ """`trash-panda hardware`: what this machine has, for a bug report."""
2
+
3
+ import platform
4
+
5
+ from rich.console import Console
6
+ from rich.table import Table
7
+ from rich.text import Text
8
+
9
+ console = Console()
10
+
11
+
12
+ def _gib(n) -> str:
13
+ """Bytes in GiB (1024 ** 3), the unit that memory is sold and shown in, unlike the decimal GB of the rest of the library."""
14
+ return f"{n / 1024 ** 3:.2f} GiB"
15
+
16
+ # What the rows that need a word of explanation mean. A row that is not here has an empty note.
17
+ NOTES = {
18
+ "Device": "Where a model runs by default.",
19
+ "Unified memory": "The GPU and the CPU share one memory pool, so splitting a model between them frees nothing.",
20
+ "Commit headroom": "Windows: how much more memory the system lets programs reserve (RAM plus page file).",
21
+ "CUDA": "The CUDA version this PyTorch was built for.",
22
+ "Compute capability": "The GPU's architecture version, which decides what it supports.",
23
+ "bf16": "The GPU supports bfloat16, a 16-bit float format used as a compute dtype.",
24
+ "Native fp8": "The GPU computes in fp8 itself (compute capability 8.9 or higher).",
25
+ }
26
+
27
+
28
+ def rows() -> list:
29
+ """(item, value) for each fact about this machine, in the order they are printed."""
30
+ import torch
31
+
32
+ from .. import __version__
33
+ from ..offload.hardware import detect_hardware
34
+
35
+ hw = detect_hardware()
36
+ out = [
37
+ ("trash-panda", f"v{__version__}"),
38
+ ("Python", f"v{platform.python_version()}"),
39
+ ("PyTorch", f"v{torch.__version__}"),
40
+ ("OS", f"{platform.system()} {platform.release()} {platform.version()} ({platform.machine()})"),
41
+ ("Device", hw.device),
42
+ ("Unified memory", "yes" if hw.unified_memory else "no"),
43
+ ("RAM", f"{_gib(hw.ram_available)} available of {_gib(hw.ram_total)}"),
44
+ ]
45
+ if hw.commit_available is not None:
46
+ out.append(("Commit headroom", _gib(hw.commit_available)))
47
+ if hw.device == "cuda":
48
+ out += [
49
+ ("GPU", hw.gpu_name),
50
+ ("VRAM", f"{_gib(hw.vram_free)} free of {_gib(hw.vram_total)}"),
51
+ ("CUDA", f"v{torch.version.cuda}" if torch.version.cuda else "none"),
52
+ ("Compute capability", ".".join(str(n) for n in hw.compute_capability)),
53
+ ("bf16", "yes" if hw.bf16_supported else "no"),
54
+ ("Native fp8", "yes" if hw.native_fp8 else "no"),
55
+ ]
56
+ elif hw.unified_memory:
57
+ out.append(("GPU memory", "shared with RAM"))
58
+ else:
59
+ out.append(("GPU", "none detected"))
60
+ return out
61
+
62
+
63
+ def hardware_command() -> None:
64
+ """Print the device, memory and versions of this machine. Paste it into a bug report."""
65
+ table = Table()
66
+ table.add_column("Item", no_wrap=True)
67
+ table.add_column("Value", no_wrap=True)
68
+ table.add_column("Note", overflow="fold")
69
+ for item, value in rows():
70
+ table.add_row(item, Text(str(value)), Text(NOTES.get(item, ""), style="dim"))
71
+ console.print(table)
@@ -23,6 +23,8 @@ class Hardware:
23
23
  compute_capability: Optional[Tuple[int, int]] = None
24
24
  bf16_supported: bool = False
25
25
  native_fp8: bool = False
26
+ device: str = "cpu" # where a model runs by default: "cuda", "mps" or "cpu"
27
+ unified_memory: bool = False # the device shares its memory with the CPU
26
28
 
27
29
  def summary(self) -> str:
28
30
  lines = []
@@ -127,6 +129,7 @@ def _read_ram() -> Tuple[int, int, Optional[int]]:
127
129
  def detect_hardware(device_index: int = 0) -> Hardware:
128
130
  hw = Hardware()
129
131
  if torch.cuda.is_available():
132
+ hw.device = "cuda"
130
133
  props = torch.cuda.get_device_properties(device_index)
131
134
  free, total = torch.cuda.mem_get_info(device_index)
132
135
  hw.vram_total, hw.vram_free = int(total), int(free)
@@ -134,5 +137,9 @@ def detect_hardware(device_index: int = 0) -> Hardware:
134
137
  hw.compute_capability = (props.major, props.minor)
135
138
  hw.bf16_supported = bool(torch.cuda.is_bf16_supported())
136
139
  hw.native_fp8 = hw.compute_capability >= (8, 9)
140
+ hw.unified_memory = bool(getattr(props, "is_integrated", False))
141
+ elif getattr(torch.backends, "mps", None) and torch.backends.mps.is_available():
142
+ hw.device = "mps"
143
+ hw.unified_memory = True
137
144
  hw.ram_total, hw.ram_available, hw.commit_available = _read_ram()
138
145
  return hw
File without changes
File without changes