Files
tokenspeed/python
943bef04fb fix(memory): scope expandable segments around memory saver operations (#3640)
Enabling expandable CUDA segments together with memory saver can fail
initialization or bypass the allocator that tracks managed storage. This
change temporarily disables expandable segments during managed weight/KV
and persistent-buffer allocations, CUDA graph capture, and pause/resume.
It restores the effective allocator configuration and both environment
aliases afterward, including on exceptions and when the last
configuration string omits the active expandable setting.

The allocator setting is process-wide. The adapter serializes its own
scopes, and callers must keep unrelated CUDA allocation threads idle
during startup or drained maintenance.

Validation:
- `pre-commit run --all-files` passed.
- H200 with PyTorch 2.9.0 and `torch_memory_saver` 0.0.10: 19 passed, 1
skipped. The skipped case uses `PYTORCH_ALLOC_CONF`, which does not
enable expandable segments in the tested Torch build.
- GPU tests cover expandable allocations outside managed scopes,
weight/KV/buffer isolation, graph replay, three pause/resume cycles,
exception and sticky-setting restoration, and normal process exit.

---------

Signed-off-by: lyzuu <349859374+lyzuu@users.noreply.github.com>
Co-authored-by: lyzuu <349859374+lyzuu@users.noreply.github.com>
Co-authored-by: longcat-ia-team <312376714+longcat-ia-team@users.noreply.github.com>
2026-11-19 14:55:22 -08:00
..
2026-05-06 13:27:02 +00:00