fix: add MPS device support#3763
Closed
Aanushka001 wants to merge 2 commits into
Closed
Conversation
- Add import gc at module level - Add empty_mps_cache function for MPS device cache clearing - Add MPS cache clearing handler in _setup_common_training_handlers
Collaborator
|
@Aanushka001 you have a lot unrelated changes, split this PR into multiple ones with one PR for one fix. |
Author
|
placeholder |
2 similar comments
Author
|
placeholder |
Author
|
placeholder |
This was referenced May 31, 2026
Author
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.
Description
This PR improves MPS (Apple Metal Performance Shaders) device support in PyTorch Ignite, addressing issues raised in #2977.
Changes
ignite/distributed/auto.pyauto_dataloader(): Updatedpin_memorydefault to also enable for MPS devices, not just CUDA. This ensures data loading performance is optimized when using Apple Silicon GPUs.ignite/contrib/engines/common.pyempty_mps_cache(): New handler function that clears MPS cache (viatorch.mps.empty_cache()) at the end of each epoch, similar to the existingempty_cuda_cache()for CUDA devices._setup_common_training_handlers(): Now registers the MPS cache clearing handler when running on MPS devices.Related
Closes #2977