Skip to content

Avoid ambiguous reverse promotion in DiffCache - #201

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-sct-bigfloat-cache
Draft

Avoid ambiguous reverse promotion in DiffCache#201
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-sct-bigfloat-cache

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Ignore until reviewed by @ChrisRackauckas.

What changed

get_tmp now asks the requested element type's public Base.promote_rule first. When that type has no rule, it falls back to the existing symmetric promote_type check. This preserves the primal buffer selection for ordinary inputs while avoiding an ambiguous reverse promotion rule for BigFloat and SparseConnectivityTracer.Dual.

The regression test covers both DiffCache and FixedSizeDiffCache through SparseConnectivityTracer's public jacobian_eltype API. No SparseConnectivityTracer dependency or internal API is added.

Root cause

PreallocationTools v1.5.0 moved sparse-tracer handling into the generic cache path. promote_type(BigFloat, SparseConnectivityTracer.Dual{BigFloat, ...}) asks both promotion directions; its reverse query is ambiguous between Base's BigFloat rule and SparseConnectivityTracer's Dual rule.

The boundary bisects to a032da6 (the merge of #198). PreallocationTools v1.4.1 passes the standalone control; v1.5.0 fails.

Failing before

$ env JULIA_DEPOT_PATH=$DEPOT JULIA_PKG_PRECOMPILE_AUTO=0 julia +1.12 --project=. -e 'using Pkg; Pkg.test()'
BigFloat cache: Error During Test
MethodError: promote_rule(::Type{BigFloat}, ::Type{SparseConnectivityTracer.Dual{BigFloat, ...}}) is ambiguous.
Test Summary:             | Pass  Error  Total
Sparse Connectivity Tests |   22      1     23
ERROR: Package PreallocationTools errored during testing

The unmodified BoundaryValueDiffEq master Misc group reproduces the downstream failure with PreallocationTools v1.5.0 and SparseConnectivityTracer v1.2.2:

$ env JULIA_DEPOT_PATH=$DEPOT JULIA_PKG_PRECOMPILE_AUTO=0 GROUP=Misc julia +1.12 --project=. -e 'using Pkg; Pkg.test()'
Test Summary:  | Pass  Error  Total
BigFloat Tests |    3      2      5
ERROR: Package BoundaryValueDiffEq errored during testing

Passing after

$ env JULIA_DEPOT_PATH=$DEPOT JULIA_PKG_PRECOMPILE_AUTO=0 julia +1.12 --project=. -e 'using Pkg; Pkg.test()'
Test Summary:                           | Pass  Total   Time
DiffCache with SparseConnectivityTracer |   26     26  11.6s
Test Summary:  | Pass  Total     Time
Enzyme Support |   26     26  3m46.3s
Test Summary:               | Pass  Total  Time
Allocation Regression Tests |   27     27  3.3s
Testing PreallocationTools tests passed

The full Core group also passed Developer Interface (16/16), DiffCache Dispatch (82 pass, 10 existing broken), ODE (7/7), Resizing (64/64), Nested Duals (4/4), Sparsity Support (4/4), LazyBufferCache (2/2), GeneralLazyBufferCache (11/11), and Zero/Copy/Fill Dispatches (66/66).

The same full downstream group passes with the branch developed into BoundaryValueDiffEq:

$ env JULIA_DEPOT_PATH=$DEPOT JULIA_PKG_PRECOMPILE_AUTO=0 GROUP=Misc julia +1.12 --project=. -e 'using Pkg; Pkg.develop(path="../prealloc"); Pkg.test()'
Test Summary:    | Pass  Total      Time
Adaptivity Tests |   19     19  12m48.5s
Test Summary:          | Pass  Broken  Total     Time
Non-Vector Input Tests |   24       4     28  9m01.8s
Test Summary:  | Pass  Total     Time
BigFloat Tests |    7      7  6m09.7s
Test Summary: | Pass  Total     Time
Verbose Tests |   78     78  8m59.7s
Test Summary:   | Pass  Total     Time
Manifolds Tests |   11     11  4m22.8s
Testing BoundaryValueDiffEq tests passed

Initial Guess (6/6), Scalar BVP (4/4), Default Solvers (2/2), Public API Package Splits (12/12), and the zero-assertion Type Stability run also completed successfully.

Other checks

$ env JULIA_DEPOT_PATH=$DEPOT JULIA_PKG_PRECOMPILE_AUTO=0 GROUP=QA julia +1.12 --project=. -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total     Time
QA            |   27     27  1m18.9s
Testing PreallocationTools tests passed

$ julia +1.12 --project=/home/crackauc/.julia/environments/runic -m Runic --check .
$ git diff | typos -
$ git diff --check

Runic, typos, and git diff --check exit successfully with no output.

Documentation was not built because this changes no public API, docstring, or documentation. GPU-specific paths were not run. The BoundaryValueDiffEq Misc group is the downstream integration coverage.

CI context

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
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