dumpsterpanda 0.2.2__tar.gz → 0.2.4__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.2 → dumpsterpanda-0.2.4}/PKG-INFO +1 -1
  2. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/pyproject.toml +1 -1
  3. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/__init__.py +1 -1
  4. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/app.py +3 -1
  5. dumpsterpanda-0.2.4/src/trash_panda/cli/hardware.py +71 -0
  6. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/config.py +2 -1
  7. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/hardware.py +7 -0
  8. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/loader.py +17 -1
  9. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/LICENSE +0 -0
  10. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/README.md +0 -0
  11. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/__init__.py +0 -0
  12. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/config.py +0 -0
  13. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/info.py +0 -0
  14. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/names.py +0 -0
  15. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/plan.py +0 -0
  16. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/cli/trace.py +0 -0
  17. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/__init__.py +0 -0
  18. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/blocks.py +0 -0
  19. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/checkpoint.py +0 -0
  20. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/coordinator.py +0 -0
  21. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/depth.py +0 -0
  22. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/early.py +0 -0
  23. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/formats.py +0 -0
  24. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/hooks.py +0 -0
  25. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/measure.py +0 -0
  26. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/order_file.py +0 -0
  27. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/planner.py +0 -0
  28. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/report.py +0 -0
  29. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/stage.py +0 -0
  30. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/offload/trace.py +0 -0
  31. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/paths.py +0 -0
  32. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/__init__.py +0 -0
  33. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/load.py +0 -0
  34. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/server.py +0 -0
  35. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/app.js +0 -0
  36. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/bars.js +0 -0
  37. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/data.js +0 -0
  38. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/files.js +0 -0
  39. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/index.html +0 -0
  40. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/memory.js +0 -0
  41. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/memorychart.js +0 -0
  42. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/package.json +0 -0
  43. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/panels.js +0 -0
  44. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/style.css +0 -0
  45. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/svg.js +0 -0
  46. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/src/trash_panda/ui/static/timeline.js +0 -0
  47. {dumpsterpanda-0.2.2 → dumpsterpanda-0.2.4}/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.2
3
+ Version: 0.2.4
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.2"
3
+ version = "0.2.4"
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.2"
3
+ __version__ = "0.2.4"
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 = (
@@ -6,6 +6,7 @@ except ImportError:
6
6
  raise SystemExit("The command line needs extra packages: pip install 'dumpsterpanda[cli]'")
7
7
 
8
8
  from .config import config_command
9
+ from .hardware import hardware_command
9
10
  from .info import info_command
10
11
  from .plan import plan_command
11
12
  from .trace import trace_command
@@ -15,13 +16,14 @@ app = typer.Typer(no_args_is_help=True, add_completion=False, help="trash-panda:
15
16
 
16
17
  @app.callback()
17
18
  def _root() -> None:
18
- """The root of the commands: `trash-panda plan ...`, `trash-panda info ...`, `trash-panda trace ...`, `trash-panda config`."""
19
+ """The root of the commands: `trash-panda plan ...`, `trash-panda info ...`, `trash-panda trace ...`, `trash-panda config`, `trash-panda hardware`."""
19
20
 
20
21
 
21
22
  app.command("plan")(plan_command)
22
23
  app.command("info")(info_command)
23
24
  app.command("trace")(trace_command)
24
25
  app.command("config")(config_command)
26
+ app.command("hardware")(hardware_command)
25
27
 
26
28
 
27
29
  def main() -> None:
@@ -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)
@@ -52,7 +52,8 @@ class Defaults:
52
52
  find_blocks_min_blocks: int = 2 # ... and have at least this many blocks
53
53
 
54
54
  # diagnostics
55
- profile: bool = False # print where the prefetching spent its time
55
+ faulthandler: bool = True # turn faulthandler on when a model loads: a crash in native code then prints where (nothing is printed otherwise)
56
+ profile: bool = False # print where the prefetching spent its time
56
57
  trace: bool = False # record the run in a trace file (docs/design/trace-format.md), in TRASH_PANDA_TRACE_DIR
57
58
 
58
59
 
@@ -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
@@ -12,6 +12,7 @@ Each tensor is read lazily from the checkpoint and placed according to its tier:
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
+ import faulthandler
15
16
  import threading
16
17
  import time
17
18
  from collections import defaultdict
@@ -137,6 +138,20 @@ def _to_meta(model: nn.Module, name: str) -> None:
137
138
  owner._parameters[leaf] = nn.Parameter(torch.empty_like(p, device="meta"), requires_grad=False)
138
139
 
139
140
 
141
+ def _enable_faulthandler() -> None:
142
+ """Turn faulthandler on, so that a crash in native code (an access violation, a segmentation fault) prints the Python
143
+ traceback of every thread: where the process was when it died. Nothing is printed unless it crashes. It stays as it is
144
+ when it is on already (the user's own setting, `-X faulthandler`, PYTHONFAULTHANDLER=1), when TRASH_PANDA_FAULTHANDLER
145
+ turns it off, and when stderr has no file descriptor to write to (a notebook). A process that the system ends, as when
146
+ memory runs out, leaves no trace here: nothing runs in it then."""
147
+ if not config.current().faulthandler or faulthandler.is_enabled():
148
+ return
149
+ try:
150
+ faulthandler.enable(all_threads=True)
151
+ except (AttributeError, OSError, ValueError, RuntimeError):
152
+ pass
153
+
154
+
140
155
  def stream_load(
141
156
  model: nn.Module,
142
157
  path,
@@ -174,7 +189,8 @@ def stream_load(
174
189
  Returns a LoadReport (print it) and remembers the settings on the model for install_offload().
175
190
  """
176
191
  began_all = time.perf_counter()
177
- tr = _trace.loading_model() # the trace of the model that this thread is loading, if one is recorded
192
+ _enable_faulthandler()
193
+ tr = _trace.loading_model() # the trace of the model that this thread is loading, if one is recorded
178
194
  device = device or ("cuda" if torch.cuda.is_available() else "cpu")
179
195
  if plan is not None:
180
196
  cdt, sdt = plan.compute_dtype, plan.storage_dtype
File without changes
File without changes