Skip to content

feat(rocr): enforce required gfx1250 hotswap rewrites - #8387

Merged
harsh-amd merged 8 commits into
ROCm:developfrom
harsh-amd:users/harsh-amd/plat-204339-hotswap-strict-mode
Jul 14, 2026
Merged

harsh-amd merged 8 commits into
ROCm:developfrom
harsh-amd:users/harsh-amd/plat-204339-hotswap-strict-mode

Conversation

@harsh-amd

@harsh-amd harsh-amd commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add HSA_HOTSWAP_STRICT_MODE, default off, to request COMGR AMD_COMGR_HOTSWAP_REWRITE_FLAG_STRICT_MODE for non-A0 gfx1250 HotSwap rewrites.
  • Keep A0 retargeting outside ROCR strict mode; A0 continues to use the normal B0-to-A0 hotswap path and does not set the COMGR strict flag.
  • Treat required rewrites as non-fallback operations: A0 B0-to-A0 retargeting and opt-in B0 strict rewrites return HSA_STATUS_ERROR_INVALID_CODE_OBJECT if COMGR cannot produce the rewrite or the rewritten code object cannot be loaded.
  • Keep entry-trampoline selection independent from strict-mode mask workarounds, so AMD_COMGR_HOTSWAP_ENTRY_TRAMPOLINES=0 only disables entry trampolines.
  • Preserve the original fallback behavior for optional rewrites and no-decision paths.
  • Document HSA_HOTSWAP_STRICT_MODE in the runtime environment variable table.
  • Depends on [comgr][hotswap] apply gfx1250 mask workarounds llvm-project#3312 for COMGR B0 strict mask workaround support.

JIRA ID

JIRA ID : ROCM-27304
JIRA ID : PLAT-204339

Testing

  • cmake --build build-rocrtst-hotswap-review --target hotswap_rewrite -j 8
  • ctest --test-dir build-rocrtst-hotswap-review -R hotswap_rewrite --output-on-failure
  • Result: hotswap_rewrite 30/30 passed.

@therock-pr-bot

therock-pr-bot Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
🌿 Branch Name ✅ Pass —
📝 PR Title/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.

@therock-pr-bot

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Title/Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@harsh-amd
harsh-amd force-pushed the users/harsh-amd/plat-204339-hotswap-strict-mode branch from e0b638c to 06b41ab Compare July 10, 2026 01:14
@harsh-amd harsh-amd changed the title ROCR: enable strict COMGR hotswap workarounds ROCR: require strict COMGR hotswap workarounds Jul 10, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 10, 2026
@harsh-amd harsh-amd changed the title ROCR: require strict COMGR hotswap workarounds ROCR: add opt-in B0 strict COMGR hotswap mode Jul 10, 2026
@harsh-amd harsh-amd changed the title ROCR: add opt-in B0 strict COMGR hotswap mode feat(rocr): add opt-in B0 strict COMGR hotswap mode Jul 10, 2026
@harsh-amd
harsh-amd force-pushed the users/harsh-amd/plat-204339-hotswap-strict-mode branch from e0dbc89 to 6102171 Compare July 10, 2026 18:33
@harsh-amd
harsh-amd marked this pull request as ready for review July 10, 2026 18:33
@harsh-amd harsh-amd changed the title feat(rocr): add opt-in B0 strict COMGR hotswap mode feat(rocr): enforce required gfx1250 hotswap rewrites Jul 10, 2026

@shwetagkhatri shwetagkhatri 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.

New tests (HotswapRewriteDecision., HotswapRewrite.RuntimeLoadRequired*) are not registered in rocrtst/suites/test_common/test_categories.yaml. Please take a note before adding any tests to rocrtsts next time.

Comment thread projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hotswap.cpp
Comment thread projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hotswap.cpp Outdated
@powderluv

Copy link
Copy Markdown

Do you want the strict mode to work even in the B0 -> A0 path ?

@harsh-amd

Copy link
Copy Markdown
Contributor Author

These tests are built as the standalone hotswap_rewrite target and already have the quick, standard, pr, and pre-commit CTest labels. Since test_categories.yaml currently only applies to rocrtst64, adding these test names there would not affect the standalone target. Are the existing CTest labels sufficient, or should standalone targets also be added to the YAML?

