Skip to content

fix(rocalution): fall back to host when rocBLAS/rocSPARSE handle creation fails - #13230

Merged
ntrost57 merged 2 commits into
developfrom
users/ntrost/rocalution/fix/hip-init-handle-failure
Oct 8, 2026
Merged

ntrost57 merged 2 commits into
developfrom
users/ntrost/rocalution/fix/hip-init-handle-failure

Conversation

@ntrost57

@ntrost57 ntrost57 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

Under ASAN, rocalution-test crashes at startup on gfx950 before any test
runs. HIP reports that device 0 cannot create the rocBLAS/rocSPARSE context,
yet rocALUTION still reports the HIP backend as available, and
info_rocalution() then crashes inside rocsparse_get_version with an
invalid handle (0xbebebebe..., ASAN's fill pattern for uninitialized heap
memory).

Technical Details

rocalution_init_hip() decided whether initialization succeeded by checking
HIP_dev == -1 after the device loop. If the device was preset through
set_device_rocalution(), as rocalution-test does, HIP_dev is already set
before init. A failure in rocblas_create_handle or rocsparse_create_handle
then went unnoticed: init returned true, and the backend kept the
uninitialized handles. info_rocalution() passed the rocSPARSE handle to
rocsparse_get_version, which crashed, and stop_rocalution() would also
have tried to destroy both handles.

Initialization now records whether the handles were created in a local flag,
so a failure falls back to the host backend as intended. In addition, if
rocBLAS handle creation succeeds but rocSPARSE handle creation fails, the
rocBLAS handle is destroyed instead of leaked.

This PR does not address why handle creation fails in the ASAN
configuration in the first place; it only makes rocALUTION handle that
failure correctly.

JIRA ID : ROCM-32358

…tion fails

rocalution_init_hip() decided whether initialization succeeded by
checking HIP_dev == -1. When the device was preset through
set_device_rocalution() (as rocalution-test does), HIP_dev was already
set, so a failure in rocblas_create_handle or rocsparse_create_handle
went unnoticed. The backend then reported HIP as available with
uninitialized handles, and info_rocalution() passed an invalid handle to
rocsparse_get_version, which crashed (SEGV under ASAN).

Track handle creation with a local flag instead, so a failure falls back
to the host backend. Also destroy a rocBLAS handle that was created when
the subsequent rocSPARSE handle creation fails, so it is not leaked.

JIRA ID : ROCM-32358

Co-authored-by: Cursor <cursoragent@cursor.com>
JIRA ID : ROCM-32358

Co-authored-by: Cursor <cursoragent@cursor.com>
@therock-pr-bot

therock-pr-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocalution/src/base/hip/backend_hip.cpp; no test file found
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

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

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@ntrost57
ntrost57 merged commit 3e5ea29 into develop Oct 8, 2026
138 of 145 checks passed
@ntrost57
ntrost57 deleted the users/ntrost/rocalution/fix/hip-init-handle-failure branch October 8, 2026 06:46
@assistant-librarian

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.

2 participants