Skip to content

[ROCm][kineto] Fix segfault at exit with a profiler session still open - #202665

Closed
pablo-garay wants to merge 2 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocprof-exit-tls
Closed

pablo-garay wants to merge 2 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocprof-exit-tls

Conversation

@pablo-garay

@pablo-garay pablo-garay commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue or supporting maintainer

Related: #199973 (found while testing it)

Supported by @jeffdaily

BC-breaking?

No

Summary (human written only)

The torch.profiler for ROCm could segfault at process exit if a profiling session was still running, because it used thread-local state that had already been destroyed.

Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

Problem. A process that exits while a torch.profiler session with GPU activity is still running can segfault on ROCm. On gfx90a with hipBLASLt it crashes on every exit; on other archs and on the rocBLAS path it depends on what is left in freed memory (MALLOC_PERTURB_=165 makes those crash too).

Cause. exit() destroys the main thread's thread_locals before the static destructors of rocBLAS and hipBLASLt run. Those destructors call hipModuleUnload, which rocprofiler-sdk still traces, so RocprofLogger::api_callback indexes its destroyed thread_local timestamp map. Per-thread-buffer mode and the correlation-id stacks touch destroyed thread_locals the same way.

Change. api_callback keeps the ENTER timestamp in the SDK's per-call user_data, which rocprofiler-sdk retains from the ENTER to the EXIT phase of one call, so the map is gone (and with it a hash insert and erase per traced HIP call). The remaining per-thread state (correlation-id stacks and the per-thread buffer) moves into one thread_local ThreadState whose destructor sets a trivially destructible t_threadExiting flag before its members are destroyed; once set, api_callback and the correlation push/pop return early and rows go to the shared buffer. The HIP calls dropped this way are those a thread makes after its kineto state is gone: for the main thread that is inside exit(), where no session can collect them; a worker thread exiting during a session loses its last such calls, which were undefined behaviour before. The new test_profiler_left_running_at_exit_cuda exits a subprocess with the profiler running under MALLOC_PERTURB_=165.

Test plan.

gfx90a (MI250X) and gfx1100 (W7800), TheRock ROCm 10.1 (rocprofiler-sdk 1.4.1), on main 9c0fed7, A/B by reverting RocprofLogger.cpp. Exit codes of a script that starts a CPU+CUDA profile, runs a matmul and exits without stopping (139 = SIGSEGV):

BLAS path env gfx90a without fix gfx1100 without fix with fix (both GPUs)
hipBLASLt plain 139 x3 139 x3 0 x15
hipBLASLt MALLOC_PERTURB_=165 139 x3 139 x3 0 x15
rocBLAS plain 0 x3 0 x3 0 x15
rocBLAS MALLOC_PERTURB_=165 139 x3 139 x3 0 x15

The backtrace without the fix is api_callback -> destroyed thread_local map, called from hipModuleUnload in hipBLASLt's or rocBLAS's TensileHost destructor inside exit().

python test/profiler/test_profiler.py -k test_profiler_left_running_at_exit_cuda
python test/profiler/test_profiler.py
python test/profiler/test_kineto.py
python test/profiler/test_profiler_tree.py
  • The new test fails 6/6 without the fix (Expected 0 but got -11) and passes 6/6 with it on both GPUs, with hipBLASLt and with TORCH_BLAS_PREFER_HIPBLASLT=0.
  • With the fix, KINETO_USE_DAEMON=1 and per-thread buffers (ROCPROF_PER_THREAD_BUFFER_ENABLED=true, confirmed active) also exit 0 under MALLOC_PERTURB_=165.
  • test_profiler.py, test_kineto.py, test_profiler_tree.py: no new failures (the two TestMetadataJsonFormatCUDA grid failures fail the same way without the fix).

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

If a torch.profiler session with GPU activity is still running when the process exits, the main thread's thread_locals are destroyed inside exit() before the static destructors of rocBLAS and hipBLASLt run. Those destructors call hipModuleUnload, which rocprofiler-sdk still traces, so RocprofLogger::api_callback indexes its destroyed thread_local timestamp map. On gfx90a with hipBLASLt this segfaults every time; elsewhere it depends on what is left in the freed memory (MALLOC_PERTURB_=165 makes the rocBLAS path fault too).

