Skip to content

fix(hrr): keep graph landing buffers stable until teardown - #14156

Merged
danielbolsson merged 4 commits into
developfrom
users/danielbolsson/hrr-3067
Oct 27, 2026
Merged

danielbolsson merged 4 commits into
developfrom
users/danielbolsson/hrr-3067

Conversation

@danielbolsson

@danielbolsson danielbolsson commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

JIRA ID : AIRUNTIME-3067

Motivation

Replay gave each graph memcpy node a pointer into a std::vector<uint8_t> keyed by the recorded host address. When a later event asked for a larger buffer for the same key, resize reallocated the vector. The earlier node still held the old pointer, so a later graph launch wrote into freed host memory.

Technical Details

PlaybackContext::host_landing_buffer (projects/hrr/playback/hip_playback.h) now never moves or frees a block it has handed out. A larger request allocates a new block and retires the outgrown one instead of freeing it. Replay treats hipGraphDestroy and hipGraphExecDestroy as no-ops and destroys its graphs only at teardown, so blocks live as long as the context, which is as long as any graph can be launched. Both blocks are resident, so a grown block is charged to the host budget whole (it was growth-only before). A refused charge or failed allocation leaves the buffer as it was.

Covers every caller: the from-symbol graph handlers and their exec forms all go through this function.

Issue Tracking

JIRA ID : AIRUNTIME-3067

Test Plan

  • Unit_HRR_HostBudget_LandingBufferPointerSurvivesGrowth (new, in hrr-handler-tests, AddressSanitizer): writes through a pointer taken before one growth of the same key.
  • Unit_HRR_HostBudget_LandingBufferChargesWholeBlock (renamed from ...ChargesGrowthOnly): updated for whole-block charging and for a refusal leaving the buffer unchanged.
  • Negative control: with the old hip_playback.h the new test aborts with an ASAN heap-use-after-free WRITE.
  • No GPU needed.

Test Result

On gbt350 (private ROCr + capture CLR + HRR, HIP_VISIBLE_DEVICES=4,5, tree 922aa52e4e7c): hrr-unit-tests 78 cases, 1487 assertions pass; hrr-handler-tests 31 cases, 242 assertions pass; integration 147 pass, 1 known failure (Unit_HRR_SecureExecIgnoresCaptureOutput, AIRUNTIME-3074). Negative control (outgrown block freed instead of retired) fails the growth test with an ASAN heap-use-after-free.

Submission Checklist

A graph memcpy node keeps the host pointer it was given, but
host_landing_buffer resized a std::vector per recorded key, so a later
event asking for a larger buffer for the same key reallocated it and left
earlier nodes pointing at freed memory. A later graph launch then wrote
into freed host memory.

A grown buffer now gets a new block; the outgrown block is retired, not
freed. Replay does not replay hipGraphDestroy/hipGraphExecDestroy (no-ops)
and destroys its graphs at teardown, so blocks live as long as the context.
Both blocks are resident, so a grown block is charged to the host budget
whole.

Tracks AIRUNTIME-3067.
@danielbolsson
danielbolsson requested a review from a team as a code owner October 23, 2026 15:29
Copilot AI balanced review requested due to automatic review settings October 23, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@andraghetti andraghetti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MI350 gate on 21819a5: no new failures.

Comment thread projects/hrr/playback/hip_playback.h Resolved
Comment thread projects/hrr/playback/hip_playback.h Resolved
Comment thread projects/hrr/playback/hip_playback.h Resolved
…IRUNTIME-3067)

sz is already under the host budget cap and the zero-fill touches every page, so
the nothrow check could not fire; plain make_unique matches develop's resize.
The growth test keeps the one assertion that fails without the fix (a write
through the pre-growth pointer), and the comments say only what the code does not.
Comment thread projects/hrr/playback/hip_playback.h Resolved
hip_playback.h only needed it for std::nothrow, removed with the nothrow
branch. AIRUNTIME-3067
@danielbolsson
danielbolsson merged commit 8c81fa0 into develop Oct 27, 2026
75 of 76 checks passed
@danielbolsson
danielbolsson deleted the users/danielbolsson/hrr-3067 branch October 27, 2026 15:20
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants