-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Introduce AcceleratorAllocatorConfig as the common class #149601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/149601
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (4 Unrelated Failures)As of commit 63983b1 with merge base 6de2413 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot revert -m 'See #149601 (comment)' -c ghfirst |
|
@pytorchbot successfully started a revert job. Check the current status here. |
…9601)" This reverts commit 1e8e9f7. Reverted #149601 on behalf of https://github.com/huydhn due to See #149601 (comment) ([comment](#149601 (comment)))
|
@guangyey your PR has been successfully reverted. |
| }; | ||
|
|
||
| C10_API inline void setAllocatorSettings(const std::string& env) { | ||
| AcceleratorAllocatorConfig::instance().parseArgs(env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this one still going to parse at global init time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API will be only used inside torch._C._accelerator_setAllocatorSetting. The user will call it.
|
@wdvr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@wdvr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@wdvr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
Starting merge as part of PR stack under #156175 |
# Motivation Add a mechanism to ensure raise the key if the key is unrecognized in allocator config. Pull Request resolved: #157908 Approved by: https://github.com/albanD ghstack dependencies: #149601
…0312) # Motivation Refactor `CUDAAllocatorConfig` to reuse `AcceleratorAllocatorConfig` and `ConfigTokenizer`. We would deprecate those option that overleap with `AcceleratorAllocatorConfig` in the following PR and keep them only for BC. Pull Request resolved: #150312 Approved by: https://github.com/albanD ghstack dependencies: #149601, #157908
# Motivation This PR moves the implementation of `torch.cuda.memory._set_allocator_settings` to `torch._C._accelerator_setAllocatorSettings`. Since the original API was intended as a temporary/internal utility, I am not exposing the new function as a public API. Pull Request resolved: #156175 Approved by: https://github.com/albanD ghstack dependencies: #149601, #157908, #150312, #156165
# Motivation This PR aims to generalize `AllocatorConfig` to be device-agnostic. Introduce the class `AcceleratorAllocatorConfig` to clarify its scope as a configuration manager for accelerator backends (e.g., CUDA, XPU). The another name `AllocatorConfig` is now reserved for a potential future base class that can unify configuration handling for both CPU and accelerator allocators, should similar requirements arise for the CPU path. # Design Rule ## Overall This class configures memory allocation for both device and host memory. A single `AcceleratorAllocatorConfig` instance is shared across all accelerator backends, such as CUDA and XPU, under the assumption that relevant environment variables apply uniformly to all accelerators. Device-specific configuration extensions are supported via hooks (see `registerDeviceConfigParserHook`). Introduce a new class `ConfigTokenizer` to help process the env variable config key-value pair ## Naming Convention: - Public API names in `AcceleratorAllocatorConfig` should be device-generic. - Members prefixed with `pinned_` are specific to the host/pinned allocator. - Environment variable names should be generic across backends. - Comma-separated key-value pairs in the format: `key:value`. Use square brackets `[]` for list values Example: `key1:123, key2:[val1,val2]` ## Environment Variables: - The default environment variable for configuration is `PYTORCH_ALLOC_CONF`. - For backward compatibility, `PYTORCH_CUDA_ALLOC_CONF` and `PYTORCH_HIP_ALLOC_CONF` are also supported with lower priority. Differential Revision: [D79011786](https://our.internmc.facebook.com/intern/diff/D79011786) Pull Request resolved: #149601 Approved by: https://github.com/albanD
# Motivation Add a mechanism to ensure raise the key if the key is unrecognized in allocator config. Pull Request resolved: #157908 Approved by: https://github.com/albanD ghstack dependencies: #149601
…0312) # Motivation Refactor `CUDAAllocatorConfig` to reuse `AcceleratorAllocatorConfig` and `ConfigTokenizer`. We would deprecate those option that overleap with `AcceleratorAllocatorConfig` in the following PR and keep them only for BC. Pull Request resolved: #150312 Approved by: https://github.com/albanD ghstack dependencies: #149601, #157908
# Motivation This PR moves the implementation of `torch.cuda.memory._set_allocator_settings` to `torch._C._accelerator_setAllocatorSettings`. Since the original API was intended as a temporary/internal utility, I am not exposing the new function as a public API. Pull Request resolved: #156175 Approved by: https://github.com/albanD ghstack dependencies: #149601, #157908, #150312, #156165
Stack from ghstack (oldest at bottom):
Motivation
This PR aims to generalize
AllocatorConfigto be device-agnostic. Introduce the classAcceleratorAllocatorConfigto clarify its scope as a configuration manager for accelerator backends (e.g., CUDA, XPU). The another nameAllocatorConfigis now reserved for a potential future base class that can unify configuration handling for both CPU and accelerator allocators, should similar requirements arise for the CPU path.Design Rule
Overall
This class configures memory allocation for both device and host memory. A single
AcceleratorAllocatorConfiginstance is shared across all accelerator backends, such as CUDA and XPU, under the assumption that relevant environment variables apply uniformly to all accelerators. Device-specific configuration extensions are supported via hooks (seeregisterDeviceConfigParserHook).Introduce a new class
ConfigTokenizerto help process the env variable config key-value pairNaming Convention:
AcceleratorAllocatorConfigshould be device-generic.pinned_are specific to the host/pinned allocator.key:value. Use square brackets[]for list values Example:key1:123, key2:[val1,val2]Environment Variables:
PYTORCH_ALLOC_CONF.PYTORCH_CUDA_ALLOC_CONFandPYTORCH_HIP_ALLOC_CONFare also supported with lower priority.cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @albanD @EikanWang
Differential Revision: D79011786