RVV: Fix ReorderWidenMulAccumulate for fractional LMUL #3382
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 241 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.328
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3382"
general
weight: 0.35
jan-wassenberg
Fixes #3305
Addresses #3281
Summary
Fix ReorderWidenMulAccumulate on RVV for fractional LMUL.
For real e32,mf2, the native vector type is also used to represent virtual e32,mf4. The previous implementation could leave state required by RearrangeToOddPlusEven in inactive tail lanes. After a Store/Load round trip, those tail lanes are no longer guaranteed to retain the required values, which can change the result.
This change keeps all persistent state required by RearrangeToOddPlusEven in active lanes.
For the real e32,mf2 case, the widening products are first computed in natural order:
[P0 | P1 | P2 | P3]
They are then stored using the block-transposed representation:
sum0 = [P0 | P2]
sum1 = [P1 | P3]
The implementation uses native vwmul.vv / vwmulu.vv followed by vcompress to construct the two accumulators.
This also avoids the slide-based rearrangement considered for this path and addresses the RVV performance concern in #3281.
Testing
Real RVV hardware
Tested on an X60 RISC-V system:
widen_mul_test: 12/12 tests passed
Both signed and unsigned paths were checked in the generated assembly:
int16_t -> int32_t: vwmul.vv + vcompress.vm
uint16_t -> uint32_t: vwmulu.vv + vcompress.vm
Multiple VLENs
TestAllReorderWidenMulAccumulate/RVV passes under QEMU with:
VLEN=128 PASS
VLEN=256 PASS
VLEN=512 PASS
VLEN=1024 PASS
A separate BF16 failure in TestAllRearrangeToOddPlusEven/RVV at VLEN=1024 is also reproducible on unmodified upstream/master and is unrelated to this change.
Performance
Microbenchmarks were run on the X60 with the benchmark pinned to a single CPU. The operands were changed on every iteration to prevent loop-invariant hoisting.
Average over 10 runs:
Type | upstream | this change
uint16_t -> uint32_t | 9.413 ns/iter | 9.413 ns/iter
int16_t -> int32_t | 9.415 ns/iter | 9.416 ns/iter