api_callback now keeps the ENTER timestamp in the SDK's per-call user_data, which rocprofiler-sdk retains from the ENTER to the EXIT phase of one call, so the map is gone. That alone fixes the default configuration, but per-thread-buffer mode and the correlation-id stacks still touch destroyed thread_locals at exit. A trivially destructible t_threadExiting flag, set by a marker object declared after the other thread_locals in this file (and so destroyed before them), makes api_callback and the correlation push/pop return early and sends rows to the shared buffer once the thread is exiting. Calls dropped this way happen during thread teardown, where no session can collect them.

Test Plan:

```
python test/profiler/test_profiler.py -k test_profiler_left_running_at_exit_cuda
python test/profiler/test_profiler.py
python test/profiler/test_kineto.py
```

The new test fails without the fix (exit code -11) and passes with it.

Authored with Claude.
The marker relied on all of one file's thread_locals being constructed together and destroyed in reverse, which is how GCC and Clang implement them but not something C++ guarantees; a never-referenced marker need not be constructed at all. Holding the correlation-id stacks and the thread buffer in one ThreadState whose destructor sets the flag gives the same order by rule: a destructor body runs before its members are destroyed. Also give the exit test a timeout so a teardown hang cannot stall the shard.

Authored with Claude.
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Oct 29, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202665

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 528ab94 with merge base 9c0fed7 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@jithunnair-amd jithunnair-amd added ciflow/trunk Trigger trunk jobs on your pull request ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 labels Oct 29, 2026
@github-actions
github-actions Bot requested a review from jeffdaily October 29, 2026 22:33
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 29, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
pytorch#202665)

## Linked issue or supporting maintainer

Related: pytorch#199973 (found while testing it)

Supported by @jeffdaily

## BC-breaking?

No

## Summary (human written only)

The torch.profiler for ROCm could segfault at process exit if a profiling session was still running, because it used thread-local state that had already been destroyed.

## Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

**Problem.** A process that exits while a `torch.profiler` session with GPU activity is still running can segfault on ROCm. On gfx90a with hipBLASLt it crashes on every exit; on other archs and on the rocBLAS path it depends on what is left in freed memory (`MALLOC_PERTURB_=165` makes those crash too).

**Cause.** `exit()` destroys the main thread's thread_locals before the static destructors of rocBLAS and hipBLASLt run. Those destructors call `hipModuleUnload`, which rocprofiler-sdk still traces, so `RocprofLogger::api_callback` indexes its destroyed `thread_local` timestamp map. Per-thread-buffer mode and the correlation-id stacks touch destroyed thread_locals the same way.

**Change.** `api_callback` keeps the ENTER timestamp in the SDK's per-call `user_data`, which rocprofiler-sdk retains from the ENTER to the EXIT phase of one call, so the map is gone (and with it a hash insert and erase per traced HIP call). The remaining per-thread state (correlation-id stacks and the per-thread buffer) moves into one `thread_local ThreadState` whose destructor sets a trivially destructible `t_threadExiting` flag before its members are destroyed; once set, `api_callback` and the correlation push/pop return early and rows go to the shared buffer. The HIP calls dropped this way are those a thread makes after its kineto state is gone: for the main thread that is inside `exit()`, where no session can collect them; a worker thread exiting during a session loses its last such calls, which were undefined behaviour before. The new `test_profiler_left_running_at_exit_cuda` exits a subprocess with the profiler running under `MALLOC_PERTURB_=165`.

**Test plan.**

gfx90a (MI250X) and gfx1100 (W7800), TheRock ROCm 10.1 (rocprofiler-sdk 1.4.1), on main 9c0fed7, A/B by reverting `RocprofLogger.cpp`. Exit codes of a script that starts a CPU+CUDA profile, runs a matmul and exits without stopping (139 = SIGSEGV):

| BLAS path | env | gfx90a without fix | gfx1100 without fix | with fix (both GPUs) |
|---|---|---|---|---|
| hipBLASLt | plain | 139 x3 | 139 x3 | 0 x15 |
| hipBLASLt | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |
| rocBLAS | plain | 0 x3 | 0 x3 | 0 x15 |
| rocBLAS | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |

The backtrace without the fix is `api_callback` -> destroyed `thread_local` map, called from `hipModuleUnload` in hipBLASLt's or rocBLAS's `TensileHost` destructor inside `exit()`.

```
python test/profiler/test_profiler.py -k test_profiler_left_running_at_exit_cuda
python test/profiler/test_profiler.py
python test/profiler/test_kineto.py
python test/profiler/test_profiler_tree.py
```

