Skip to content

Add compatibility with skip_memory_metrics for mps device#29264

Merged
SunMarc merged 3 commits intomainfrom
add-mps-compatibility-memory-metrics
Feb 27, 2024
Merged

Add compatibility with skip_memory_metrics for mps device#29264
SunMarc merged 3 commits intomainfrom
add-mps-compatibility-memory-metrics

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
@SunMarc SunMarc deleted the add-mps-compatibility-memory-metrics branch February 27, 2024 14:58
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