SIGN IN SIGN UP

clr: Fix stream capture invalidated state reset

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

## Motivation
hipStreamEndCapture on an invalidated stream was leaving the capture
state as Invalidated instead of resetting it to None. This caused any
subsequent hipStreamGetCaptureInfo call to still report Invalidated, and
hipStreamSynchronize to spuriously fail with
hipErrorStreamCaptureUnsupported — even though the failed capture had
already been ended. CUDA resets the state to None in this case.

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

## Technical Details
In hipStreamEndCapture_common (hipamd/src/hip_graph.cpp), the
early-return path for an invalidated stream called only
ReleaseCaptureGraph() (which deletes the in-progress graph object) but
did not call EndCapture(), which is responsible for resetting
captureStatus_ and all other capture state fields to their defaults. The
fix adds the EndCapture() call after ReleaseCaptureGraph(). A new test
Unit_hipStreamEndCapture_Negative_InvalidatedStateReset is
added to hipStreamEndCapture.cc covering the full sequence from the
standalone reproducer graph_failed_capture.cu.
<!-- Explain the changes along with any relevant GitHub links. -->

## JIRA ID
AIRUNTIME-2257
<!-- If applicable, mention the JIRA ID resolved by this PR (Example:
Resolves SWDEV-12345). -->
<!-- Do not post any JIRA links here. -->

## Test Plan
- Run Unit_hipStreamEndCapture_Negative_InvalidatedStateReset on AMD GPU
   (gfx942)
  - Run full GraphsTest2 suite to check for regressions
- Run graph_failed_capture.cu reproducer and verify output matches CUDA
  behavior
<!-- Explain any relevant testing done to verify this PR. -->

## Test Result
- graph_failed_capture.cu reproducer output now matches CUDA — After
  StreamEndCapture 1/2 both show None, Sync stream after failed capture
  returns no error
  - Unit_hipStreamEndCapture_Negative_InvalidatedStateReset passes
  - No regressions in GraphsTest2
<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
[rocm-systems] ROCm/rocm-systems#6509 (commit b8c378e)
G
Godavarthy Surya, Anusha committed
fa77aedd3cd2301f760e3132fca780adb85fa8ec
Parent: 6dec1ec
Committed by systems-assistant[bot] <systems-assistant[bot]@users.noreply.github.com> on 5/30/2026, 11:29:05 PM