Use the fast path for FixedSizeArrays #127
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 390 lines diff across 4 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.357
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #127"
general
weight: 0.35
oscardssmith
Fixes #126.
fast_materialize!,fast_materializeandfast_materialize_threadedused the fast path only forDefaultArrayStyle.FixedSizeArraydefines its ownFixedSizeArrayBroadcastStyle, but only so that broadcasting returns aFixedSizeArray, so@..fell back to Base'smaterialize!, including theunaliaschecks.Changes
use_fast_broadcast(S)trait first. Within the fast path, any styleS <: AbstractArrayStyle{0}is materialized to a scalar, matching Base'scopy(::Broadcasted{<:AbstractArrayStyle{0}}). The scalar is computed once, viaonly(bc), orfill!(dst, bc[1])in-place._broadcasted's collapsing of nested 0-dim broadcasts uses the same rule.- Before this change, that 0-dim branch was hard-coded to
DefaultArrayStyle{0}, souse_fast_broadcast(DefaultArrayStyle{0})is nowtrue.- Styles that don't opt in (e.g. GPU arrays, which override
copyfor 0-dim broadcasts to avoid scalar indexing) still go throughmaterialize/materialize!.FixedSizeArraysExtopts in everyFixedSizeArrayBroadcastStyle, including{0}. A 0-dimFixedSizeArraynow behaves like a 0-dimArrayunder@... Previously it fell back to Base, which evaluates the broadcast once per destination element.use_fast_broadcastnow has a docstring.Arrays, matrices with transposed vectors,DimensionMismatch, and 0-dim broadcasts. The 0-dim tests check the result types and that the function is called once, for bothArrayandFixedSizeArray. The QA environment loads FixedSizeArrays so the new extension gets checked.Behavior change: dynamic broadcasts with
FixedSizeArrays (e.g. a1×nFixedSizeMatrixagainst anm×none) now throwDimensionMismatch, as they already do forArrays.RecursiveArrayTools:
use_fast_broadcast(DefaultArrayStyle{0})wasfalseto keep 0-dim broadcasts away from RecursiveArrayTools' FastBroadcast extension, which (like RecursiveArrayTools' broadcasting into aVectorOfArrayin general) mishandles arguments with fewer dimensions than theVectorOfArray: SciML/RecursiveArrayTools.jl#680.@..never passes 0-dim broadcasts tofast_materialize!(_broadcastedcollapses them to a scalar first), so@.. voa = 3 * rwithr = Ref(2.0)orr = fill(2.0)works on this branch, as on master. Only direct calls of the internalfast_materialize!with a 0-dimBroadcastedwould now reach that bug.Benchmark
This is the benchmark from #126, run without the manual opt-in (Julia 1.13.1, one thread):
| eltype | n |
Vector|FixedSizeVector||---|---|---|---|
| Float64 | 3 | 4.7 ns | 4.4 ns |
| Float64 | 8 | 3.6 ns | 3.9 ns |
| Float64 | 100 | 15.9 ns | 15.7 ns |
|
Dual{…,2}| 3 | 4.7 ns | 4.7 ns ||
Dual{…,2}| 8 | 7.3 ns | 7.3 ns ||
Dual{…,2}| 100 | 61.2 ns | 62.0 ns |Before this change,
FixedSizeVectortook 7.4–11.1 ns at n = 3 and 8.Core and QA tests pass locally.
🤖 Generated with Claude Code