fix(engine): handle torch 2.9 allocator API deprecation - #245
Open
fangyuan-3149 wants to merge 1 commit into
Open
fix(engine): handle torch 2.9 allocator API deprecation#245fangyuan-3149 wants to merge 1 commit into
fangyuan-3149 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
expandable_segmentsallocator setting broken by PyTorch 2.9 API migration.Background & Impact
expandable_segmentsis a CUDA allocator switch that lets freed GPU memory blocks be split, merged, and reused at arbitrary sizes instead of being locked into fixed-size buckets.Why it matters:
In MoE offload/hybrid paths, each step fetches expert weights from host RAM, dequantizes them to BF16 (7–9 MB), computes, and immediately frees the buffer. The block size varies per layer/step because the active expert count changes.
Scope: Benefits every workload with variable-sized allocate/free cycles — MoE offload/hybrid dequant, KV cache growth, long-context serving. Memory-constrained GPUs benefit most, but all GPUs gain the same allocator efficiency.
Change
PyTorch 2.9 moved the internal API for
expandable_segmentsfromtorch.cuda.memory._set_allocator_settings→torch._C._cuda_setAllocatorSettings.The old path still works but emits a
FutureWarning, polluting CI logs.Fix: Try the new private API
torch._C._cuda_setAllocatorSettingsfirst; onAttributeErrorfall back to the legacytorch.cuda.memory._set_allocator_settings. Behavior is identical; only the warning is removed.Verification
python -m py_compilepassespytest -m "not slow"— no new warnings, CI clean