Download offload/prefill_cause/runtime.py from ProprietaryLegal/dsv41-offload: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/ProprietaryLegal/dsv41-offload/resolve/main/offload/prefill_cause/runtime.py
- Command line
-
hf download hf://ProprietaryLegal/dsv41-offload/offload/prefill_cause/runtime.py
-
curl -L -o runtime.py https://huggingface.co/ProprietaryLegal/dsv41-offload/resolve/main/offload/prefill_cause/runtime.py
1.25 kB
| """PF1-CAUSE helper (mounted as vllm/v1/worker/gpu/dsv41_prefill_cause.py): host-only allocator counters for a span row. | |
| Only while a PF1-R2 trace chunk is open (prefill steps of an ON arm); otherwise an empty dict and no torch call. Reads | |
| the caching allocator's own statistics (no device read, no synchronization, no allocation). Numbers only. | |
| """ | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: # the same module as reviewed in this checkout (offload/prefill_trace/runtime.py) | |
| from offload.prefill_trace import runtime as _pf | |
| else: | |
| from vllm.v1.worker.gpu import dsv41_prefill_trace as _pf | |
| Scalar = str | int | float | bool | None | |
| STATS = {'alloc_retries': 'num_alloc_retries', 'device_allocs': 'num_device_alloc', 'device_frees': 'num_device_free', | |
| 'reserved_bytes': 'reserved_bytes.all.current', 'active_bytes': 'active_bytes.all.current', | |
| 'segments': 'segment.all.current'} | |
| def alloc(**extra: Scalar) -> dict[str, Scalar]: | |
| rec = _pf._recorder | |
| if not _pf.ENABLED or rec is None or rec.context is None: | |
| return {} | |
| import torch | |
| stats = torch.cuda.memory_stats() | |
| return {**extra, **{name: int(stats.get(key, -1)) for name, key in STATS.items()}} | |