Repository navigation
fix(rocRAND): fix Sobol rightmost_zero_bit at period wrap - #13327
Merged
Merged
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
Pre-commit check failed⛔ pre-commit failed Please run locally:
This repo uses |
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (57.42%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #13327 +/- ##
===========================================
- Coverage 72.14% 72.14% -0.00%
===========================================
Files 2868 2868
Lines 473296 473300 +4
Branches 69809 69811 +2
===========================================
Hits 341437 341437
- Misses 108152 108154 +2
- Partials 23707 23709 +2
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
JIRA ID : ROCM-31895
## Motivation
AddressSanitizer reports a stack-buffer-overflow in Sobol32 host
generation (int_test_large/Sobol32_*, RUN_SLOW_TESTS=1). The same root
cause produces silently wrong values on device for Sobol32, Scrambled
Sobol32, Sobol64 and Scrambled Sobol64 whenever a single generate() call
crosses the end of the sequence period (2^32 / 2^64).
## Technical Details
rightmost_zero_bit(x) has no valid result when x is all ones, which
happens when the engine advances from index 2^N-1 to 0:
- host: the loop returned 32/64, causing an out-of-bounds read of
vectors[32]/vectors[64] in discard_state_power2 (the ASan finding)
Wrapping from 2^N-1 to 0 flips only the top bit of the Gray code, so the
correct index is 31 (Sobol32) / 63 (Sobol64). rightmost_zero_bit now
returns that on host and device. Results for all other inputs are
unchanged, so output before the wrap is bit-identical.
## Test Plan
- Build with BUILD_ADDRESS_SANITIZER=ON (gfx90a:xnack+), RUN_SLOW_TESTS=1
- test_rocrand_host: int_test_large/Sobol32_* and int_test_large/Sobol64_*
- Full test_rocrand_host
## Test Result
- int_test_large/Sobol32_*: 4/4 pass, no ASan findings (previously
aborted with stack-buffer-overflow); int_test_large/Sobol64_*: pass
- ctest Sobol suites: 8/8 pass; full test_rocrand_host: pass
## Submission Checklist
- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
amd-mcieslak
force-pushed
the
users/mcieslak/rocrand_fix_sobol_wrap
branch
from
October 8, 2026 22:28
1b3528d to
a3d692d
Compare
|
🎉 All checks passed! This PR is ready for review. |
assistant-librarian Bot
pushed a commit
to ROCm/rocRAND
that referenced
this pull request
Oct 9, 2026
fix(rocRAND): fix Sobol rightmost_zero_bit at period wrap (#13327) JIRA ID : ROCM-31895 ## Motivation AddressSanitizer reports a stack-buffer-overflow in Sobol32 host generation (int_test_large/Sobol32_*, RUN_SLOW_TESTS=1). The same root cause produces silently wrong values on device for Sobol32, Scrambled Sobol32, Sobol64 and Scrambled Sobol64 whenever a single generate() call crosses the end of the sequence period (2^32 / 2^64). ## Technical Details rightmost_zero_bit(x) has no valid result when x is all ones, which happens when the engine advances from index 2^N-1 to 0: - host: the loop returned 32/64, causing an out-of-bounds read of vectors[32]/vectors[64] in discard_state_power2 (the ASan finding) Wrapping from 2^N-1 to 0 flips only the top bit of the Gray code, so the correct index is 31 (Sobol32) / 63 (Sobol64). rightmost_zero_bit now returns that on host and device. Results for all other inputs are unchanged, so output before the wrap is bit-identical. ## Test Plan - Build with BUILD_ADDRESS_SANITIZER=ON (gfx90a:xnack+), RUN_SLOW_TESTS=1 - test_rocrand_host: int_test_large/Sobol32_* and int_test_large/Sobol64_* - Full test_rocrand_host ## Test Result - int_test_large/Sobol32_*: 4/4 pass, no ASan findings (previously aborted with stack-buffer-overflow) - int_test_large/Sobol64_*: pass - ctest Sobol suites: 8/8 pass - full test_rocrand_host: pass ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
Contributor
TheRock Submodule Bump ActivityNewest first
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA ID : ROCM-31895
Motivation
AddressSanitizer reports a stack-buffer-overflow in Sobol32 host generation (int_test_large/Sobol32_*, RUN_SLOW_TESTS=1). The same root cause produces silently wrong values on device for Sobol32, Scrambled Sobol32, Sobol64 and Scrambled Sobol64 whenever a single generate() call crosses the end of the sequence period (2^32 / 2^64).
Technical Details
rightmost_zero_bit(x) has no valid result when x is all ones, which happens when the engine advances from index 2^N-1 to 0:
Wrapping from 2^N-1 to 0 flips only the top bit of the Gray code, so the correct index is 31 (Sobol32) / 63 (Sobol64). rightmost_zero_bit now returns that on host and device. Results for all other inputs are unchanged, so output before the wrap is bit-identical.
Test Plan
Test Result
Submission Checklist