Skip to content

Mark matrix-free composites as non-concretizable#361

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
AshtonSBradley:fix-concretization-traits
May 4, 2026
Merged

Mark matrix-free composites as non-concretizable#361
ChrisRackauckas merged 1 commit into
SciML:masterfrom
AshtonSBradley:fix-concretization-traits

Conversation

@AshtonSBradley
Copy link
Copy Markdown
Contributor

@AshtonSBradley AshtonSBradley commented May 1, 2026

Summary

Extends the existing has_concretization trait through SciMLOperator wrappers and composites so matrix-free operators are not accidentally treated as materializable matrices.

Compositions involving matrix-free FunctionOperators now report has_concretization == false, while matrix-backed/scalar-backed wrappers continue to report true recursively.

Motivation

Downstream packages such as OrdinaryDiffEq need to know whether an operator can be safely converted to an AbstractMatrix. Without this, matrix-free compositions such as FunctionOperator \ DiagonalOperator * FunctionOperator can reach convert(AbstractMatrix, ...) and fail.

This is the first PR in a pair for SciML/OrdinaryDiffEq.jl#2078.

Paired OrdinaryDiffEq PR: SciML/OrdinaryDiffEq.jl#3588

Changes

  • Add recursive has_concretization methods for scalar operators, wrappers, composites, tensor products, and InvertibleOperator.
  • Mark common concrete inputs as concretizable.
  • Make generic matrix predicates return false for non-concretizable operators instead of falling through to concretization.
  • Add regression tests for matrix-backed and matrix-free composites.

Type stability / allocations

This is trait-only dispatch. It avoids eager matrix materialization for matrix-free operators and does not introduce per-application allocation. Existing concrete conversion behavior is preserved for matrix-backed operators.

Tests

julia --project=. -e 'using Pkg; Pkg.test()'

@AshtonSBradley
Copy link
Copy Markdown
Contributor Author

Codex was used to help prepare and validate this PR.

@AshtonSBradley AshtonSBradley marked this pull request as ready for review May 1, 2026 20:56
@ChrisRackauckas ChrisRackauckas merged commit 728f18f into SciML:master May 4, 2026
14 checks passed
@AshtonSBradley AshtonSBradley deleted the fix-concretization-traits branch May 5, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants