Skip to content
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

Add compatibility with skip_memory_metrics for mps device #29264

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

SunMarc
Copy link
Member

@SunMarc SunMarc commented Feb 23, 2024

What does this PR do

This PR makes mps device compatible with memory profiling integrated in Trainer (skip_memory_metrics=False). However, we can't get the information on the peak memory since torch.mps.max_memory_allocated() doesn't exist yet.
Fixes #27181
Tested on mac and I get the following output for a simple Trainer example:

{'train_runtime': 7.8136, 'train_samples_per_second': 24.572, 'train_steps_per_second': 3.072, 'train_loss': 5.870065689086914, 'init_mem_cpu_alloc_delta': 950272, 'init_mem_gpu_alloc_delta': 512, 'init_mem_cpu_peaked_delta': 16384, 'init_mem_gpu_peaked_delta': 'Not available', 'train_mem_cpu_alloc_delta': 38354944, 'train_mem_gpu_alloc_delta': 2304, 'train_mem_cpu_peaked_delta': 16384, 'train_mem_gpu_peaked_delta': 'Not available', 'before_init_mem_cpu': 351813632, 'before_init_mem_gpu': 0, 'epoch': 3.0}

@SunMarc SunMarc requested a review from ArthurZucker February 23, 2024 23:11
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SunMarc SunMarc changed the title Add compatibility with mps device Add compatibility with skip_memory_metrics for mps device Feb 26, 2024
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤗 thanks you for this long due fix!

@SunMarc SunMarc merged commit 8a1faf2 into main Feb 27, 2024
21 checks passed
@SunMarc SunMarc deleted the add-mps-compatibility-memory-metrics branch February 27, 2024 14:58
itazap pushed a commit that referenced this pull request May 14, 2024
* Add compatibility with mps device

* fix

* typo and style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

skip_memory_metrics=False breaks training loop when on MPS device
3 participants