- The new test fails 6/6 without the fix (`Expected 0 but got -11`) and passes 6/6 with it on both GPUs, with hipBLASLt and with `TORCH_BLAS_PREFER_HIPBLASLT=0`.
- With the fix, `KINETO_USE_DAEMON=1` and per-thread buffers (`ROCPROF_PER_THREAD_BUFFER_ENABLED=true`, confirmed active) also exit 0 under `MALLOC_PERTURB_=165`.
- `test_profiler.py`, `test_kineto.py`, `test_profiler_tree.py`: no new failures (the two `TestMetadataJsonFormatCUDA` `grid` failures fail the same way without the fix).

Pull Request resolved: pytorch#202665
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
pytorch#202665)

## Linked issue or supporting maintainer

Related: pytorch#199973 (found while testing it)

Supported by @jeffdaily

## BC-breaking?

No

## Summary (human written only)

The torch.profiler for ROCm could segfault at process exit if a profiling session was still running, because it used thread-local state that had already been destroyed.

## Agent details (if applicable)

My agent came up with this analysis, but I've read and approved it.

**Problem.** A process that exits while a `torch.profiler` session with GPU activity is still running can segfault on ROCm. On gfx90a with hipBLASLt it crashes on every exit; on other archs and on the rocBLAS path it depends on what is left in freed memory (`MALLOC_PERTURB_=165` makes those crash too).

**Cause.** `exit()` destroys the main thread's thread_locals before the static destructors of rocBLAS and hipBLASLt run. Those destructors call `hipModuleUnload`, which rocprofiler-sdk still traces, so `RocprofLogger::api_callback` indexes its destroyed `thread_local` timestamp map. Per-thread-buffer mode and the correlation-id stacks touch destroyed thread_locals the same way.

**Change.** `api_callback` keeps the ENTER timestamp in the SDK's per-call `user_data`, which rocprofiler-sdk retains from the ENTER to the EXIT phase of one call, so the map is gone (and with it a hash insert and erase per traced HIP call). The remaining per-thread state (correlation-id stacks and the per-thread buffer) moves into one `thread_local ThreadState` whose destructor sets a trivially destructible `t_threadExiting` flag before its members are destroyed; once set, `api_callback` and the correlation push/pop return early and rows go to the shared buffer. The HIP calls dropped this way are those a thread makes after its kineto state is gone: for the main thread that is inside `exit()`, where no session can collect them; a worker thread exiting during a session loses its last such calls, which were undefined behaviour before. The new `test_profiler_left_running_at_exit_cuda` exits a subprocess with the profiler running under `MALLOC_PERTURB_=165`.

**Test plan.**

gfx90a (MI250X) and gfx1100 (W7800), TheRock ROCm 10.1 (rocprofiler-sdk 1.4.1), on main 9c0fed7, A/B by reverting `RocprofLogger.cpp`. Exit codes of a script that starts a CPU+CUDA profile, runs a matmul and exits without stopping (139 = SIGSEGV):

| BLAS path | env | gfx90a without fix | gfx1100 without fix | with fix (both GPUs) |
|---|---|---|---|---|
| hipBLASLt | plain | 139 x3 | 139 x3 | 0 x15 |
| hipBLASLt | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |
| rocBLAS | plain | 0 x3 | 0 x3 | 0 x15 |
| rocBLAS | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |

The backtrace without the fix is `api_callback` -> destroyed `thread_local` map, called from `hipModuleUnload` in hipBLASLt's or rocBLAS's `TensileHost` destructor inside `exit()`.

```
python test/profiler/test_profiler.py -k test_profiler_left_running_at_exit_cuda
python test/profiler/test_profiler.py
python test/profiler/test_kineto.py
python test/profiler/test_profiler_tree.py
```

- The new test fails 6/6 without the fix (`Expected 0 but got -11`) and passes 6/6 with it on both GPUs, with hipBLASLt and with `TORCH_BLAS_PREFER_HIPBLASLT=0`.
- With the fix, `KINETO_USE_DAEMON=1` and per-thread buffers (`ROCPROF_PER_THREAD_BUFFER_ENABLED=true`, confirmed active) also exit 0 under `MALLOC_PERTURB_=165`.
- `test_profiler.py`, `test_kineto.py`, `test_profiler_tree.py`: no new failures (the two `TestMetadataJsonFormatCUDA` `grid` failures fail the same way without the fix).

