fix(rocrand): MT19937 allocating 4x more memory than needed #16687
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 191 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.315
Real PR Conversation Timeline
1 comments
"Review active on #16687"
general
weight: 0.35
amd-jmahovsky
Motivation
system_type::alloc(&ptr, n)takes a number of elements. The device version callshipMalloc(ptr, sizeof(T) n)and the host version callsnew T[n]. MT19937'sinit()passed byte counts instead, so three allocations weresizeof(unsigned int)(4x) larger than needed. This happened on every initialization, which includes every seed or ordering change:m_engines)d_engines)d_mt19937_jump)JIRA ID : AIPRIMS-287
Technical Details
m_enginesandd_enginesnow passm_generator_count mt19937_constants::ninstead of the same value times sizeof(unsigned int).now passesstd::size(rocrand_h_mt19937_jump), the array's element count, instead ofsizeof(rocrand_h_mt19937_jump), its size in bytes. Thememcpythat follows still usessizeof, becausememcpytakes bytes.was already given a correct byte count and is unchanged.Generated numbers don't change; only the allocation sizes do.
Test Plan
Ran the existing tests on gfx90a. No new test: the bug only wasted memory, and the size of an internal allocation can't be checked through the public API.
Test Result
All passed: 34, 47 and 99 tests respectively.
Submission Checklist