fix: auto-disable expandable_segments around cumem memory pool#1657
Conversation
Signed-off-by: AlpinDale <alpindale@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8d48eb925
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if expandable_was_enabled: | ||
| torch.cuda.memory._set_allocator_settings("expandable_segments:True") |
There was a problem hiding this comment.
Preserve disabled allocator state across nested pool scopes
Re-enabling expandable_segments on every context exit breaks nested use_memory_pool usage when PYTORCH_CUDA_ALLOC_CONF contains expandable_segments:True. Each nested call recomputes expandable_was_enabled from the environment, so an inner scope restores expandable_segments:True while an outer scope is still active, which reintroduces the exact incompatible allocator mode this context is trying to suppress and can trigger allocator failures in the remainder of the outer block.
Useful? React with 👍 / 👎.
No description provided.