Skip to content

fix: add MPS device support#3763

Closed
Aanushka001 wants to merge 2 commits into
pytorch:masterfrom
Aanushka001:fix-mps-device
Closed

fix: add MPS device support#3763
Aanushka001 wants to merge 2 commits into
pytorch:masterfrom
Aanushka001:fix-mps-device

Conversation

@Aanushka001
Copy link
Copy Markdown

Description

This PR improves MPS (Apple Metal Performance Shaders) device support in PyTorch Ignite, addressing issues raised in #2977.

Changes

ignite/distributed/auto.py

  • auto_dataloader(): Updated pin_memory default 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.py

  • Added empty_mps_cache(): New handler function that clears MPS cache (via torch.mps.empty_cache()) at the end of each epoch, similar to the existing empty_cuda_cache() for CUDA devices.
  • _setup_common_training_handlers(): Now registers the MPS cache clearing handler when running on MPS devices.

Related

Closes #2977

- 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
@github-actions github-actions Bot added module: distributed Distributed module module: contrib Contrib module labels May 31, 2026
@vfdev-5
Copy link
Copy Markdown
Collaborator

vfdev-5 commented May 31, 2026

@Aanushka001 you have a lot unrelated changes, split this PR into multiple ones with one PR for one fix.

@Aanushka001
Copy link
Copy Markdown
Author

placeholder

2 similar comments
@Aanushka001
Copy link
Copy Markdown
Author

placeholder

@Aanushka001
Copy link
Copy Markdown
Author

placeholder

@Aanushka001
Copy link
Copy Markdown
Author

Split into separate focused PRs as requested: #3764 (MPS pin_memory), #3765 (MPS cache clearing), #3766 (API fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: contrib Contrib module module: distributed Distributed module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with using "mps" device

2 participants