← Back to Pull requests

Adapt the memory backend of a `FixedSizeArray` for adaptors that are not array types #235

Open
unknown opened this pull request with 323 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 26, 2026 09:52 UTC
Author

Problem

With Adapt.jl loaded, adapt(to, a) applies only the storage rule of to to a FixedSizeArray a as a whole:

Adapt.adapt_structure(to, a::FixedSizeArray) = Adapt.adapt_storage(to, a)

That is what we want for array types (adapt(CuArray, a) is a CuArray), 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 a Vector or CuVector into an isbits device array and fall back to the identity for everything else. A FixedSizeArray therefore reaches the kernel unchanged and compilation fails. This shows up in trixi-framework/Trixi.jl#3357 with the POCL backend of KernelAbstractions.jl:

KernelError: passing non-bitstype argument
Argument 8 to your kernel function is of type FixedSizeArrays.FixedSizeArrayDims{Float64, 4, NTuple{4, Int64}, Vector{Float64}}, which is not a bitstype:
  .mem is of type Vector{Float64} which is not isbits.

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 of FixedSizeArrayDims: adapt the memory backend and wrap it again, with and without static dimensions.

Unchanged: adapt(Array, a), adapt(CuArray, a), etc. still convert a FixedSizeArray as a whole, and adapt(FixedSizeArray, x) behaves as before.

Changed: an adaptor that is not an array type but has a storage rule matching a FixedSizeArray as a whole (e.g. one for AbstractArray) is now given the memory backend instead, so the result is a FixedSizeArray over the adapted vector rather than whatever that rule returned for the whole array.

Testing

  • New tests with a small kernel-like adaptor (storage rule only for Vector, returning an isbits device vector), for arrays with and without static dimensions and inside a Transpose.

  • The package tests pass locally on Julia 1.14.0-beta1.

  • With this branch, the KernelAbstractions.jl test items of Trixi.jl that fail in trixi-framework/Trixi.jl#3357 compile and run their kernels again (checked for two of them, with the POCL backend).
  • 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

    Diff: 323 lines (+242 / -81) across 4 files Reviewer: giordano Review duration: 6301m
    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
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%