Repository navigation
Fused LDLᵀ: diagonal pivoting, KKTSolver pivoting = :diagonal (refs #167, stage 2) - #204
Conversation
…zation (refs #167) FusedSolver "S" takes pivot_type = 'D' and pivot_threshold. The regime-A subtrees run the stock subtree LDLᵀ kernel; the narrow panels (PANEL_B/C, width <= 64) run the stock pivot steps (_lt_pass1!/decide/pass3/swap/update/ finalize) on the split front (F11 in sh, rows below in the panel), factor the rows below themselves (no TRSM role) and write piv/pivot_kind in the stock layout; the in-kernel wide fronts (> 64) factor without interchanges with the static replacement and an identity piv. Compile-time Val(PIV): the no-pivot kernels are unchanged. The fused solve applies the pivot order (set_pivoted!); refactorization picks a new pivot sequence with the same plans; graph replay unaffected (pivots read on the device). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr
:diagonal (:ldl only, pivot_threshold allowed) is pivot_type = 'D'; fused where :none is fused (fused = nothing: CUDA/AMDGPU/oneAPI fused, CPU/Metal stock; fused = true/false honoured; the #200 fallback keeps 'D'). Docs, MadNLP options table and CHANGELOG (0.4.1, Added). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr
91837fb to
12090c9
Compare
| # diagonal pivoting on either pipeline (the fused one: the subtrees and the narrow fronts, see FusedSolver) | ||
| if diagonal | ||
| setparam!(inner, "pivot_type", 'D') | ||
| pivot_threshold === nothing || setparam!(inner, "pivot_threshold", pivot_threshold) | ||
| end |
There was a problem hiding this comment.
nit (non-blocking): on the stock pipeline pivot_type is already set to 'D' at line 210 (setparam!(d, "pivot_type", diagonal ? 'D' : 'N')), so this block repeats it; only the fused pipeline and pivot_threshold need it. Harmless (the second call is a no-op), but one of the two writes could go, e.g. keep line 210 as setparam!(d, "pivot_type", 'N') under elseif ldl && !diagonal, or drop the diagonal ? 'D' : 'N' and let this block be the single place that turns diagonal pivoting on for both pipelines.
There was a problem hiding this comment.
VERDICT: APPROVE (head 12090c9)
Reviewed against AGENTS.md, issue #167 (the stage-2 scope of the owner's maintenance plan), PLAN.md §2.4/§2.7 and the diff (src/fused.jl, src/kkt.jl, test/test_fused.jl, test/test_kkt.jl, docs, CHANGELOG). Maintenance PR, not a TASKS.md task: PLAN.md, TASKS.md, Manifest.toml untouched; the PLAN deviation is stated in the body.
What I checked
- Kernel (
fused_fact_kernel!, PIV branch): the narrow panel runs the stock regime-B pivot steps (_lt_reset!/_lt_init_piv!/_lt_pass1!/_lt_stage1!/_lt_decide1!/_lt_pass3!/_lt_decide3!/_lt_swap!/_lt_update!/_lt_finalize!/_lt_stage!) on a_SplitFrontwithW = 64over(sh, factor); the offsets match the fused panel indexing (front_ptr[v] - 1 + (j-1)f + i);red/rediare sized3·WG/2·WGas the stock kernel;ctl,lpvcollapse to one entry without pivoting. Barriers are uniform (thePHASE == 3branch reads a local word after a barrier, as stock). After_lt_finalize!theshdiagonal holds D and the panel rows below hold L₂₁, which is what_front_ldl_syrk!and the TILE roles consume; the Schur complement is invariant to the in-block interchange and the CB row indexing is untouched, so extend-add is unchanged. - Dependency counters:
emit_splitsetstrsm_left[v] = 1with no TRSM roles; the panel decrements it after the fence and signalscb_done/arrivedonly whentiles_base[v] == 0, mirroring ROLE_TRSM; TILE roles spin ontrsm_left == 0. Consistent. - Pivot-sign convention: the stock kernels read
psign[perm[piv[g]]](original row);psgoisInt8.(ps)unpermuted, the wide fronts use the factor-orderedpsgwith identitypiv, so both agree.dhas2nentries (d_len = 2n),pivisInt32storage, thed[n+g]write of_lt_select!is in bounds. - Regime A:
subtree_ldlt_kernel!with the sameLB - SUBTREE_LOCAL_RESERVE_LDLTbudget as the fused LDL launcher and the stock one; stack/cb_ptroutput as the no-pivot kernel. - Inertia/
npivotsof a FusedSolver are read fromd/pivot_kind, which 1×1 pivoting keeps valid;prm.scaled = falseis guaranteed by the existing refusal ofpivot_epsilon_alg = "algo1". FusedSolver.setparam!("pivot_type")restores the old value when refusing'A'/'B'/'L';_check_fused_optionsre-checks at analysis;set_pivoted!is set at analysis and at each factorization.KKTSolver::diagonalvalidation, pipeline selection (!bk && forward_progress),pivot_thresholdgating, and the #200 fallback keepspivot_type = 'D'since it lives in the inner options. One redundantsetparam!on the stock path (inline nit).- Tests: no existing assertion weakened; the new testsets use
eltypes_among((Float32, Float64))(the fused LDL is real-only),FUSED_BACKENDS,Random.seed!(666),tol(T)/growth_toland the shared helpers; they compare the pivot order exactly outside the wide fronts and their ancestors, identity order in the wide fronts, D, inertia,npivots, zero-pivot replacement withpivot_sign, thepivot_epsilon = 0failure, refactorization with a new pivot sequence, bitwise reproducibility, graph replay,Int64indices, and"algo5"/"algo6"with refinement. The reported counts are plausible for the added parametrizations.
Blocking findings: none.
For the owner (non-blocking):
- The body says the PR is a draft until the Aurora host-allocation overshoot of the unpivoted fused cycle (101,384 / 101,624 vs 98,304 bytes on oneAPI) is traced, but the PR is not marked draft. The pivoted path adds six kernel arguments (56 now) to every fused launch, the likely source on oneAPI;
ALCF / LTS stack (Aurora)was still pending at review time and would failtest_fusedif the measurement holds. The CUDA, AMDGPU and CPU legs were pending too. - Performance, by design: a pivoted narrow panel factors all rows below itself in one workgroup (needed for the threshold test against the whole column), where the no-pivot plan spreads that over
cld(m, wgf)TRSM roles; the body's 1.75× / 2.9× factorization cost reflects it.
… with 31 or more arguments (#205) The fused factorization kernel has 56 arguments since the diagonal pivoting (50 before). oneAPI.jl converts the arguments of a launch with Base's map, which is not inferred for a tuple of 32 or more elements (31 arguments and the KernelAbstractions context); the launch then allocates about 1 KB per argument: 42 KB for this one launch, 34-36 KB before. Measured on Aurora: 101.6 KB for the cycle with three solves (94.7 KB on main), 79-82 KB for the others. No launch, fill or host read was added to the unpivoted cycle. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHmu82zj927Qv8Zq6Tq
The stock branch already sets it; the common block now sets it for the fused pipeline only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr
… (refs #167) Stage 2 (pivot_type = 'D') added 816-864 B of host allocation to every refactorize! + solve! cycle of a FusedSolver without pivoting (CUDA; every configuration, "SPD" included), which pushed the refining "S" cycle over the 96 KiB oneAPI budget on Aurora: * the fused kernel launch passed the four arrays of the pivoted variant (N.piv, psgo, S.perm, N.aux) also without pivoting; the GPU packages convert and track every array argument of a launch. Without pivoting they are now `nothing` (never read: every use is under PIV); * `_fused_factorize!` re-set the solve's pivot flag from `F.fp.piv`, a read of the untyped plan field that copied the 448-byte plan NamedTuple at every refactorization. The flag is set by the analysis together with the plan and is not re-set here. The unpivoted cycle now allocates exactly what it did before stage 2 (byte for byte, same allocation profile). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr
The stock branch already sets it; the common block now sets it for the fused pipeline only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr
Refs #167. Stage 2 of three maintenance PRs for it, rebased on
mainafter #202 and #203 were merged.What changed
src/fused.jl, structure"S",pivot_type = 'D'):pivot_epsilonandpivot_sign, andpiv,pivot_kindin the stock layout. The panel factors the rows below itself, so the pivot plan has no TRSM roles.FusedSolveracceptspivot_type'N'or'D'andpivot_thresholdon"S";'A','B','L'raiseNotSupportedError. Refactorization gives a new pivot sequence on the same plans; captured CUDA graphs stay valid since the pivot decisions andpivlive on the device.KKTSolvergainspivoting = :diagonal(:ldlonly, withpivot_threshold): the fused pipeline wherever:noneis fused,pivot_type = 'D'on the stock pipeline. MadNLP's binding can then pass it instead of settingpivot_typeon the inner solver.docs/src/lib/fused.md,docs/src/lib/kkt.md,docs/src/man/madnlp.md),CHANGELOG.md(Added, under[0.4.1] - unreleased; no further version bump).Pivot sequence against the stock pipeline
Equal outside the wide fronts and their ancestors on well-conditioned generators, in
Float32andFloat64; the tests compare it exactly there. On strongly ill-conditioned matrices or with exact ties a few narrow-front pivots differ, since rounding differences in the assembly decide near-ties; those tests compare inertia,npivotsand residuals.Tests
No existing assertion was changed or removed. Two parametrizations in
test/test_kkt.jlwere extended with:diagonal. New testsets intest/test_fused.jl(against the stock factorization on the same analysis: interchanges asserted in subtrees and narrow fronts, identity order in wide fronts, exactpiv, inertia,npivots, pivot-changing refactorization, bitwise reproducibility, graph replay,Int64indices, zero-pivot replacement, matching"algo5"/"algo6"withir_n_steps = 2) and intest/test_kkt.jl(keyword validation, pipeline selection, a configuration as MadNLP's).Run as plain scripts with the
runtests.jlsetup, CPU backend and CUDA (H200):test_fused684 of 684 inFloat64and inFloat32;test_kkt6389 of 6389; inFloat64test_solve_algo1287 of 287,test_solve304 of 304,test_refinement279 of 279,test_numeric_ldlt919 of 919.Timing (H200, one GPU through Slurm, median of 20,
Float64)KKTSolverwithmatching = "algo6",pivot_epsilon = 1e-10, no refinement.case1354_pegase_k2_10(n = 33,811)case1354_pegase_k2_10the residual without refinement is 2.0e-08 with diagonal pivoting (4 replaced pivots) against 4.3e-06 without pivoting (20 replaced pivots).Not done
test_allocations, the docs build, AMDGPU, oneAPI.test/test_fused.jl, the testset withir_n_steps = 2) measured 101,384 and 101,624 bytes against the earlier oneAPI budget of 98,304. The kernel launch now has 56 arguments (50 before), and oneAPI.jl allocates about 1 KB per argument for a launch with 31 or more; the oneAPI budget is 112 KiB sincedab6205, and the Aurora leg passes. Details in oneAPI: host allocation of the unpivoted fused cycle exceeds its budget after the diagonal-pivoting change (PR #204) #205.Deviations
PLAN.mddefines the fused pipeline without pivoting; this follows the owner's decision to do #167 as maintenance PRs.🤖 Generated with Claude Code
https://claude.ai/code/session_01MsLzHkzHJjM2g5P6ZyZKhr