@harsh-amd

Copy link
Copy Markdown
Contributor Author

Do you want the strict mode to work even in the B0 -> A0 path ?

So far we haven't found a need for this. The D# WA is always required on A0, while it can be avoided on B0. Hence currently we only have strict mode for B0 -> B0.

@shwetagkhatri

Copy link
Copy Markdown
Contributor

These tests are built as the standalone hotswap_rewrite target and already have the quick, standard, pr, and pre-commit CTest labels. Since test_categories.yaml currently only applies to rocrtst64, adding these test names there would not affect the standalone target. Are the existing CTest labels sufficient, or should standalone targets also be added to the YAML?

I see it now. Yes the existing CTest labels are the correct for standalone tests.

@shwetagkhatri
shwetagkhatri self-requested a review July 12, 2026 22:13

@shwetagkhatri shwetagkhatri 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.

LGTM.

@harsh-amd
harsh-amd force-pushed the users/harsh-amd/plat-204339-hotswap-strict-mode branch from 2e2f418 to 16e4fdc Compare July 13, 2026 13:42

@cfreeamd cfreeamd 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.

🤖 AI-assisted pre-review (for @cfreeamd)

The ROCr files look correct overall — hotswap.hpp, hotswap.cpp, and env_variables.rst all look consistent with the new rewrite_required enforcement semantics.

Comment thread projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hotswap.cpp
@harsh-amd
harsh-amd merged commit 1755df8 into ROCm:develop Jul 14, 2026
35 of 41 checks passed
rahulc-gh pushed a commit that referenced this pull request Jul 20, 2026
## Motivation

#8387 made gfx1250 B0-to-A0 HotSwap rewrites mandatory.
COMGR still rejects several valid production code objects, so those
pre-existing rewrite failures changed from loading the original object
to HSA_STATUS_ERROR_INVALID_CODE_OBJECT. The Jul-17 quick suite
consequently regressed in hiptensor, rocPRIM, rocThrust, hipSPARSE,
rocSPARSE, rocSOLVER, and hipBLASLt.

A controlled A/B used the same Jul-18 compiler, libraries, tests, GPU,
and ROCr revision, changing only the A0 rewrite-required policy. The
failing COMGR return codes remained identical, but restoring optional
fallback made the affected tests execute successfully.

## Technical Details

- Keep legacy gfx1250 B0-to-A0 retargeting best-effort when COMGR cannot
emit a rewrite.
- Fall back to the original code object if an optional A0 rewrite fails
or if its rewritten object fails to load.
- Preserve fail-closed behavior for opt-in non-A0 strict-mode rewrites.
- Update decision and runtime-load tests for both A0 failure paths.

This restores the behavior before commit 8b9a6bf. Mandatory A0
enforcement can be reconsidered after COMGR supports the production
code-object population or exposes a result that distinguishes a
proven-safe no-rewrite case from an unsupported required rewrite.

## Issue Tracking

JIRA ID: ROCM-28260

## Test Plan

- Build libhsa-runtime64 from current develop with this change.
- Build and run hotswap_gfx_query and hotswap_rewrite.
- Run the original affected quick-suite matrix on mi400 GPU 2 with
AMD_COMGR_HOTSWAP_ENTRY_TRAMPOLINES=1.
- Verify the exact production cases that previously terminated on COMGR
rewrite failure.

## Test Result

- ROCr HotSwap tests: 2/2 passed.
- hiptensor: 108/108 CTest entries passed.
- rocPRIM: 172/172 CTest entries passed.
- rocThrust: 336/336 CTest entries passed.
- hipSPARSE: 4/4 CTest entries passed.
- rocSPARSE: three shorter CTest entries passed; the native quick
executable passed 18,124/18,124 tests in 318.9 seconds. Its existing
CTest entry has a 300-second timeout.
- rocSOLVER: ffm-quick passed; the native quick executable passed
6,188/6,188 tests in 331.3 seconds. Its existing CTest entry has a
300-second timeout.
- hipBLASLt: 1/1 quick entry passed, with zero out-of-range register
diagnostics.
- No GPU fault or hang occurred.

The rocSPARSE and rocSOLVER timeout budgets are separate harness issues
exposed because the formerly crashing cases now complete.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
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: rocr-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants