mirror of
https://github.com/lightseekorg/tokenspeed.git
synced 2026-12-04 02:16:40 +08:00
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>