[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 into
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 |
ac733e2 to
c9961c9
Compare
|
@JustQJ Please tried it again. I made some changes according to your bug results. :) |
Hi, In my test, my env |
|
@lishunyang12 @JustQJ any progress? |
…eneration Signed-off-by: lishunyang <lishunyang12@163.com>
c9961c9 to
f433b1a
Compare
|
@JustQJ The crash is fixed — the The reason @david6666666 DCO is fixed, squashed into one commit. Ready to go. |
|
Should we accelerate this PR? @david6666666 @gcanlin |
|
@lishunyang12 Thanks for your contribution. #1261 is integrating NPU activities. NPU needs to use torch_npu api to get the activities after my check. Please take a look. I will add co-author in #1261 for you :) |
Thanks @gcanlin |
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