Add real LAPACK GETRS derivative rules #3524
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.55) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 502 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.372
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3524"
general
weight: 0.35
agourakis82
Real Fortran LAPACK
sgetrs/dgetrscalls currently stop differentiation with a missing-derivative error. This adds forward and reverse rules for solves with supplied packed LU factors and fixed integer pivots, allowing a factorization to be reused across differentiated solves.The rules are defined in
BlasDerivatives.td, following the review request. The dedicatedBlasGetrsimplementation, handler and tape have been removed. The BLAS generator gains inactive integer-array caching for pivots, guarded cache copies, outlined statement rules and masked matrix updates. Outlining keeps derivative control flow separate from Enzyme's mapped primal blocks. Existing Fortran declaration argument counts and callee calling conventions are preserved.The rules differentiate both packed factors and the in-place RHS/solution. They cover real N/T/C operations, multiple RHS, padded leading dimensions, vector differentiation, and recognized LP64 /
_64_ILP64 spellings. The primal remains a LAPACK call; derivatives use GETRS, TRMM, GEMM and LASWP without constructing an inverse. The reverse factor rule reconstructs the solution from the cached input RHS.Native validation now covers LLVM 15.0.7 and 16.0.6, each in Release and Debug on Linux:
The earlier LLVM18 golden-check replay is superseded by the LLVM15/16 matrix. Its one intentional raw-IR difference preserves an existing 13-argument GEMM declaration rather than adding hidden lengths. The original checks remain intact.
Private environment caveat: GCC13/C++23 builds use a documented LLVM SDK DiagnosticInfo.h lvalue-return compatibility edit, a CMake standard override and isolated SDK dependency bootstrap. These are not upstream changes. The numerical source uses -std=c++2b with Clang15/16, their spelling for C++23 mode. Official CI, other platforms and full compiler soundness remain separate unverified gates.
Scope: supplied nonsingular packed factors, fixed pivots, ordinary pointer-based Fortran declarations, an active RHS and static activity. This does not add GETRF or pivot-selection differentiation. Complex arithmetic, runtime activity, split-forward mode, integer-encoded references and arbitrary factor/RHS overlap are outside this change. GETRS argument-error identity behavior is tested; GETRS does not supply a new singularity check. No performance improvement is claimed.
Related request: https://github.com/EnzymeAD/Enzyme.jl/issues/3039