Skip to content

fix(rocprofiler-sdk): decline range replay when kernel arguments point outside the snapshot - #14030

Open
minseobshin11 wants to merge 1 commit into
users/vkale/range-replay-v1from
users/mishin/range-replay-memory-outside-snapshot
Open

minseobshin11 wants to merge 1 commit into
users/vkale/range-replay-v1from
users/mishin/range-replay-memory-outside-snapshot

Conversation

@minseobshin11

@minseobshin11 minseobshin11 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Range replay restores the coarse-grained device snapshot before every pass. The documented scope already excludes unified/managed, host, fine-grained and virtual-memory-mapped allocations, and said such ranges are "not detected — see the divergence check". But the divergence check hashes only snapshot regions, so it cannot see this memory. Those ranges replayed with REPLAYED, and a kernel writing that memory applied its writes once per pass. A counter incremented 4 times in the application's run read 10 after 3 passes, with divergence 0.

Technical Details

When a dispatch is recorded inside a range, its explicit kernel arguments are checked. The trailing 256-byte HIP hidden-argument block is skipped. An argument that points at GPU-writable memory outside the snapshot declines the range with the existing SNAPSHOT_FAILED, and a warning names the memory kind. This covers host-pinned, managed, locked, fine-grained, another agent's memory, virtual-memory mappings, and pageable host memory when the runtime reports XNACK enabled. The application's own run is unchanged.

What the opt-in divergence check (ROCPROF_RANGE_REPLAY_VERIFY=1) catches on the PR head, compared with this guard:

Case Divergence check (PR head) This guard
Kernel writes hipHostMalloc memory Missed (divergence 0, result 10 instead of 4) Declines
Kernel writes managed memory Missed (divergence 0) Declines
Kernel writes hipMallocAsync memory Missed (divergence 0) Declines
Kernel writes fine-grained device memory Missed (divergence 0) Declines
Kernel writes another GPU's memory Missed: not in this agent's snapshot Declines
OpenMP zero-copy under XNACK Missed (divergence 0, application check fails) Declines
Small hipMemcpyAsync into pinned host memory Missed: host memory is not hashed Declines
A wrong untracked value later written into a hipMalloc buffer Caught: that buffer's hash differs Declines, if the untracked memory was a kernel argument
Pointer to untracked memory stored inside another buffer Caught only if the effect reaches snapshot memory Not seen
Host recomputes an input inside the range Caught only if the effect reaches snapshot memory Not seen

The first six rows were measured with the check on. The others follow from what each check reads. The guard acts before any replayed pass. The divergence check reports after the passes, when the application's result is already wrong, so it remains the diagnostic for what the guard cannot see.

No new public status, environment variable, kernel replay change, or memory tracker change. The SNAPSHOT_FAILED comment, the header warning and the conceptual docs describe the check.

Device-side malloc replays correctly: HIP's device heap is allocated through the tracked allocator, so the snapshot covers it. Growing the heap inside a range declines ALLOCATION_CHANGED_IN_RANGE through the existing allocation check.

Test Plan

  • New GPU-free unit test range-replay-untracked-memory-test: memory classification, hidden-argument skip, and decline decisions.
  • Replay CTests on MI300X (gfx942).
  • Small HIP programs that increment a buffer inside a range, run with 3 passes and checked against the run without the tool: hipMalloc, hipHostMalloc, hipMallocManaged, hipMallocAsync, fine-grained and uncached device memory, another GPU's fine-grained memory, small hipMemcpyAsync in both directions, device malloc within and beyond the initial heap, and OpenMP zero-copy under XNACK.
  • 12-application correctness matrix (HIP and OpenMP builds of BabelStream, XSBench, RSBench and miniBUDE).

Test Result

Case PR head This change
hipMalloc Replays, correct Replays, correct
Device malloc within HIP's heap Replays, correct Replays, correct
Device malloc that grows the heap Not run Declines ALLOCATION_CHANGED_IN_RANGE, correct
hipHostMalloc, hipMallocManaged, hipMallocAsync Replays, wrong Declines, correct
Fine-grained and uncached device memory Replays, wrong Declines, correct
Fine-grained memory on another GPU Replays, wrong Declines, correct
Small hipMemcpyAsync (4 KiB, both directions, pageable and pinned) Replays; pinned device-to-host wrong Declines, correct
OpenMP zero-copy under XNACK Replays, application check fails Declines, application check passes
OpenMP device malloc Process aborts after the 60 s drain timeout Same, unchanged
PyTorch inference step, 2 or more passes Process aborts with a GPU fault Same, unchanged
  • Replay CTests: 189 of 189 pass. The kernel-replay validate tests flake under ctest -j8 on the PR head too and pass when rerun alone.
  • Application matrix: identical statuses to the PR head, except BabelStream (HIP) with dot, which now declines because its partial-sum buffer is hipHostMalloc memory. Every application's own check passes.
  • The two aborts reproduce on the PR head and are not addressed here.

Submission Checklist

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation organization: ROCm project: rocprofiler-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant