DynamicQuantities.jl icon indicating copy to clipboard operation
DynamicQuantities.jl copied to clipboard

Tracking: DynamicQuantities × SciML (DiffEq) compatibility rollout

Open MilesCranmerBot opened this issue 8 months ago • 5 comments

Summary

Tracking issue for the DynamicQuantities × SciML (DiffEq stack) compatibility rollout.

Goal: land a minimal, semantically-correct patch stack across repos to support unitful ODE workflows with DynamicQuantities without type-level zero(::Type{Quantity}) assumptions.

Primary staging reference:

  • Bundle PR: https://github.com/MilesCranmerBot/dqdeq-units-bundle/pull/1

Rollout plan (2 waves)

Wave 1 (root dependency)

  • [x] DynamicQuantities.jl PR merged
  • [x] DynamicQuantities.jl release/tag published (release process started; tag pending)

Wave 2 (open downstream PRs in parallel after DQ release)

  • [x] DiffEqBase.jl PR
  • [x] OrdinaryDiffEqCore.jl PR
  • [x] OrdinaryDiffEqDifferentiation.jl PR
  • [ ] (optional) ArrayInterface.jl PR
  • [ ] (optional) DifferentiationInterface.jl PR

Dependency graph

graph TD
  DQ[DynamicQuantities.jl] --> DB[DiffEqBase.jl]
  DQ --> ODEC[OrdinaryDiffEqCore.jl]
  DQ --> ODED[OrdinaryDiffEqDifferentiation.jl]
  DB --> ODED
  DQ --> AI[ArrayInterface.jl]
  DQ --> DI[DifferentiationInterface.jl]

Notes / constraints

  • No CI-hack edits in upstream repos just to force green.
  • Keep semantic behavior aligned with Unitful/SciML expectations.
  • SciML hooks (value, unitfulvalue) for DQ types should be owned by DynamicQuantities via extension (not downstream piracy).
  • Prefer minimal per-repo diffs with explicit dependency links in each downstream PR body.

PR links

  • DynamicQuantities.jl: https://github.com/JuliaPhysics/DynamicQuantities.jl/pull/201
  • DiffEqBase.jl: https://github.com/SciML/DiffEqBase.jl/pull/1293
  • OrdinaryDiffEqCore.jl: https://github.com/SciML/OrdinaryDiffEq.jl/pull/3126
  • OrdinaryDiffEqDifferentiation.jl: https://github.com/SciML/OrdinaryDiffEq.jl/pull/3126
  • ArrayInterface.jl (optional): TBD
  • DifferentiationInterface.jl (optional): TBD

MilesCranmerBot avatar Mar 08 '26 14:03 MilesCranmerBot

Wave 1 PR opened: https://github.com/JuliaPhysics/DynamicQuantities.jl/pull/201

MilesCranmerBot avatar Mar 08 '26 15:03 MilesCranmerBot

Wave 2 downstream PRs are now open:

  • DiffEqBase: https://github.com/SciML/DiffEqBase.jl/pull/1293
  • OrdinaryDiffEq (Core + Differentiation paths): https://github.com/SciML/OrdinaryDiffEq.jl/pull/3126

Note: ODE core local test still sees registered DynamicQuantities until the new DQ tag is available; once tag propagates, this should validate on released deps instead of source overrides.

MilesCranmerBot avatar Mar 08 '26 18:03 MilesCranmerBot

@MilesCranmerBot are the ArrayInterface.jl ones actually optional? I was confused by that comment in the issue body. I remember from the stacked PR discussion we needed it, did we not? Please share any context as necessary.

MilesCranmer avatar Mar 08 '26 18:03 MilesCranmer

Yes — for the current DiffEq/OrdinaryDiffEq rollout, the ArrayInterface.jl changes are optional.

Context from the stacked/bundle PR: we initially hit failures because ArrayInterface’s constructors (, , ) allocate caches by calling things like / on the element type. For DynamicQuantities quantities that’s intentionally unsupported ( / are undefined because the dimensions are runtime).

In the final wave-2 plan we avoided relying on those ArrayInterface paths for the ODE stack by moving the unitful linear-solve/factorization handling into the SciML side (DiffEqBase ext: value-space factorization via a bridge, plus ODE init/cache tweaks in OrdinaryDiffEq). With that in place, unitful ODEs don’t require ArrayInterface to know about DQ.

So the ArrayInterface PR would be more of a hardening / ecosystem nicety: it makes not error, which could matter for other packages or less-traveled solver/cache paths. But it’s not a blocker for the main ODE compatibility wave.

(For reference, the proposed ArrayInterface ext was basically this: https://raw.githubusercontent.com/MilesCranmerBot/dqdeq-units-bundle/patches/ArrayInterface/ext/ArrayInterfaceDynamicQuantitiesExt.jl.)

MilesCranmerBot avatar Mar 08 '26 18:03 MilesCranmerBot

Follow-up (my previous comment got mangled by shell backticks):

Yes — for the current DiffEq/OrdinaryDiffEq rollout, the ArrayInterface.jl changes are optional.

Why it came up in the stacked/bundle PR: ArrayInterface’s instance constructors like lu_instance, qr_instance, svd_instance are used for cache allocation and (for some eltypes) they end up calling things like zeros(T, ...) and/or real(T) on the element type T. For DynamicQuantities quantities, zero(::Type{<:Quantity}) / oneunit(::Type{<:Quantity}) are intentionally undefined because the dimensions are runtime-stored.

Why it’s optional now: in the wave-2 plan we avoided relying on those ArrayInterface cache constructors for the main unitful-ODE paths by handling unitful linear solves/factorizations in the SciML side instead (DiffEqBase ext does value-space factorization via a DQUnitlessLU bridge; OrdinaryDiffEqCore avoids type-level identity assumptions during init/caching). With that in place, unitful ODEs don’t require an ArrayInterface patch.

So an ArrayInterface PR would be more of a hardening / ecosystem nicety: it makes ArrayInterface.lu_instance/qr_instance/svd_instance(::Matrix{<:Quantity}) not error, which could matter for other packages or less-traveled solver/cache paths, but it’s not blocking the main ODE compatibility wave.

Reference implementation from the bundle PR: https://raw.githubusercontent.com/MilesCranmerBot/dqdeq-units-bundle/patches/ArrayInterface/ext/ArrayInterfaceDynamicQuantitiesExt.jl

MilesCranmerBot avatar Mar 08 '26 18:03 MilesCranmerBot