Pull Request resolved: pytorch#202665
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
jeffdaily added a commit to ROCm/pytorch that referenced this pull request Dec 3, 2026
pytorch#202665)

Related: pytorch#199973 (found while testing it)

Supported by @jeffdaily

No

The torch.profiler for ROCm could segfault at process exit if a profiling session was still running, because it used thread-local state that had already been destroyed.

My agent came up with this analysis, but I've read and approved it.

**Problem.** A process that exits while a `torch.profiler` session with GPU activity is still running can segfault on ROCm. On gfx90a with hipBLASLt it crashes on every exit; on other archs and on the rocBLAS path it depends on what is left in freed memory (`MALLOC_PERTURB_=165` makes those crash too).

**Cause.** `exit()` destroys the main thread's thread_locals before the static destructors of rocBLAS and hipBLASLt run. Those destructors call `hipModuleUnload`, which rocprofiler-sdk still traces, so `RocprofLogger::api_callback` indexes its destroyed `thread_local` timestamp map. Per-thread-buffer mode and the correlation-id stacks touch destroyed thread_locals the same way.

**Change.** `api_callback` keeps the ENTER timestamp in the SDK's per-call `user_data`, which rocprofiler-sdk retains from the ENTER to the EXIT phase of one call, so the map is gone (and with it a hash insert and erase per traced HIP call). The remaining per-thread state (correlation-id stacks and the per-thread buffer) moves into one `thread_local ThreadState` whose destructor sets a trivially destructible `t_threadExiting` flag before its members are destroyed; once set, `api_callback` and the correlation push/pop return early and rows go to the shared buffer. The HIP calls dropped this way are those a thread makes after its kineto state is gone: for the main thread that is inside `exit()`, where no session can collect them; a worker thread exiting during a session loses its last such calls, which were undefined behaviour before. The new `test_profiler_left_running_at_exit_cuda` exits a subprocess with the profiler running under `MALLOC_PERTURB_=165`.

**Test plan.**

gfx90a (MI250X) and gfx1100 (W7800), TheRock ROCm 10.1 (rocprofiler-sdk 1.4.1), on main 9c0fed7, A/B by reverting `RocprofLogger.cpp`. Exit codes of a script that starts a CPU+CUDA profile, runs a matmul and exits without stopping (139 = SIGSEGV):

| BLAS path | env | gfx90a without fix | gfx1100 without fix | with fix (both GPUs) |
|---|---|---|---|---|
| hipBLASLt | plain | 139 x3 | 139 x3 | 0 x15 |
| hipBLASLt | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |
| rocBLAS | plain | 0 x3 | 0 x3 | 0 x15 |
| rocBLAS | `MALLOC_PERTURB_=165` | 139 x3 | 139 x3 | 0 x15 |

The backtrace without the fix is `api_callback` -> destroyed `thread_local` map, called from `hipModuleUnload` in hipBLASLt's or rocBLAS's `TensileHost` destructor inside `exit()`.

```
python test/profiler/test_profiler.py -k test_profiler_left_running_at_exit_cuda
python test/profiler/test_profiler.py
python test/profiler/test_kineto.py
python test/profiler/test_profiler_tree.py
```

- The new test fails 6/6 without the fix (`Expected 0 but got -11`) and passes 6/6 with it on both GPUs, with hipBLASLt and with `TORCH_BLAS_PREFER_HIPBLASLT=0`.
- With the fix, `KINETO_USE_DAEMON=1` and per-thread buffers (`ROCPROF_PER_THREAD_BUFFER_ENABLED=true`, confirmed active) also exit 0 under `MALLOC_PERTURB_=165`.
- `test_profiler.py`, `test_kineto.py`, `test_profiler_tree.py`: no new failures (the two `TestMetadataJsonFormatCUDA` `grid` failures fail the same way without the fix).

Pull Request resolved: pytorch#202665
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
(cherry picked from commit 45b310d)
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Dec 3, 2026
…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

This branch was previously deployed

1 inactive deployment
bedrock — 528ab94a Deployed Oct 29, 2026 by pytorchbot via analyze #18392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/trunk Trigger trunk jobs on your pull request Merged module: rocm AMD GPU support for Pytorch open source release notes: rocm mandatorylabel triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants