Repository navigation
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". 🟡 AUTOMATED REVIEW - Changes requested:
Findings (9): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200296
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit a49a226 with merge base 28e3c72 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
jeffdaily
left a comment
There was a problem hiding this comment.
My agent came up with this analysis, but I've read and approved it.
- Please add a ROCm test that exercises the reclassification directly, e.g. profile a D2D
x.clone()and assert the event isgpu_memcpynamedMemcpy DtoD (Device -> Device)with Bytes, and that no__amd_rocclr_*kernel event remains.test_all_kernel_events_have_dimsonly coverstorch.mmand does not show that fill/copy dispatches are retyped.RocmStreamQueue.h:async->op = kind + 1mapshipMemcpyDefaulttoROCPROFILER_MEMORY_COPY_LAST. Copies with nokindargument (hipMemcpyPeerAsync, used by the caching allocator for non-P2P cross-device copies, plushipMemcpyDtoD/HtoD/DtoH) then render asMemcpy <unknown> (? -> ?). Please map explicitly, deriving the direction from the API id when the kind is Default.- Memcpy bytes still come from the thread_local
correlationToSizeeven thoughinternalBytesis now set; useinternalBytesas the memset path does.
|
|
…copy kernels as memset/memcpy Kernel metadata now gets grid/block from the rocprofiler-sdk dispatch record (covers graph replays and API-less dispatches), and kernel dispatches correlated to hipMemset*/hipMemcpy* are retyped as GPU_MEMSET/GPU_MEMCPY (CUPTI parity) instead of surfacing as user kernels. Fixes missing 'grid' in TestMetadataJsonFormat on ROCm.
4f78c1d to
671b0d4
Compare
|
Responses to the review (force-pushed as
|
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Remaining automated-review items are refactors and test additions, tracked for a follow-up. Validated on ROCm 10.1 and ROCm 7.0.
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…me fill/copy kernels as memset/memcpy (pytorch#200296) ## Linked issue or supporting maintainer Supported by @jeffdaily Continuation of pytorch/kineto#1418 Fixes: pytorch#198442 Fixes: pytorch#187119 Fixes: pytorch#180072 Fixes: pytorch#179944 ## BC-breaking? No API change. On ROCm, trace outputs change for the same workload: - The runtime's fill/copy dispatches (`__amd_rocclr_fill*`/`__amd_rocclr_copyBuffer*`) move from `cat: "kernel"` to `gpu_memset`/`gpu_memcpy` events, as on CUDA. They are renamed, which changes `key_averages()` keys and `FunctionEvent.name`; they lose grid/block and gain bytes; the `kind` goes from "Dispatch Kernel" to none (memset) or a copy direction (memcpy); and they are now filtered by the GPU_MEMSET/GPU_MEMCPY masks instead of CONCURRENT_KERNEL. - hipExtModuleLaunchKernel/hipHccModuleLaunchKernel runtime events (Tensile `Cijk*` GEMMs) report `grid` in workgroups instead of the global work size, matching the kernel event. - A fill or copy that the runtime splits into several GPU records reports its bytes on the first record only, and none of the records reports a bandwidth. ## Summary (human written only) Some unit tests were still missing metadata for some kernels. This was due to a combination of bad test implementation and a unique feature of rocprofiler-sdk. Often the runtime use blit kernels for memcpy, memset, etc. Roctracer and Cupti report these as opaque memory operations, rocprofiler-sdk faithfully report the underlying kernels, e.g. __amd_rocclr_copyBuffer.kd. The flawed tests were grabbing those implicit kernels, and not finding the metadata they were expecting. Fix: - Mark those blit kernels as gpu_memset/gpu_memcpy GPU ops instead of kernel - Collect grid/block from the dispatch (KERNEL_DISPATCH buffer) record itself ## Agent details (if applicable) My agent came up with this analysis, but I've read and approved it. ### Summary On the rocprofiler-sdk path, kernel grid/block came only from correlating a HIP launch-API record, so kernels with no launch API (hipGraphLaunch replays, and the rocclr fill/copy kernels behind hipMemset*/hipMemcpy*) had no dims, which is why TestMetadataJsonFormat could not find `grid` on ROCm. This PR reads grid/block from the KERNEL_DISPATCH record (global size converted to workgroups, rounding up); the hipExtModuleLaunchKernel and hipHccModuleLaunchKernel runtime events now also report workgroups instead of the global work size, so the launch and the kernel agree. hipMemset* calls now produce a runtime row that carries their byte count (sizeBytes, width x height x depth, or count x element size) and stream. Dispatches that share the correlation id of a hipMemset*/hipMemcpy* call are reported as gpu_memset/gpu_memcpy, as CUPTI reports them, with the call's byte count and stream, and every memset/copy call starts an ac2g flow. Kernel-implemented copies emit no MEMORY_COPY record, so nothing is counted twice. When the runtime splits one call into several GPU records, one of them carries the bytes and none reports a bandwidth. The byte count of SDMA MEMORY_COPY records also comes from the copy call's row now, so the thread_local correlation maps (grid, block and size) are all removed. Copy byte counts now cover 2D copies (width x height) and array copies (count), and the `_spt` variants of the copy APIs are classified like the memset `_spt` variants already were. Tests: test_kineto now requires a device-side memcpy event on CUDA/ROCm (the CPU runtime call is also named memcpy, so the old check could not fail); new TestMetadataJsonFormatCUDA tests cover kernel dims for eager and graph-replayed kernels (and, on ROCm, equality with the launch API's grid/block), memcpy and memset reclassification with byte totals, and memset flows, each profiling after one discarded warmup session; RocmActivityProfilerTest covers copy direction, memset and copy byte counts, classification (including SDMA records, split calls and a second classification pass), the emitted name/type/metadata of reclassified rows, the output filter, and flow starts. Not covered, and unchanged from before (these dispatches were kernels or lacked the field before this PR too): memset and copy nodes replayed by hipGraphLaunch are still reported as kernels, because their dispatches carry the graph launch's correlation id and classifying them would need the kernel name; hipMemcpy3D* and hipMemcpyParam2D* copies have no byte count (their sizes are inside a struct argument); copies issued with hipMemcpyDefault through hipMemcpy/hipMemcpyAsync are named `Memcpy <unknown> (? -> ?)` because the direction is not in the call's arguments. Only the copy APIs listed in `isCopyApi` are classified; the array copies added in HIP_RUNTIME_API_TABLE_STEP_VERSION 3 (hipMemcpyAtoD, DtoA, AtoA, AtoHAsync, HtoAAsync, 2DArrayToArray) and hipDrvMemcpy* are not, and PyTorch issues none of them. ### Reland (maintainer update) The first landing was reverted because the `hipMemsetD2D*` rocprofiler IDs do not exist in ROCm 7.0's SDK; 6c79b5b guards them on `HIP_RUNTIME_API_TABLE_STEP_VERSION >= 14`. This update merges viable/strict (kineto moved to torch/csrc/profiler/kineto; the changes carried over unchanged) and removes the two remaining ROCm skips the `Fixes` lines refer to: `test_kineto_kernel_metadata_in_trace` (pytorch#180072) and `test_structured_metadata_matches_chrome_trace` (pytorch#179944, whose skip was re-added by the pytorch#198324 test move after pytorch#196487 fixed it). Test plan (done with Claude): built and ran on MI300X with ROCm 7.0.0 (rocprofiler-sdk 1.0.0, STEP_VERSION 13, so the guard drops the labels) and MI300X with ROCm 10.1. On both, every kineto source compiles with no warnings, the full test_profiler.py runs 207 tests OK with 16 skipped, RocmActivityProfilerTest passes 20/20, and each new or changed test passes when run alone in a fresh process. On a V100 with a CUDA 12.6 nightly, the changed TestMetadataJsonFormatCUDA tests and test_kineto_cuda pass alone in a fresh process. Without the change, `test_kernel_metadata_has_expected_fields` / `test_kernel_metadata_field_types` fail (`'grid' not found`) and so do the new tests. Sessions that got no kernel dispatch record at all on MI300X with ROCm 10.1 (rocprofiler-sdk delivering late dispatch records, ROCm/TheRock#9008) are fixed by pytorch#202758. ``` python test/profiler/test_profiler.py -k TestMetadataJsonFormatCUDA python test/profiler/test_profiler.py -k test_kineto_cuda python test/profiler/test_profiler.py -k test_kineto_kernel_metadata_in_trace python test/profiler/test_profiler.py -k test_structured_metadata_matches_chrome_trace python test/profiler/test_profiler.py ``` Pull Request resolved: pytorch#200296 Approved by: https://github.com/jeffdaily Co-authored-by: Jithun Nair <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
…me fill/copy kernels as memset/memcpy (pytorch#200296) ## Linked issue or supporting maintainer Supported by @jeffdaily Continuation of pytorch/kineto#1418 Fixes: pytorch#198442 Fixes: pytorch#187119 Fixes: pytorch#180072 Fixes: pytorch#179944 ## BC-breaking? No API change. On ROCm, trace outputs change for the same workload: - The runtime's fill/copy dispatches (`__amd_rocclr_fill*`/`__amd_rocclr_copyBuffer*`) move from `cat: "kernel"` to `gpu_memset`/`gpu_memcpy` events, as on CUDA. They are renamed, which changes `key_averages()` keys and `FunctionEvent.name`; they lose grid/block and gain bytes; the `kind` goes from "Dispatch Kernel" to none (memset) or a copy direction (memcpy); and they are now filtered by the GPU_MEMSET/GPU_MEMCPY masks instead of CONCURRENT_KERNEL. - hipExtModuleLaunchKernel/hipHccModuleLaunchKernel runtime events (Tensile `Cijk*` GEMMs) report `grid` in workgroups instead of the global work size, matching the kernel event. - A fill or copy that the runtime splits into several GPU records reports its bytes on the first record only, and none of the records reports a bandwidth. ## Summary (human written only) Some unit tests were still missing metadata for some kernels. This was due to a combination of bad test implementation and a unique feature of rocprofiler-sdk. Often the runtime use blit kernels for memcpy, memset, etc. Roctracer and Cupti report these as opaque memory operations, rocprofiler-sdk faithfully report the underlying kernels, e.g. __amd_rocclr_copyBuffer.kd. The flawed tests were grabbing those implicit kernels, and not finding the metadata they were expecting. Fix: - Mark those blit kernels as gpu_memset/gpu_memcpy GPU ops instead of kernel - Collect grid/block from the dispatch (KERNEL_DISPATCH buffer) record itself ## Agent details (if applicable) My agent came up with this analysis, but I've read and approved it. ### Summary On the rocprofiler-sdk path, kernel grid/block came only from correlating a HIP launch-API record, so kernels with no launch API (hipGraphLaunch replays, and the rocclr fill/copy kernels behind hipMemset*/hipMemcpy*) had no dims, which is why TestMetadataJsonFormat could not find `grid` on ROCm. This PR reads grid/block from the KERNEL_DISPATCH record (global size converted to workgroups, rounding up); the hipExtModuleLaunchKernel and hipHccModuleLaunchKernel runtime events now also report workgroups instead of the global work size, so the launch and the kernel agree. hipMemset* calls now produce a runtime row that carries their byte count (sizeBytes, width x height x depth, or count x element size) and stream. Dispatches that share the correlation id of a hipMemset*/hipMemcpy* call are reported as gpu_memset/gpu_memcpy, as CUPTI reports them, with the call's byte count and stream, and every memset/copy call starts an ac2g flow. Kernel-implemented copies emit no MEMORY_COPY record, so nothing is counted twice. When the runtime splits one call into several GPU records, one of them carries the bytes and none reports a bandwidth. The byte count of SDMA MEMORY_COPY records also comes from the copy call's row now, so the thread_local correlation maps (grid, block and size) are all removed. Copy byte counts now cover 2D copies (width x height) and array copies (count), and the `_spt` variants of the copy APIs are classified like the memset `_spt` variants already were. Tests: test_kineto now requires a device-side memcpy event on CUDA/ROCm (the CPU runtime call is also named memcpy, so the old check could not fail); new TestMetadataJsonFormatCUDA tests cover kernel dims for eager and graph-replayed kernels (and, on ROCm, equality with the launch API's grid/block), memcpy and memset reclassification with byte totals, and memset flows, each profiling after one discarded warmup session; RocmActivityProfilerTest covers copy direction, memset and copy byte counts, classification (including SDMA records, split calls and a second classification pass), the emitted name/type/metadata of reclassified rows, the output filter, and flow starts. Not covered, and unchanged from before (these dispatches were kernels or lacked the field before this PR too): memset and copy nodes replayed by hipGraphLaunch are still reported as kernels, because their dispatches carry the graph launch's correlation id and classifying them would need the kernel name; hipMemcpy3D* and hipMemcpyParam2D* copies have no byte count (their sizes are inside a struct argument); copies issued with hipMemcpyDefault through hipMemcpy/hipMemcpyAsync are named `Memcpy <unknown> (? -> ?)` because the direction is not in the call's arguments. Only the copy APIs listed in `isCopyApi` are classified; the array copies added in HIP_RUNTIME_API_TABLE_STEP_VERSION 3 (hipMemcpyAtoD, DtoA, AtoA, AtoHAsync, HtoAAsync, 2DArrayToArray) and hipDrvMemcpy* are not, and PyTorch issues none of them. ### Reland (maintainer update) The first landing was reverted because the `hipMemsetD2D*` rocprofiler IDs do not exist in ROCm 7.0's SDK; 6c79b5b guards them on `HIP_RUNTIME_API_TABLE_STEP_VERSION >= 14`. This update merges viable/strict (kineto moved to torch/csrc/profiler/kineto; the changes carried over unchanged) and removes the two remaining ROCm skips the `Fixes` lines refer to: `test_kineto_kernel_metadata_in_trace` (pytorch#180072) and `test_structured_metadata_matches_chrome_trace` (pytorch#179944, whose skip was re-added by the pytorch#198324 test move after pytorch#196487 fixed it). Test plan (done with Claude): built and ran on MI300X with ROCm 7.0.0 (rocprofiler-sdk 1.0.0, STEP_VERSION 13, so the guard drops the labels) and MI300X with ROCm 10.1. On both, every kineto source compiles with no warnings, the full test_profiler.py runs 207 tests OK with 16 skipped, RocmActivityProfilerTest passes 20/20, and each new or changed test passes when run alone in a fresh process. On a V100 with a CUDA 12.6 nightly, the changed TestMetadataJsonFormatCUDA tests and test_kineto_cuda pass alone in a fresh process. Without the change, `test_kernel_metadata_has_expected_fields` / `test_kernel_metadata_field_types` fail (`'grid' not found`) and so do the new tests. Sessions that got no kernel dispatch record at all on MI300X with ROCm 10.1 (rocprofiler-sdk delivering late dispatch records, ROCm/TheRock#9008) are fixed by pytorch#202758. ``` python test/profiler/test_profiler.py -k TestMetadataJsonFormatCUDA python test/profiler/test_profiler.py -k test_kineto_cuda python test/profiler/test_profiler.py -k test_kineto_kernel_metadata_in_trace python test/profiler/test_profiler.py -k test_structured_metadata_matches_chrome_trace python test/profiler/test_profiler.py ``` Pull Request resolved: pytorch#200296 Approved by: https://github.com/jeffdaily Co-authored-by: Jithun Nair <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Jeff Daily <[email protected]>
…me fill/copy kernels as memset/memcpy (pytorch#200296) Supported by @jeffdaily Continuation of pytorch/kineto#1418 Fixes: pytorch#198442 Fixes: pytorch#187119 Fixes: pytorch#180072 Fixes: pytorch#179944 No API change. On ROCm, trace outputs change for the same workload: - The runtime's fill/copy dispatches (`__amd_rocclr_fill*`/`__amd_rocclr_copyBuffer*`) move from `cat: "kernel"` to `gpu_memset`/`gpu_memcpy` events, as on CUDA. They are renamed, which changes `key_averages()` keys and `FunctionEvent.name`; they lose grid/block and gain bytes; the `kind` goes from "Dispatch Kernel" to none (memset) or a copy direction (memcpy); and they are now filtered by the GPU_MEMSET/GPU_MEMCPY masks instead of CONCURRENT_KERNEL. - hipExtModuleLaunchKernel/hipHccModuleLaunchKernel runtime events (Tensile `Cijk*` GEMMs) report `grid` in workgroups instead of the global work size, matching the kernel event. - A fill or copy that the runtime splits into several GPU records reports its bytes on the first record only, and none of the records reports a bandwidth. Some unit tests were still missing metadata for some kernels. This was due to a combination of bad test implementation and a unique feature of rocprofiler-sdk. Often the runtime use blit kernels for memcpy, memset, etc. Roctracer and Cupti report these as opaque memory operations, rocprofiler-sdk faithfully report the underlying kernels, e.g. __amd_rocclr_copyBuffer.kd. The flawed tests were grabbing those implicit kernels, and not finding the metadata they were expecting. Fix: - Mark those blit kernels as gpu_memset/gpu_memcpy GPU ops instead of kernel - Collect grid/block from the dispatch (KERNEL_DISPATCH buffer) record itself My agent came up with this analysis, but I've read and approved it. On the rocprofiler-sdk path, kernel grid/block came only from correlating a HIP launch-API record, so kernels with no launch API (hipGraphLaunch replays, and the rocclr fill/copy kernels behind hipMemset*/hipMemcpy*) had no dims, which is why TestMetadataJsonFormat could not find `grid` on ROCm. This PR reads grid/block from the KERNEL_DISPATCH record (global size converted to workgroups, rounding up); the hipExtModuleLaunchKernel and hipHccModuleLaunchKernel runtime events now also report workgroups instead of the global work size, so the launch and the kernel agree. hipMemset* calls now produce a runtime row that carries their byte count (sizeBytes, width x height x depth, or count x element size) and stream. Dispatches that share the correlation id of a hipMemset*/hipMemcpy* call are reported as gpu_memset/gpu_memcpy, as CUPTI reports them, with the call's byte count and stream, and every memset/copy call starts an ac2g flow. Kernel-implemented copies emit no MEMORY_COPY record, so nothing is counted twice. When the runtime splits one call into several GPU records, one of them carries the bytes and none reports a bandwidth. The byte count of SDMA MEMORY_COPY records also comes from the copy call's row now, so the thread_local correlation maps (grid, block and size) are all removed. Copy byte counts now cover 2D copies (width x height) and array copies (count), and the `_spt` variants of the copy APIs are classified like the memset `_spt` variants already were. Tests: test_kineto now requires a device-side memcpy event on CUDA/ROCm (the CPU runtime call is also named memcpy, so the old check could not fail); new TestMetadataJsonFormatCUDA tests cover kernel dims for eager and graph-replayed kernels (and, on ROCm, equality with the launch API's grid/block), memcpy and memset reclassification with byte totals, and memset flows, each profiling after one discarded warmup session; RocmActivityProfilerTest covers copy direction, memset and copy byte counts, classification (including SDMA records, split calls and a second classification pass), the emitted name/type/metadata of reclassified rows, the output filter, and flow starts. Not covered, and unchanged from before (these dispatches were kernels or lacked the field before this PR too): memset and copy nodes replayed by hipGraphLaunch are still reported as kernels, because their dispatches carry the graph launch's correlation id and classifying them would need the kernel name; hipMemcpy3D* and hipMemcpyParam2D* copies have no byte count (their sizes are inside a struct argument); copies issued with hipMemcpyDefault through hipMemcpy/hipMemcpyAsync are named `Memcpy <unknown> (? -> ?)` because the direction is not in the call's arguments. Only the copy APIs listed in `isCopyApi` are classified; the array copies added in HIP_RUNTIME_API_TABLE_STEP_VERSION 3 (hipMemcpyAtoD, DtoA, AtoA, AtoHAsync, HtoAAsync, 2DArrayToArray) and hipDrvMemcpy* are not, and PyTorch issues none of them. The first landing was reverted because the `hipMemsetD2D*` rocprofiler IDs do not exist in ROCm 7.0's SDK; 6c79b5b guards them on `HIP_RUNTIME_API_TABLE_STEP_VERSION >= 14`. This update merges viable/strict (kineto moved to torch/csrc/profiler/kineto; the changes carried over unchanged) and removes the two remaining ROCm skips the `Fixes` lines refer to: `test_kineto_kernel_metadata_in_trace` (pytorch#180072) and `test_structured_metadata_matches_chrome_trace` (pytorch#179944, whose skip was re-added by the pytorch#198324 test move after pytorch#196487 fixed it). Test plan (done with Claude): built and ran on MI300X with ROCm 7.0.0 (rocprofiler-sdk 1.0.0, STEP_VERSION 13, so the guard drops the labels) and MI300X with ROCm 10.1. On both, every kineto source compiles with no warnings, the full test_profiler.py runs 207 tests OK with 16 skipped, RocmActivityProfilerTest passes 20/20, and each new or changed test passes when run alone in a fresh process. On a V100 with a CUDA 12.6 nightly, the changed TestMetadataJsonFormatCUDA tests and test_kineto_cuda pass alone in a fresh process. Without the change, `test_kernel_metadata_has_expected_fields` / `test_kernel_metadata_field_types` fail (`'grid' not found`) and so do the new tests. Sessions that got no kernel dispatch record at all on MI300X with ROCm 10.1 (rocprofiler-sdk delivering late dispatch records, ROCm/TheRock#9008) are fixed by pytorch#202758. ``` python test/profiler/test_profiler.py -k TestMetadataJsonFormatCUDA python test/profiler/test_profiler.py -k test_kineto_cuda python test/profiler/test_profiler.py -k test_kineto_kernel_metadata_in_trace python test/profiler/test_profiler.py -k test_structured_metadata_matches_chrome_trace python test/profiler/test_profiler.py ``` Pull Request resolved: pytorch#200296 Approved by: https://github.com/jeffdaily Co-authored-by: Jithun Nair <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Jeff Daily <[email protected]> (cherry picked from commit 1ab6780) [release/2.15 adaptation, by mwootton] - Kineto paths landed under third_party/kineto (2.15 predates the vendoring move to torch/csrc/profiler/kineto). - The three prerequisite ROCm kineto fixes (pytorch#199973, pytorch#202665, pytorch#202758) were cherry-picked ahead of this commit; this branch's kineto snapshot (Oct 2) predates them. - test_profiler.py: kept on the pre-split TestMetadataJsonFormat class (the CUDA split landed after the branch cut); added @instantiate_parametrized_tests to that class so the new parameterized test is collected; dropped the skipXPUIf decorator hunk (added upstream after the cut). Fixes ROCM-31589 Fixes ROCM-29809
Linked issue or supporting maintainer
Supported by @jeffdaily
Continuation of pytorch/kineto#1418
Fixes: #198442
Fixes: #187119
Fixes: #180072
Fixes: #179944
BC-breaking?
No API change. On ROCm, trace outputs change for the same workload:
__amd_rocclr_fill*/__amd_rocclr_copyBuffer*) move fromcat: "kernel"togpu_memset/gpu_memcpyevents, as on CUDA. They are renamed, which changeskey_averages()keys andFunctionEvent.name; they lose grid/block and gain bytes; thekindgoes from "Dispatch Kernel" to none (memset) or a copy direction (memcpy); and they are now filtered by the GPU_MEMSET/GPU_MEMCPY masks instead of CONCURRENT_KERNEL.Cijk*GEMMs) reportgridin workgroups instead of the global work size, matching the kernel event.Summary (human written only)
Some unit tests were still missing metadata for some kernels. This was due to a combination of bad test implementation and a unique feature of rocprofiler-sdk. Often the runtime use blit kernels for memcpy, memset, etc. Roctracer and Cupti report these as opaque memory operations, rocprofiler-sdk faithfully report the underlying kernels, e.g. __amd_rocclr_copyBuffer.kd.
The flawed tests were grabbing those implicit kernels, and not finding the metadata they were expecting.
Fix:
Agent details (if applicable)
My agent came up with this analysis, but I've read and approved it.
Summary
On the rocprofiler-sdk path, kernel grid/block came only from correlating a HIP launch-API record, so kernels with no launch API (hipGraphLaunch replays, and the rocclr fill/copy kernels behind hipMemset*/hipMemcpy*) had no dims, which is why TestMetadataJsonFormat could not find
gridon ROCm. This PR reads grid/block from the KERNEL_DISPATCH record (global size converted to workgroups, rounding up); the hipExtModuleLaunchKernel and hipHccModuleLaunchKernel runtime events now also report workgroups instead of the global work size, so the launch and the kernel agree.hipMemset* calls now produce a runtime row that carries their byte count (sizeBytes, width x height x depth, or count x element size) and stream. Dispatches that share the correlation id of a hipMemset*/hipMemcpy* call are reported as gpu_memset/gpu_memcpy, as CUPTI reports them, with the call's byte count and stream, and every memset/copy call starts an ac2g flow. Kernel-implemented copies emit no MEMORY_COPY record, so nothing is counted twice. When the runtime splits one call into several GPU records, one of them carries the bytes and none reports a bandwidth. The byte count of SDMA MEMORY_COPY records also comes from the copy call's row now, so the thread_local correlation maps (grid, block and size) are all removed. Copy byte counts now cover 2D copies (width x height) and array copies (count), and the
_sptvariants of the copy APIs are classified like the memset_sptvariants already were.Tests: test_kineto now requires a device-side memcpy event on CUDA/ROCm (the CPU runtime call is also named memcpy, so the old check could not fail); new TestMetadataJsonFormatCUDA tests cover kernel dims for eager and graph-replayed kernels (and, on ROCm, equality with the launch API's grid/block), memcpy and memset reclassification with byte totals, and memset flows, each profiling after one discarded warmup session; RocmActivityProfilerTest covers copy direction, memset and copy byte counts, classification (including SDMA records, split calls and a second classification pass), the emitted name/type/metadata of reclassified rows, the output filter, and flow starts.
Not covered, and unchanged from before (these dispatches were kernels or lacked the field before this PR too): memset and copy nodes replayed by hipGraphLaunch are still reported as kernels, because their dispatches carry the graph launch's correlation id and classifying them would need the kernel name; hipMemcpy3D* and hipMemcpyParam2D* copies have no byte count (their sizes are inside a struct argument); copies issued with hipMemcpyDefault through hipMemcpy/hipMemcpyAsync are named
Memcpy <unknown> (? -> ?)because the direction is not in the call's arguments. Only the copy APIs listed inisCopyApiare classified; the array copies added in HIP_RUNTIME_API_TABLE_STEP_VERSION 3 (hipMemcpyAtoD, DtoA, AtoA, AtoHAsync, HtoAAsync, 2DArrayToArray) and hipDrvMemcpy* are not, and PyTorch issues none of them.Reland (maintainer update)
The first landing was reverted because the
hipMemsetD2D*rocprofiler IDs do not exist in ROCm 7.0's SDK; 6c79b5b guards them onHIP_RUNTIME_API_TABLE_STEP_VERSION >= 14. This update merges viable/strict (kineto moved to torch/csrc/profiler/kineto; the changes carried over unchanged) and removes the two remaining ROCm skips theFixeslines refer to:test_kineto_kernel_metadata_in_trace(#180072) andtest_structured_metadata_matches_chrome_trace(#179944, whose skip was re-added by the #198324 test move after #196487 fixed it).Test plan (done with Claude): built and ran on MI300X with ROCm 7.0.0 (rocprofiler-sdk 1.0.0, STEP_VERSION 13, so the guard drops the labels) and MI300X with ROCm 10.1. On both, every kineto source compiles with no warnings, the full test_profiler.py runs 207 tests OK with 16 skipped, RocmActivityProfilerTest passes 20/20, and each new or changed test passes when run alone in a fresh process. On a V100 with a CUDA 12.6 nightly, the changed TestMetadataJsonFormatCUDA tests and test_kineto_cuda pass alone in a fresh process. Without the change,
test_kernel_metadata_has_expected_fields/test_kernel_metadata_field_typesfail ('grid' not found) and so do the new tests. Sessions that got no kernel dispatch record at all on MI300X with ROCm 10.1 (rocprofiler-sdk delivering late dispatch records, ROCm/TheRock#9008) are fixed by #202758.cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang