[Bugfix][NPU][XPU] Use platform-aware profiler activities for trace generation#1542
[Bugfix][NPU][XPU] Use platform-aware profiler activities for trace generation#1542lishunyang12 wants to merge 3 commits intovllm-project:mainfrom
Conversation
|
Thanks! I will test it on NPU. |
352bb61 to
3b5b321
Compare
|
|
||
| activities = [ProfilerActivity.CPU] | ||
| device_type = current_omni_platform.device_type | ||
| if device_type == "npu": |
There was a problem hiding this comment.
Does it support other platforms(rocm, xpu)? Does it require adaptation?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good point — I'll add XPU support too. ROCm already works with the CUDA fallback since PyTorch maps it to ProfilerActivity.CUDA.
|
@xuechendi PTAL |
| activities.append(getattr(ProfilerActivity, "NPU")) | ||
| elif device_type == "xpu": | ||
| # Intel XPU support | ||
| activities.append(getattr(ProfilerActivity, "XPU")) |
There was a problem hiding this comment.
This is how we did in vLLM main repo
TorchProfilerActivity = Literal["CPU", "CUDA", "XPU"]
TorchProfilerActivityMap = {
"CPU": torch.profiler.ProfilerActivity.CPU,
"CUDA": torch.profiler.ProfilerActivity.CUDA,
"XPU": torch.profiler.ProfilerActivity.XPU,
}
Current codes with getattr also works. Thanks for adding XPU
|
please fix DCO |
|
Hi, I still encounter error |
Signed-off-by: lishunyang <lishunyang12@163.com>
Signed-off-by: lishunyang <lishunyang12@163.com>
Signed-off-by: lishunyang <lishunyang12@163.com>
ac733e2 to
c9961c9
Compare
|
@JustQJ Please tried it again. I made some changes according to your bug results. :) |
Hi, In my test, my env |
Summary
TorchProfilerhardcodesProfilerActivity.CUDA, which fails on NPU (Ascend) devices sinceCUDAactivity is not available there.current_omni_platform.device_typeand usesProfilerActivity.NPU(provided bytorch_npu) on NPU devices, falling back toProfilerActivity.CUDAotherwise.Fixes #1484
Test plan
export_chrome_traceshould produce a valid trace file.ProfilerActivity.CUDAis still used.cc @gcanlin