Skip to content

Enable memory snapshot for generic devices - #2228

Merged
tianyu-l merged 3 commits into
pytorch:mainfrom
frost-intel:xpu_memory_snapshot
Jan 15, 2026
Merged

tianyu-l merged 3 commits into
pytorch:mainfrom
frost-intel:xpu_memory_snapshot

Conversation

@frost-intel

Copy link
Copy Markdown
Contributor

Pytorch recently added _record_memory_history for Intel XPU. This PR makes the memory snapshot device-generic.

@pkourdis @githubsgi

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 14, 2026
Comment thread torchtitan/tools/profiling.py Outdated
class MemoryProfiler:
def __init__(self, step_num: int, freq: int):
torch.cuda.memory._record_memory_history(
self.device_module = torch.get_device_module()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tianyu-l

Copy link
Copy Markdown
Contributor

test failed

@frost-intel

Copy link
Copy Markdown
Contributor Author

I found device_module typing was incorrect, so I fixed that and the relevant typing overrides.

# PP computation ========================================================
_hook_coordinator.enable_coordination(num_layers=min_num_layers)
main_stream = torch.accelerator.current_stream(device_module)
main_stream = torch.accelerator.current_stream(device_type)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After fixing the typing for device_module, using it here throws a pyre typing error.

current_stream accepts a device type, which can be torch.device | str | int | None (from types.py ).

It looks like torch.cuda or torch.xpu can convert to one of these types, but it's definitely not the intended design, and we should use the correct device_type since we already have it.

@tianyu-l
tianyu-l merged commit 6408426 into pytorch:main Jan 15, 2026
wwwjn pushed a commit to wwwjn/torchtitan that referenced this pull request Jan 30, 2026
Pytorch recently added `_record_memory_history` for Intel XPU. This PR
makes the memory snapshot device-generic.

@pkourdis @githubsgi
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
Pytorch recently added `_record_memory_history` for Intel XPU. This PR
makes the memory snapshot device-generic.

@pkourdis @githubsgi
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
Pytorch recently added `_record_memory_history` for Intel XPU. This PR
makes the memory snapshot device-generic.

@pkourdis @githubsgi
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
Pytorch recently added `_record_memory_history` for Intel XPU. This PR
makes the memory snapshot device-generic.

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

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants