Skip to content

Fix ExpMethodHigham2005 for immutable arrays with non-BLAS eltypes - #307

Merged
ChrisRackauckas merged 2 commits into
masterfrom
dw/fixedsize-dual-ldiv
Nov 15, 2026
Merged

ChrisRackauckas merged 2 commits into
masterfrom
dw/fixedsize-dual-ldiv

Conversation

@devmotion

Copy link
Copy Markdown
Member

Fixes #306.

ldiv_for_generated! (the lu! fallback for non-BLAS element types) checked aliasing with pointer_from_objref, which throws for immutable array types such as FixedSizeArray. This broke exponential!, ExpMethodHigham2005 and ExpMethodHigham2005Base on FixedSizeMatrix{<:Dual}, including under ForwardDiff.jacobian. The generated code always passes distinct cache slots, so the copy is now unconditional.

Adds a test for FixedSizeMatrix inputs: the Float64 result and Dual Jacobians for all three method variants. FixedSizeArrays becomes a test-only dependency.

🤖 Generated with Claude Code

The lu! fallback of `ldiv_for_generated!` checked aliasing with
`pointer_from_objref`, which throws for immutable array types such as
`FixedSizeArray`, e.g. under ForwardDiff. The generated code always passes
distinct cache slots, so copy unconditionally.

Fixes #306

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #307

Reviewed head: 33cc83b
Raw SHA-256: 94f1dccd22d1f1a2386b4dbb94b072870b8f4f735cc18208876625f97f8d1940
Source SHA-256: 16a85349a4956709e6674928341a0903744ab29721d4b8c0a866312e85169d45
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d173-c4ce-7c03-b765-a7bb06aa8db8
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: low (L6)
  • Verdict: MERGE
  • Reviewed head: 33cc83b

Review report

VERDICT: MERGE
Round: 2
Head: 33cc83b
Slot: 1
CI: green
Session: 01a1d173-c4ce-7c03-b765-a7bb06aa8db8

Risk

low (L6: fixes an immutable-container error; the added regression fails before and passes after, and 144 previously working results are exactly equal between base and head).

Blocking findings

None.

  • Verdict: MERGE
  • Round: 2
  • Blocking priorities: None
  • Deferred P2 issues: None

Non-blocking findings

  • Pre-existing, confirmed by running — src/exp_noalloc.jl:167: ForwardDiff.jacobian(x -> exponential!(FixedSizeMatrix(x), ExpMethodHigham2005(true)), zeros(Float32, 1, 1)) does not terminate in balancing. The unmodified base reached this call and exhausted a 60-second diagnostic timeout (exit 124); the head's broader probe remained in the same loop until interrupted. A runtime stack sample located it in GenericSchur.balance!, before the edited LU fallback. Suggested separate follow-up: handle zero primal norms in dual-valued balancing and add a termination regression. This is not introduced by this diff. Zero-matrix derivatives with balancing disabled passed all six probes.

What I ran

Independent blind review by codex-cli 0.164.0, model gpt-6-astra. No PR discussion or author rating was read. Tests used scratch archives; the supplied checkout remained clean. JULIA_DEPOT_PATH was preserved.

  • git diff origin/master...HEAD, root instructions, affected implementations and tests, and the risk criteria. Compared against merge-base 56dba586f0c9dd2bca074859464d3a30f104f781. The only production edit removes the object-pointer comparison. FixedSizeArrays is a test-only dependency; its installed license is MIT.
  • GROUP=Core julia --startup-file=no --project=scratch/head -e 'using Pkg; Pkg.test()': Julia 1.13.2; 1,144 passed, one pre-existing broken check, exit 0.
  • julia --startup-file=no --project=scratch/{base-env,probe-env} scratch/added_test.jl: the exact added testset produced 2 passes and 1 error on base (pointer_from_objref cannot be used on immutable objects), then 5/5 passes on head.
  • julia --startup-file=no --project=scratch/probe-env scratch/nonzero_probes.jl: 510/510 passed: 144 LU buffer-aliasing checks, 252 primal/Jacobian checks across all Padé branches, 108 cache-reuse checks, and six unbalanced zero-matrix derivative checks. Independent Jacobians came from the off-diagonal block of LinearAlgebra.exp([A E; 0 A]). Maximum relative Jacobian errors were 9.61e-6 (Float32) and 2.32e-15 (Float64), below precision-derived sqrt(eps(T)) bounds.
  • working_paths.jl under both saved environments: 144/144 accuracy checks passed on each across Float32, Float64, ComplexF32, ComplexF64, BigFloat and Double64; serialized outputs were 144/144 exactly equal using isequal.
  • julia --project=@runic -m Runic --check src/exp_noalloc.jl test/basictests.jl, typos src ext test docs, and git diff --check origin/master...HEAD: all passed.
  • uv run --locked python --version: Python 3.15.0, with warning that --locked has no effect outside a project. This repository has no Python project or uv.lock.
  • The original broad probe was interrupted after diagnosing the pre-existing hang; its remaining checks were run separately as reported above. All started commands have finished.

What I did not verify

  • No Julia Manifest or interpreter pin is tracked. Tests resolved the declared environment on Julia 1.13.2, then reused its saved dependency manifest for both revisions (including FixedSizeArrays 1.5.2 and ForwardDiff 1.4.7); this was not a repository-locked environment.
  • QA, documentation, other Julia versions/platforms and CUDA execution were not run. Both GPUs were occupied. Live CI was not inspected; the CI: green header is supplied review metadata.

AUTHOR_GRADE: {"task":"bugfix","score":5,"difficulty":2,"rounds":2,"author_harness":"unknown","author_model":"unknown","note":"The added regression fails on base and passes on head; Core and 510 targeted assertions pass, and 144 previously working results are exactly unchanged. The balanced-zero hang also reproduces on base. Newest commit has no Agent-Harness or Agent-Model trailers."}

Head link: 33cc83b


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6-astra
Conversation: local session 01a1d173-c4ce-7c03-b765-a7bb06aa8db8 (no session URL)

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

The latest independent review at 33cc83b rated this low risk with a MERGE verdict, and CI on that head is green. The merge tooling now refuses it with "base overlap on 'master'": master changed Project.toml after this branch was cut (aa24a59, "Bump versions for release (#308)"), and this PR changes Project.toml too.

Could you merge the current master into the branch and push? A new push needs a fresh review and CI at the new head before it can merge.


🤖 Posted by an AI agent — harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Conversation: local session 3878b54e-28f2-4a01-a176-a8f5468d1997 (no session URL)

@ChrisRackauckas
ChrisRackauckas merged commit 6d52a22 into master Nov 15, 2026
39 checks passed
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.

ExpMethodHigham2005 fails on FixedSizeMatrix with non-BLAS element types

2 participants