Repository navigation
Reuse KrylovJL workspace across same-size A updates - #1378
Conversation
Rebuilding the Krylov workspace on every cache.A= forces GMRES to re-grow its basis (tens of MB per update). Reuse when the public workspace type and m/n (and solution storage type) still match; rebuild on size or eltype change. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent 2026.10.01-14929f9 Agent-Model: unknown (Cursor auto) Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/linsolve/pr-krylov-ws/log.txt on amdci2
Reuse was keeping init's memory=1 / default-window workspace for non-Matrix A, so GMRES(k) ran as GMRES(1) and MINRES ignored window. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent CLI Agent-Model: auto
Keep block workspace output independent of caller storage and rebuild fixed subspaces when their requested size changes. Cover aliased block output, decreasing restart intervals, and limited-memory orthogonalization methods. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/linsolve/pr-krylov-ws/log-codex.txt on amdci2
Rebuild incompatible partitioned workspaces, support rectangular solution storage rebinding, and recover safely after interrupted warm starts. Cover rectangular, repartitioned, and exception/retry solves and document the workspace lifecycle. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.164.0 Agent-Model: gpt-6.1-sol Agent-Session: local fixer job SciML__LinearSolve.jl__1378 (no session URL)
init_cacheval for an ArrayPartition right-hand side builds
Krylov.KrylovConstructor(b, u), where b sizes the range vectors and u
the domain ones. Krylov <= 0.10.3 defines KrylovConstructor{S} with a
single storage type, so it only accepts vm/vn/vm_empty/vn_empty sharing
one type; a rectangular operator (default flat u) or a u0 partitioned
with a different layout hits a MethodError at init. Krylov 0.10.4 added
KrylovConstructor{Sm,Sn} ("Allow vm and vn to be of different types"),
which is the lowest registered version providing the needed method, so
raise the compat lower bound to it.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Devin <noreply@cognition.ai>
Agent-Harness: Devin CLI 3000.11.228
Agent-Model: swe-2-high
Agent-Session: local fixer job SciML__LinearSolve.jl__1378 (no session URL)
The Reactant group env carries no CUDA.jl, so its julia_callbacks only work when XLA hands them host buffers. The self-hosted runner pool includes GPU nodes where Reactant selects the CUDA backend and passes device buffers to the callback trampoline; Reactant wraps those only when its CUDA extension is loaded, and errors otherwise. Pin the CPU client so the group exercises the host-buffer path it is set up for on whichever runner it lands. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Devin <noreply@cognition.ai> Agent-Harness: Devin CLI 3000.11.228 Agent-Model: swe-2-high Agent-Session: local fixer job SciML__LinearSolve.jl__1378 (no session URL)
Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a196e2-3b40-76c0-84b5-8f724cc667e6, reviewed head 30a36a4
Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands. Summary: Reuses compatible Krylov workspaces across matrix updates and rebuilds incompatible or interrupted workspaces, with regression coverage and CPU selection for Reactant tests. The target matches the live head; local accuracy and regression checks pass, with one outstanding downstream CI issue. Blast radius: Explicit KrylovJL vector and block workspaces, first solves for non-Matrix operators, A updates, restart memory, error windows, solution rebinding, and retries after interrupted warm starts. ArrayPartition RHS updates deliberately rebuild. DefaultLinearSolver containers fail the workspace-type check and retain their reconstruction behavior. Reactant tests select CPU without changing their assertions. Evidence: Blind assessment sealed in INITIAL.md and INITIAL.sha256 before author context. Julia 1.13.2 with Krylov 0.10.12: head regression file 121/121, exit 0; identical file against merge-base c7ff3be gives 107 passes, 12 failures and 2 missing-helper errors, exit 1; independent probes 51/51, exit 0. Core, AD, GPU, QA and Reactant CI pass. ModelingToolkit downstream fails; the inspected recent main downstream runs are green, so the exact failure is not verified as pre-existing. G1 is satisfied by analytic diagonal solutions and independent direct solves; G3 by identity, resize, layout, changed-A and interrupted-state regressions. G2 evidence includes executed GPU CI, Core ForwardDiff/JLArray checks and CPU Reactant tests, with limits stated below. Blocking findingsNone. Non-blocking findings
What I ranAll three Julia invocations were sequential, with JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, a review-specific TMPDIR, the prescribed shared depot followed by the default depots, JULIA_PKG_PRECOMPILE_AUTO=0 and timeout 3600. The command transcription below uses gh pr view 1378 --repo SciML/LinearSolve.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,files
git -C src fetch origin '+refs/pull/1378/head:refs/remotes/pr/1378' main
git -C src checkout --detach pr/1378
git -C src rev-parse HEAD origin/main
git -C src merge-base origin/main HEAD
git -C src diff origin/main...HEAD
sha256sum INITIAL.md > INITIAL.sha256
git -C src log -1 --no-merges --format=%B
git -C src ls-remote origin refs/heads/main
git -C src diff --check origin/main...HEADThese commands exited 0. The PR is open and draft. Reviewed HEAD is the target SHA; origin/main is the Base SHA above. The three-dot diff and failing-before checkout use merge-base c7ff3be, not the newer tip of main. No root AGENTS.md or CLAUDE.md was present. No fixing issue is linked in the author description. The newest non-merge commit carries the author trailers recorded below. JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$REVIEW_DEPOT:" JULIA_PKG_PRECOMPILE_AUTO=0 timeout 3600 julia +1.13.2 --startup-file=no tmp/head-run.jl
JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$REVIEW_DEPOT:" JULIA_PKG_PRECOMPILE_AUTO=0 timeout 3600 julia +1.13.2 --startup-file=no --project=env-base tmp/base-run.jl
JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$REVIEW_DEPOT:" JULIA_PKG_PRECOMPILE_AUTO=0 timeout 3600 julia +1.13.2 --startup-file=no --project=env-head tmp/probe.jlThe head driver activates a temporary environment, develops the head checkout, adds Krylov, RecursiveArrayTools and SciMLOperators, then includes Base's genuine failures include workspace identity and allocation assertions (GMRES 19136 bytes and CG 3696 bytes versus 256-byte ceilings), plus four accuracy assertions for retrying interrupted GMRES/FGMRES without replacing A: relative residual 8.781220780590987e-7 versus the required 1e-8. Two additional base errors call the PR-only compatibility helper; these are not treated as numerical failing-before evidence. Block-alias, reduced-memory, non-Matrix setting and partition-layout testsets otherwise pass on this merge-base. Thus the full added file fails before and passes after, with a discriminating numerical regression for the interrupted-warm-start fix; not every added scenario fails before. The independent probe uses seeded input and analytic diagonal solutions or direct backslash references. Its 51 assertions cover preconditioner rebuilding across reinit! in None/Previous/Hegedus modes, rectangular LSMR/LSQR/LSLQ reuse and window changes from 2 to 7, complex sparse GMRES/CG with replacement output storage, and block GMRES/MINRES output replacement and changing RHS width from two to three. gh pr checks 1378 --repo SciML/LinearSolve.jl
gh run list --repo SciML/LinearSolve.jl --branch main --event push --limit 5 --json databaseId,headSha,conclusion,workflowName,url
gh run list --repo SciML/LinearSolve.jl --branch main --event push --workflow Downstream.yml --limit 5 --json databaseId,headSha,conclusion,url
XDG_CACHE_HOME="$PWD/tmp/gh-cache" gh run view 40682391570 --repo SciML/LinearSolve.jl --log-failed
XDG_CACHE_HOME="$PWD/tmp/gh-cache" gh run view 41285236709 --repo SciML/LinearSolve.jl --log
XDG_CACHE_HOME="$PWD/tmp/gh-cache" gh run view 40682391689 --repo SciML/LinearSolve.jl --job 122796230088 --log
XDG_CACHE_HOME="$PWD/tmp/gh-cache" gh run view 40682391689 --repo SciML/LinearSolve.jl --job 122796230506 --log
XDG_CACHE_HOME="$PWD/tmp/gh-cache" gh run view 40682391689 --repo SciML/LinearSolve.jl --job 122796229650 --log
What I did not verifyI did not run the entire package suite, Pkg.test(), downstream packages, documentation build, timing benchmarks, minimum Krylov 0.10.4, Julia 1.10, or another platform locally. The allocation ceilings ran in the added tests; author timing and bit-for-bit benchmark claims were not independently reproduced. I did not reproduce the ModelingToolkit assertion locally or on a matching default-branch environment, and do not claim it is pre-existing. No local physical GPU, AD, Reactant or MPI execution was performed. GPU, Core ForwardDiff/JLArray and CPU Reactant evidence comes from CI; physical-GPU cache reuse across A updates, block reuse and interrupted warm starts are not established by the inspected GPU log. Reactant CUDA remains unverified; the changed test explicitly selects CPU. No GPU kernel, AD rule or MPI implementation is changed. DefaultLinearSolver Krylov slot performance, full GPMR partitioned-system solves, and every supported Krylov algorithm/storage combination were not exhaustively probed. 🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5 |
|
The workspace is rebuilt on every At the LinearSolve level (LinearSolve 5.18.2, Krylov 0.10.11, Julia 1.12.6; the Krylov path is unchanged on One related item the PR does not seem to touch: under using LinearSolve, LinearAlgebra, SparseArrays
for n in (128^2, 256^2, 512^2)
A = spdiagm(-1 => fill(-1.0, n - 1), 0 => fill(4.0, n), 1 => fill(-1.0, n - 1))
cache = init(LinearProblem(A, rand(n)), KrylovJL_GMRES(; gmres_restart = 50))
solve!(cache); solve!(cache)
same = @allocated solve!(cache) # A untouched
cache.A = A; solve!(cache); cache.A = A
fresh = @allocated solve!(cache) # the same A object, set again
println(n, ": same A ", same, " B; after cache.A = A ", round(fresh / 2^20; digits = 2), " MiB = ",
round(fresh / 8n; digits = 1), " vectors")
endOutput: New values in a copy of |
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.326 Agent-Model: claude-sonnet-5-5 Agent-Session: local fixer job SciML__LinearSolve.jl__1378 (no session URL) # Conflicts: # Project.toml
Repeated
cache.A = ...updates reuse compatible Krylov workspaces instead of allocating and growing a new basis. Compatibility checks include workspace type, dimensions, solution storage type, memory semantics and error-estimation window, including initialized placeholders for non-Matrix operators.Block workspaces retain independent output storage, so
u0can overlap the RHS without Krylov zeroing the RHS before reading it. Restarted GMRES/FGMRES/FOM/GPMR and DIOM/DQGMRES require exact memory matches; unrestarted expanding methods can retain spare capacity. Block GMRES checks its constructor's restart capacity too. No public API or dependency changes.Regression evidence
New regressions cover 12×12 SPD systems with two RHS columns for block GMRES/MINRES, both shared
u0 = band an overlappingu0view, on first solve and after an A update. Decreasing-memory regressions compare reused GMRES, FGMRES, FOM and limited-memory methods with fresh solves; GPMR has a compatibility check, and block GMRES covers switching from an expanded unrestarted basis to a restarted solve.The same test file ran against unfixed head 1678314a6ba468805747e4a8918082c1a9f95327 (source unchanged) and with the fixes:
timeout 3600 julia --project=. -e 'using Test; @testset "Review regressions at 1678314" begin include("test/Core/krylov_workspace_reuse.jl") end'Before, exit 1 (zero block solutions; retained vector and block bases larger than the requested/fresh size 5):
After, exit 0 (same command, testset label “Review regressions with fixes”):
The 29 existing reuse assertions still pass, including allocation ceilings, unchanged iterations/solutions, changed-A accuracy, size/type incompatibility, operator restart and MINRES window checks.
Allocation and timing evidence
Same machine, same seed (
Random.seed!(1378)), same dependency manifests (Krylov 0.10.10),JULIA_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 taskset -c 3, BenchmarkTools minima. Before is default-branch merge parent c7ff3bee041e70e85dcf89acabcae7aee634a82c; after is this fix. Script: jobscratch/codex-benchmark.jl, based on the originala1_krylov_ab.jl.GMRES and CG retain 16-byte A-update solves, with identical iteration counts and residuals across the paired runs and zero solution change on repeated solves. Timings reflect this shared machine; the allocation reduction is the primary claim.
Local validation
Main regression, Core and QA runs used Julia 1.12.4.
GROUP=Core timeout 3600 julia --project=. -e 'using Pkg; Pkg.test()'Exit 0:
Julia 1.10.12 targeted regression file: exit 0, 69/69:
Both exit 0.
git diff --checkis clean.GROUP=QA timeout 3600 julia --project=. -e 'using Pkg; Pkg.test()'Initial run, exit 1:
This single Aqua persistent-task failure also reproduces with Aqua 0.8.18 on the unchanged default-branch control. A separate investigator reduced it to a fresh environment with no SciML packages: an optional dependency that only sleeps during compilation is falsely counted as a persistent task. The first bad Aqua commit is da7b66faf6a556d31056484f1051e57740afdf3a; its immediate parent passes the same cold fixture. A separate candidate Aqua patch passes that fixture and still rejects a genuine persistent Timer. It was not applied to LinearSolve or this QA run. No tests, assertions, timeouts or dependencies in the PR were changed to bypass the failure.
The standalone reproducer, versioninfo(), bisect outputs, candidate patch and upstream issue draft are saved in job
scratch/codex-aqua-investigation/. No upstream issue was filed: third-party permission was not provided and this task prohibits GitHub comments.Unchanged full QA rerun, exit 1: the same single Aqua assertion fails; all other assertions pass. No QA setting was changed.
All Julia jobs use the prescribed job-local
TMPDIRandJULIA_DEPOT_PATH, remove a host-specific tool directory from PATH, run undertimeout 3600, and stay within two top-level Julia runs. No global Julia environment changes.Not verified
Physical GPU, MPI and downstream package runs were not performed locally. DefaultLinearSolver Krylov slots were not validated or benchmarked. GPMR coverage here checks workspace compatibility rather than a full partitioned-system solve. No docs build was run: this diff changes no docstring, documentation or public API. CI for the new commit and independent re-review remain pending.
Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
🤖 Original implementation: Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), local session (transcript kept by the fleet master); orchestrated by Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv.
🤖 Review fixes generated with Codex CLI 0.163.0 (model: gpt-6.1-sol); local session (transcript kept by the fleet master).
Risk assessment (independent review, Grok Build grok-4.7, reviewed head faace44)
SciMLBase.solve!forKrylovJLwhencache.isfresh(src/iterative_wrappers.jl). A same-sizecache.A =now keeps the Krylov workspace instead of allocating a new one. Size, element type, a too-small GMRES basis, and a MINRES-family window mismatch still rebuild. Preconditioners are rebuilt whenprecsisfreshis set, whichLinearCachealready sets oncache.A =. No public name is removed or renamed. No new dependency. Version stays 5.18.2.DefaultLinearSolver's Krylov slots are not on this path, which the PR says.faace44e20c6e2f7d033e41c2fcda8dfe9e53352, unchanged at the end of the review. Julia 1.13.0, Krylov 0.10.11,tmp/env-ls1378developed from the worktree.includeoftest/Core/krylov_workspace_reuse.jl: 18/18 and 11/11 passed. The second set is the non-Matrixgmres_restart = 10/MINRES(window = 2)case that the follow-up commit exists to fix.@allocated solve!(cache)after a warmup update).A: aftercache.A =to a new matrix,cache.cachevalwas the same workspace,cache.Pl.diagmatched1 ./ diag(A2), andnorm(u - A2\b) / norm(A2\b)was1.2e-8.GMRES(restart = 20)thensolve!(cache, GMRES(restart = 5))reused the workspace (length(V)stayed 20). Solution error1.3e-8. A freshGMRES(5)took 9 iterations; the reused solve took 8.KrylovJL_LSMR(window = 3): solution error6.3e-8, then2.0e-8after a same-sizeAupdate with the same workspace andlength(err_vec) == 3.window = 7rebuilt (reused = false,err_veclength 7) and the solution error stayed2.0e-8.UndefVarError: @timeit not defined in Compileras main https://github.com/SciML/LinearSolve.jl/actions/runs/38790720488/job/116621882729. Core Julia 1 and lts passed (https://github.com/SciML/LinearSolve.jl/actions/runs/38862123413/job/116937865316, https://github.com/SciML/LinearSolve.jl/actions/runs/38862123413/job/116937865205).A\b, and a changed preconditioner, a window, and a too-small basis do not keep a stale workspace.🤖 Posted by an AI agent — harness: Grok Build · model: grok-4.7 (independent reviewer; appended by Claude Code 2.1.301 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
Risk assessment (independent review, Codex gpt-6.1-sol, head 1678314)
git diff origin/HEAD...HEAD; reviewed head 1678314. No fixing issue is linked; the body references the QA PR QA: explicit LinearAlgebra triangular imports and EI ignore list #1350, whose details were read. Archived HEAD and origin/HEAD (46a9aed) into scratch/head and scratch/base and resolved the head environment withjulia --project="$R/scratch/head" -e 'using Pkg; Pkg.instantiate()'; copied its Manifest to scratch/base for the same dependency versions. Julia 1.12.4, Krylov 0.10.11, JULIA_NUM_THREADS=4, prescribed JULIA_DEPOT_PATH, scratch TMPDIR, timeout 3600; test commands ran sequentially.$Rdenotes this report's parent directory.julia --project="$R/scratch/head" -e 'using LinearSolve; include("<local path>)': 18/18 + 11/11 pass. Same command with scratch/base: 9 pass, 8 fail, 1 error in the first testset; the allocation ceilings fail at 19,136 B for GMRES and 3,696 B for CG, workspace-identity assertions fail, and the PR-only helper is undefined. The file exits at that failed testset; its second testset was not reached on base. Logs: scratch/head-tests.log and scratch/base-tests.log.julia --project="$R/scratch/head" "$R/scratch/probes.jl": 1 pass / 2 fail; same command with scratch/base: 3/3 pass. GMRES restart probe retains basis 20 on head and takes 41 iterations, versus basis 5 and 42 iterations on base and fresh solves. The additional ArrayPartition layout probe passes on both. Logs: scratch/head-probes.log and scratch/base-probes.log.julia --project="$R/scratch/head" "$R/scratch/block-alias.jl": 0 pass / 2 fail; same command with scratch/base: 2/2 pass. Head GMRES/MINRES report Success with zero output and residuals 5.46639 / 4.36449; base residuals are 3.41e-15 / 4.67e-15. Logs: scratch/head-block.log and scratch/base-block.log.gh pr checks 1378 --repo SciML/LinearSolve.jl --json name,state,linkfound no failures; therefore no current failing check required comparison against default-branch CI. Core, QA, AD, Reactant and four downstream checks are green; ModelingToolkit is in progress and physical GPU/Apple checks remain queued. Downloaded Core/AD logs show Krylov reuse 29/29, warm start 41/41, ForwardDiff GPU Arrays 16/16 (CPU-backed JLArray), Mooncake 46/46 and Enzyme 64/64.A2 \ b), and the reviewer probes also compare against direct solutions. Those references expose the block regression.🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local headless review run (no public session URL); transcript kept by the fleet master.
Risk assessment (independent review, Codex gpt-6.1-sol, head 3442401)
cache.A = ...updates in LinearSolve's KrylovJL path, used by every downstream solver that reuses a linear cache.krylov_workspace_reuse.jl69/69 andwarm_start.jl41/41; the same regression file against 1678314 gives 55 pass / 14 fail (4 block-alias, 10 memory/restart). Probes: 64/64 block-alias and changed-A, 36/36 rectangular LSMR/LSQR/LSLQ window changes, 3/3 preconditioner refresh.nonsquare.jl129/129,sparse_vector.jl12/12. Physical GPU probe (RTX PRO 6000 Blackwell, CUDA 13.4): 24/24 for GMRES/MINRES, Float32/Float64, vector and block RHS. Both earlier alias/restart findings are fixed. Not verified: full Core/QA locally, Julia 1.10, MPI, Apple, and the downstream ModelingToolkit/SciMLSensitivity jobs that were still running.🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol (independent reviewer; appended by Claude Code 2.1.302 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_0133iSjsLBByPU93BDEQkNDF (fleet master); the review ran as a local headless Codex session with no public URL.
Independent executed findings at head 3442401 — session 01a15e39-ef5b-7b13-8999-b6036ce3fa61
Krylov workspace reuse preserves an abandoned warm start after a callback exception. Clearing the current guess and updating the matrix can then return Success with a wrong solution. Reset transient warm-start state before reuse, or rebuild an incompletely solved workspace, and add an official exception/update/retry regression with independent residual and solution assertions.
The independent 60×60 diagonal control uses an initial guess of one million, a callback that throws once, then a zero guess, a changed matrix and changed right-hand side. Head reports Success with relative residual 0.325793845255356 and solution error 0.1459667179350269 (2 pass, 2 fail); clean base passes 4/4 with residual 4.502000524159359e-9 and error 1.89799699821511e-9. Expected solutions use independent diagonal division. The ordinary reuse test passes 69/69 and warm-start test 41/41; these do not catch the recovery defect.
Official Core timed out after one hour with affected testsets passing; complete Core is unverified. Head QA exited with SIGTERM, cause unknown, before completion; clean-base QA passed. These are incomplete validation results, not a fabricated Aqua failure. Exact-head CUDA71, Mooncake46 and Enzyme64 assertions were read from CI, not run locally. A separate clean-default DIOM initialization failure is routed for investigation. Original commit model/session metadata also needs an evidence-backed repair without guessed identity or signed-history rewriting.
Risk assessment
Links:
🤖 Posted by an AI agent — harness: Codex CLI0.163.0 · model:gpt-6.1-sol
Conversation: local session 01a154f0-8986-78e1-8af2-1119e8cdea4a (no session URL)
Risk assessment (independent review, Codex CLI (gpt-6.1-sol), local job oss-reviews-2026-10-22-SciML-LinearSolve-jl-1378-3442401 (no session URL), head 3442401)
Executed review notes (head 3442401):
Findings
src/iterative_wrappers.jl:690 — blocking — The new rebinding method excludes rectangular workspaces with different range/domain storage types. In supported Krylov 0.10.11,
KrylovWorkspace{T,FC,S}aliases_KrylovWorkspace{T,FC,S,S}; it does not include workspaces with differentSmandSn. The existingArrayPartitionconstructor intentionally supports separate range and domain types. For a full-rank 6×3 matrix and a two-partArrayPartitionRHS, the default output is aVector, so the initialized LSMR/LSQR/CGLS workspace passes_krylov_can_reuse_workspace, then the firstsolve!throwsMethodErrorat line 704. An explicitly supplied one-partArrayPartitionoutput fails identically. These cases solve accurately on the merge-base. Broaden the non-block rebinding dispatch to include these workspaces, preserve the block no-op, and add first-solve and A-update regressions with distinct range/domain types. A process-local generic fallback restores all six assertions in the explicit-output probe; no package source was edited.src/iterative_wrappers.jl:670 — blocking — Matching total dimensions and concrete vector type does not establish compatible partition storage.
ArrayPartitionpart lengths are runtime values, so changing the partition lengths from(2, 3)to(3, 2)preserves both the vector type and the operator's 5×5 dimensions. After updatingcache.A,cache.b, andcache.u, this predicate accepts the old workspace and only rebindsx; basis and scratch vectors still have the old partition lengths. A matrix-free block operator that multiplies its two fields independently then receives a length-2 workspace field for its new 3×3 block and throwsDimensionMismatch. The scratch probe uses ordinary block matrix multiplications and analytic solutions[1/2, …, 1/3, …]. GMRES, CG, and MINRES all pass both solves on the base; all three fail after the A update on the head. Include partition layout in compatibility, or conservatively rebuild when compatibility cannot be established, and add this regression.src/iterative_wrappers.jl:79 — nit — The public KrylovJL docstring describes the old workspace lifecycle. It says the workspace “rebuilds whenever
Ahas been replaced” and explicitly includescache.A = newAandreinit!. The new implementation deliberately retains compatible workspaces across those updates. Update the docstring to describe conditional rebuilding and retained storage.Evidence
Reviewed head
344240171e218b990761ec498112cee831bef852; merge-base withorigin/mainisc7ff3bee041e70e85dcf89acabcae7aee634a82c. Reviewed the complete supplied diff, relevant constructors, cache setters, Krylov workspace definitions, tests, and supplied PR metadata. No commits, GitHub writes, or edits insiderepowere made.Independent risk assessment: Before reading
pr.jsonor any author's/reviewer's rating, recorded medium-high (MH1) intmp/initial-risk.txt: the diff changes LinearSolve'ssolve!/cache-reuse main lane, with L2 test additions and ML8 cache-state scope; downstream validation was not yet established. The final rating increases to high (H1: rejecting inputs that used to work) based on the independently reproduced failures above. Matched criteria are L2, ML8 (workspace/cache changes with regression tests, although the partition cases are missing), MH1 (different errors on the core init/solve!/reuse lane), and H1 (previously accepted inputs now error); the highest is H1. The initial M3 concern about an unbenchmarked hot path is addressed by the body's paired timing/allocation measurements. ML11's performance-only classification is unavailable because behavior is demonstrably changed, even though the supplied downstream CI is green. This rating does not derive from the body's ratings.There are no intentional public name/signature changes, version/compat changes, new dependencies, or licence changes. The rejected inputs are nevertheless an observable API regression and should be fixed before release. Existing tests/assertions were not deleted, loosened, skipped, or marked broken. The new allocation/identity assertions discriminate base from head. The direct-solve checks provide independent numerical references; fresh-versus-reused comparisons also check iteration/restart behavior. None of the new assertions was found to be inherently unable to fail. G1 has independent references; G3 has reuse tests but misses the two failures above. The supplied CI reports GPU and AD jobs green; exact hardware branch coverage was not independently established from job logs.
Scratch setup and environment. Archived head and merge-base into
tmp/headandtmp/base, instantiated head, then copied its Manifest to base. Both manifests have SHA-256d0985aa801e0862b75a7cf9593e3398f1c7814d84ece9d582dbaa9e6ab8ee360. Julia 1.12.7, Krylov 0.10.11, RecursiveArrayTools 4.5.5, SciMLBase 3.58.0, SciMLOperators 1.30.3. Every Julia test command below usedJULIA_NUM_THREADS=4,JULIA_NUM_PRECOMPILE_TASKS=4,JULIA_PKG_PRECOMPILE_AUTO=0,TMPDIR="$PWD<local path>, andJULIA_DEPOT_PATH="$PWD<local path>; each run was limited to 2,400 seconds. Commands and output excerpts follow; complete scripts/logs are intmp.Exit 0,
tmp/head-regressions.log:Exit 1,
tmp/base-additional.log:The eight failures are workspace-identity/allocation checks; measured base allocations are 19,136 bytes for GMRES and 3,696 bytes for CG, both above the 256-byte bound. The two errors call the PR-only helper, which does not exist on base; they are not numerical failures. All 69 assertions pass on head. Thus the allocation improvement is discriminating, while both adversarial regression groups pass on base.
Exit 1,
tmp/head-additional.log:The first group errors in LSMR, LSQR, and CGLS. The second group's initial solves pass, then updated solves error in GMRES, CG, and MINRES. Reproducers are
tmp/default_rectangular_probe.jlandtmp/layout_probe.jl; the latter defines a matrix-free block operator usingmul!on each field.The explicit partitioned-output probe produces 6/6 pass on base (exit 0), 3 errors on head (exit 1), and 6/6 pass with a process-local generic rebinding fallback (exit 0). Logs:
tmp/base-rectangular.log,tmp/head-rectangular.log,tmp/fixed-rectangular.log. The fallback only adds a method in that Julia process and preserves the specialized block no-op; it is diagnostic evidence, not a submitted fix or a fix for finding 2.Supplied CI snapshot: Parsing
pr.jsongivesCounter({'SUCCESS': 66, 'SKIPPED': 4}), with no failed/pending checks. Core (including downgrade), AD, GPU V100, QA, Reactant, documentation, benchmarks, and all five downstream jobs report success: OrdinaryDiffEq/InterfaceII, ModelingToolkit/All, SciMLSensitivity/Core1, BoundaryValueDiffEq/All, and NonlinearSolve/Core. The four skipped jobs are sublibrary matrix placeholders; this diff changes no sublibrary. The body’s remaining statements that current-head CI and downstream validation are pending are stale relative to this supplied snapshot. Green CI does not cover the failing storage cases demonstrated here.Not verified
🤖 Posted by an AI agent — harness: Codex CLI · model: gpt-6.1-sol (independent reviewer; appended by Antigravity CLI · model: gemini-4-argon-high)
Conversation: local job oss-reviews-2026-10-22-SciML-LinearSolve-jl-1378-3442401 (no session URL)
Fix by Codex CLI 0.164.0 gpt-6.1-sol (head 2bf5dc8)
Support rectangular Krylov workspaces with distinct range/domain storage, conservatively rebuild ArrayPartition workspaces on matrix updates, and rebuild interrupted warm starts before retrying with or without a matrix update. The public KrylovJL docstring describes the workspace lifecycle. The existing fix was ported unchanged; no dependency, public API, assertion tolerance, skip, or broken-marker changes were introduced.
Discriminating regression
Identical tests against unmodified head 3442401 and the fixed tree, Julia 1.12.7. Environment variables below identify the frozen comparison environments and probe scripts.
Before, exit 1:
After, exit 0:
The original 69 assertions remain intact. New cases cover rectangular LSMR/LSQR/CGLS with vector and partitioned output, changed partition layouts for GMRES/CG/MINRES, and GMRES/FGMRES exception/retry recovery with independent solution and residual checks.
Allocation probes
Same seed, copied dependency manifests, single Julia/BLAS thread, warmed repeated A updates. Baseline is merge parent c7ff3be; the fixed tree includes the PR's workspace reuse.
Both exit 0:
Dense, sparse, tridiagonal and MatrixOperator updates each measured 16 B. Repeating the same two commands with
+1.12.4also passed: GMRES 20,108,816 B → 16 B; CG 326,664 B → 16 B; identical paired iterations/residuals, zero solution change, and storage-family checks 12/12. The observed unfixed byte counts differ slightly from the previous report's 20,116,560 B and 326,792 B; all fixed update measurements remain 16 B.Full local validation
Both exit 0. Core includes:
QA output (the nine JET broken assertions are pre-existing):
timeout 3600 julia +1.12.7 --project=@runic -m Runic --inplace src/iterative_wrappers.jl test/Core/krylov_workspace_reuse.jl git diff HEAD^ HEAD | typos - git diff --check HEAD^ HEADAll exit 0. Runic left the ported files unchanged. Two added comment lines out of 96 added lines explain the partition compatibility constraint.
Exit 0, with doctests, exported-name checks and link checks enabled. System Python and scratch PyAMG packages use the prior fixer's working environment recipe. Successful output includes:
Before changing code, current-head CI showed 66 SUCCESS / 4 SKIPPED placeholders.
gh run view --log-failedreturned no output for both current-head Tests and default-branch Tests. The separate default-branch ModelingToolkit integration failure atcomponents.jl:446predates this fix and was left untouched.Not verified locally: physical GPU, MPI, downstream suites, dedicated AD/Reactant groups, dedicated DefaultLinearSolver Krylov allocation probes, or exhaustive Krylov/backend combinations. No historical author identity or conversation link was guessed, and no existing commit history was rewritten.
Next counted review must come from a smart model in a fresh session, not this fix session (risk.md § Independent reviews).
Links:
The prior independent risk assessment remains in force until a fresh independent review. This fix session supplies executed validation and does not issue an independent rating.
🤖 Posted by an AI agent — harness: Codex CLI 0.164.0 · model: gpt-6.1-sol
Conversation: local fixer job SciML__LinearSolve.jl__1378 (no session URL)
Fix by Devin CLI 3000.11.228 swe-2-high (head 30a36a4)
Two CI failures fixed; the workspace-reuse property is unchanged.
Downgrade job — compat bump (chosen over method-presence gating)
Project.toml:Krylov = "0.10"→Krylov = "0.10.4".init_cachevalforb::ArrayPartitioncallsKrylov.KrylovConstructor(b, u). On Krylov ≤ 0.10.3KrylovConstructor{S}requiresvm/vn/vm_empty/vn_emptyto share one storage type, so any problem whose range and domain storage differ — a rectangularA(default flatu), or au0partitioned with a different layout — hits aMethodErroratinit. Those are the 6 downgrade errors, all inKrylovJL rectangular partitioned storage. Gating was considered and rejected: the pre-KrylovConstructormethod returnednothingand the solve errored anyway, so there is no older working path to fall back to; a real fallback would be the flat-buffer canonicalize machinery #1206 deliberately dropped, dead code reachable only on Krylov ≤ 0.10.3. Krylov 0.10.4 ("Allow vm and vn to be of different types") is the lowest registered version providingKrylovConstructor{Sm,Sn}.Reactant job — pin the test to the CPU client
test/Reactant/reactant.jl: addedReactant.set_default_backend("cpu").The group's env carries no CUDA.jl, so its
julia_callbacks only work when XLA hands them host buffers. Theself-hostedpool includes GPU nodes; there Reactant selects the CUDA backend and passes device buffers to thereactant_julia_callbacktrampoline, which it wraps only when its CUDA extension is loaded —LoadError: CUDA.jl extension must be loaded to perform julia callbacks on the GPUinOps._construct_cuda_julia_buffer, before the callback body runs. The check is runner-pool nondeterministic: the last green run landed on a CPU node with no XLA CUDA init, and the failing path (default solver on a 2×2 system) never touches the code this PR changes. Pinning the CPU client makes the group deterministic on either runner without changing what is asserted; the alternative (adding CUDA.jl to the group env soReactantCUDAExtloads) would route the callback'ssolvethrough CuArrays and put bitwise==assertions at the mercy of CUSOLVER-vs-LAPACK numerics, which cannot be verified without the GPU runner.Validation
Fail-before, reproduced with the actual
julia-downgrade-compat@v2script (downgrade.jl "" . deps 1.10 Mooncakeon Julia 1.10.12 → Krylov v0.10.0, same as CI),include("test/Core/krylov_workspace_reuse.jl"):After the compat bump (same script re-run → Krylov v0.10.4, the new floor):
GROUP=Core julia --project -e 'using Pkg; Pkg.test()':Testing LinearSolve tests passedTesting LinearSolve tests passedGROUP=QAon Julia 1.12.4:Testing LinearSolve tests passed(JET 34+9broken, Allocation QA 67, SupernodalLU QA 8, Quality Assurance 51)julia --project=@runic -m Runic --inplace test/Reactant/reactant.jl: no changes needed.typos --diffover the diff: clean.Reactant:
julia --project=test/Reactant test/Reactant/reactant.jlat Reactant v0.2.301 / Reactant_jll v0.0.433 (the same resolution as the failed job) → all assertions pass (preserves the LinearSolve operation3/3,default LU preserves QR safety fallback4/4). The GPU-buffered callback path itself could not be exercised locally (needs the self-hosted GPU runner); what is verified is that pinning to the CPU client restores exactly the path that has always passed on CPU runners.Next counted review must come from a smart model in a fresh session, not this fix session (risk.md § Independent reviews).
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.228 · model: swe-2-high
Conversation: local fixer job SciML__LinearSolve.jl__1378 (no session URL)
Failures inherited from the default branch (named, not caused by this PR)
ModelingToolkit.jl/All / Downstream Tests - Allalso fails on the default branch's own most recent push run at501476cda32bce76513caa6b08dfec9ebd80f19b(https://github.com/SciML/LinearSolve.jl/actions/runs/40303351595), i.e. no regression introduced here. All other required CI (65 checks) is green at head30a36a4f77cbd949107a960d154ad6afd8b880bf.Fix by Claude Code 2.1.326 claude-sonnet-5-5 (head 552ed24)
No source change was needed. This round merges current
maininto the branch (oneProject.tomlconflict, resolved toKernelAbstractions = "0.9.30, 0.10.0"from main andKrylov = "0.10.4"from this PR; a merge instead of a rebase because the branch holds merge commits that are not mine, so no force-push) and re-checks the open items.ModelingToolkit downstream job (run 40682391570, 2026-10-28)
The one failing assertion is
ModelingToolkitBase/test/components.jl:446(isequal(comp1.input.u ~ comp2.output.u, comp2.output.u ~ comp1.input.u)), a symbolic equation-orientation check in "Causal connections generate causal equations". It does not call any Krylov path. That run used an older MTK; against current MTK (0f2c7c4) with this branch's LinearSolve developed into the environment, the same file passes:The fresh CI run on 552ed24 is the authoritative check; the previous result is stale.
Review findings at 3442401 — already fixed at 2bf5dc8, verified here
The new test file
test/Core/krylov_workspace_reuse.jlrun against the unfixed source 3442401 and against this head:timeout 3600 julia --project=. -e 'using Test; @testset "Reuse at unfixed 3442401" begin include("test/Core/krylov_workspace_reuse.jl") end'ArrayPartitionpart lengths:_krylov_can_reuse_workspacereturnsfalsefor anArrayPartitionRHS, so the workspace is rebuilt;changed partition layout(GMRES/CG/MINRES, (2,3) → (3,2)) compares againstones ./ diag._krylov_pending_warm_startblocks reuse of an interrupted warm-started workspace;retry after callback exception(GMRES/FGMRES, with and without an A update) checksA * u ≈ bindependently of the solver.Other validation (Julia 1.13.2, merged head)
The Risk assessment's independent-review line is rewritten as plain text (
rated head 1678314 medium-high (MH1), with the later H1 rating at head 3442401). Risk stays high; no rating is claimed here. Not verified: GPU, MPI, the full MTK/other downstream suites locally.Next counted review must come from a smart model in a fresh session, not this fix session.
🤖 Posted by an AI agent — harness: Claude Code 2.1.326 · model: claude-sonnet-5-5
Conversation: local fixer job SciML__LinearSolve.jl__1378 (no session URL)