Use PureGebal for the Base-exp balancing path - #268
Draft
ChrisRackauckas-Claude wants to merge 1 commit into
Draft
Use PureGebal for the Base-exp balancing path#268ChrisRackauckas-Claude wants to merge 1 commit into
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Replace the hand-written LAPACK GEBAL ccall with PureGebal. The wrapper existed only because `LinearAlgebra.LAPACK.gebal!` allocates its scale vector on every call, which the Krylov hot path cannot afford, so this package duplicated ~20 lines of stdlib ccall to get a caller-supplied buffer. PureGebal provides that buffer as a first-class workspace, so the duplication goes away. The cache's bare `scale` vector becomes a `PureGebal.GebalWorkspace`, and the hand-rolled undo -- the diagonal rescale plus the two permutation replays that decode LAPACK's packed `scale` layout -- becomes `PureGebal.unbalance!`. This removes the package's entire dependence on non-public LAPACK internals. Six ExplicitImports exceptions existed solely for that wrapper and are now deleted: `@blasfunc`, `BlasInt`, `chkfinite`, `chklapackerror`, `chkstride1`, `libblastrampoline`, along with the whole `all_qualified_accesses_via_owners` block. What remains are other packages' non-public names, not LAPACK's. Behaviour is unchanged. PureGebal is bit-identical to `LAPACK.gebal!` on the inputs this path sees, and the balanced Padé evaluation still runs with zero allocations. Verified locally on Julia 1.12.6: Core 742 passed / 1 pre-existing broken -- identical to a master baseline run of the same suite -- and QA 22 passed / 2 pre-existing broken. Runic clean. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Member
Author
Local verification completeBoth Julia versions, with a master baseline run of the same suite on each so the numbers are attributable rather than assumed.
Every Two count differences that are not attributable to this PR:
Also: Runic 1.5.1 and CI here will stay red until JuliaRegistries/General#163748 merges — the local runs above used a For what it is worth, PureGebal's own CI is green on Julia 1 and lts across Ubuntu, macOS and Windows, so the balancing code this now depends on has cross-platform evidence behind it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas. Draft.
PureGebal is not in the General registry yet — JuliaRegistries/General#163748 is open, and new packages sit for three days. CI on this branch will fail at
Pkg.instantiateuntil it merges. Local verification below used adev'd PureGebal. Nothing to fix here; it just cannot go green yet.Summary
Replace the hand-written LAPACK GEBAL
ccallwith PureGebal.That wrapper existed for one reason:
LinearAlgebra.LAPACK.gebal!allocates itsscalevector on every call, which the Krylov hot path cannot afford, so this package duplicated ~20 lines of stdlibccallto get a caller-supplied buffer. PureGebal provides that buffer as a first-class workspace, so the duplication goes away.scalevector becomes aPureGebal.GebalWorkspacescalelayout — becomesPureGebal.unbalance!+15 / −81 across four files.
This removes all dependence on non-public LAPACK internals
Six ExplicitImports exceptions existed solely for that wrapper and are deleted:
@blasfunc,BlasInt,chkfinite,chklapackerror,chkstride1,libblastrampoline— along with the entireall_qualified_accesses_via_ownersblock. What remains (promote_op,arithmetic_closure,parameterless_type) are other packages' non-public names, unrelated to balancing.Behaviour
Unchanged. PureGebal is bit-identical to
LAPACK.gebal!on the inputs this path sees (asserted in its own suite across dense, wide-dynamic-range, sparse, triangular and block-isolated families), and the balanced Padé evaluation still runs at zero allocations — checked directly, withcache[7]::PureGebal.GebalWorkspace{Float64}.Local verification
git diff --check: cleanDeliberately not in this PR
src/exp_noalloc.jlstill balances viaGenericSchur.balance!forExpMethodHigham2005, which allocates (~672 B at n=30). PureGebal could replace that too and remove the allocation, plus the separateprow/pcolundo path — but it changes the generic (non-BLAS) path's behaviour, so it belongs in its own PR.This is independent of #267, which is documentation only.