Adapt the memory backend of a `FixedSizeArray` for adaptors that are not array types #235
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 323 lines diff across 4 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
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #235"
general
weight: 0.35
giordano
Problem
With Adapt.jl loaded,
adapt(to, a)applies only the storage rule oftoto aFixedSizeArrayaas a whole:That is what we want for array types (
adapt(CuArray, a)is aCuArray), but adaptors which are not array types usually have storage rules only for the arrays they know. In particular, the adaptors that convert the arguments of a GPU kernel turn aVectororCuVectorinto anisbitsdevice array and fall back to the identity for everything else. AFixedSizeArraytherefore reaches the kernel unchanged and compilation fails. This shows up in trixi-framework/Trixi.jl#3357 with the POCL backend of KernelAbstractions.jl:Arrays with static dimensions are not affected, since their rule already adapts the memory backend and wraps it again. In the same kernel call the solution array (static dimensions) is converted correctly.
Change
The conversion as a whole is restricted to adaptors which are array types (
to::Type{<:AbstractArray}). All other adaptors now use the rule ofFixedSizeArrayDims: adapt the memory backend and wrap it again, with and without static dimensions.Unchanged:
adapt(Array, a),adapt(CuArray, a), etc. still convert aFixedSizeArrayas a whole, andadapt(FixedSizeArray, x)behaves as before.Changed: an adaptor that is not an array type but has a storage rule matching a
FixedSizeArrayas a whole (e.g. one forAbstractArray) is now given the memory backend instead, so the result is aFixedSizeArrayover the adapted vector rather than whatever that rule returned for the whole array.Testing
Vector, returning anisbitsdevice vector), for arrays with and without static dimensions and inside aTranspose.The CHANGELOG entry is under a new "Unreleased" heading; I did not bump the version.
This PR was prepared with the assistance of Claude Code.
🤖 Generated with Claude Code