Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion vllm_omni/diffusion/profiler/torch_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@
logger = init_logger(__name__)


def _get_profiler_activities() -> list[ProfilerActivity]:
"""Return the appropriate profiler activities for the current platform."""
from vllm_omni.platforms import current_omni_platform

activities = [ProfilerActivity.CPU]
device_type = current_omni_platform.device_type
if device_type == "npu":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does it support other platforms(rocm, xpu)? Does it require adaptation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ROCm uses \ in PyTorch's profiler API, so the else branch already covers it. XPU support can be added when needed — this PR is scoped to fix #1484.

@lishunyang12 lishunyang12 Feb 28, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point — I'll add XPU support too. ROCm already works with the CUDA fallback since PyTorch maps it to ProfilerActivity.CUDA.

# torch_npu registers ProfilerActivity.NPU on import
try:
import torch_npu # noqa: F401
except ImportError:
pass
if hasattr(ProfilerActivity, "NPU"):
activities.append(ProfilerActivity.NPU)
else:
logger.warning("ProfilerActivity.NPU not available. Make sure torch_npu is installed.")
elif device_type == "xpu":
if hasattr(ProfilerActivity, "XPU"):
activities.append(ProfilerActivity.XPU)
else:
logger.warning("ProfilerActivity.XPU not available. Make sure Intel XPU support is installed.")
else:
activities.append(ProfilerActivity.CUDA)
return activities


class TorchProfiler(ProfilerBase):
"""
Torch-based profiler configured for End-to-End continuous recording.
Expand Down Expand Up @@ -70,7 +96,7 @@ def trace_handler(p):

# 4. Initialize profiler with long active period
cls._profiler = profile(
activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],
activities=_get_profiler_activities(),
schedule=torch.profiler.schedule(
wait=0,
warmup=0,
Expand Down
Loading