[MadNLPGPU] cuDSS: recover inertia under matching; guard matching off ubatch - #633
[MadNLPGPU] cuDSS: recover inertia under matching; guard matching off ubatch#633michel2323 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #633 +/- ##
=======================================
Coverage 88.91% 88.91%
=======================================
Files 55 55
Lines 5015 5015
=======================================
Hits 4459 4459
Misses 556 556 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0011ceb to
0fcad01
Compare
| elseif M.opt.cudss_algorithm == MadNLP.LDL | ||
| # N.B.: cuDSS does not always return the correct inertia. | ||
| if info == 0 | ||
| if M.opt.cudss_matching |
There was a problem hiding this comment.
@frapac @sshin23 @amontoison Is this what we want to do, or do we want to automatically switch to inertia-free if matching is enabled?
There was a problem hiding this comment.
I think your solution is the most appropriate. Are we sure M.diag is the diagonal factor?
There was a problem hiding this comment.
Yes but we should always check that the factorization is an LDL' before dumping the diagonal D.
There was a problem hiding this comment.
Yes — cuDSS's "diag" data parameter returns the "Diagonal of the factorized matrix", i.e. the D of P·S·A·S·Pᵀ = L·D·Lᵀ (a congruence of A, so its sign counts equal A's inertia by Sylvester's law, matching scaling/permutation included).
Verified empirically on an RTX 4080 with cuDSS 0.8 on KKT-like symmetric indefinite matrices ([H Aᵀ; A -δI], n=70 and n=280): the sign counts of the dumped D match the eigenvalue-count inertia exactly, both with matching off (where it also agrees with cuDSS's native "inertia") and with matching on (where native reports (0, 0)). End-to-end, SparseCondensedKKTSystem + InertiaBased + cudss_matching=true now converges in the identical iteration count/objective as with matching off.
@amontoison addressed in 9010247: the recovery is extracted into inertia_from_diag with a hard @assert cudss_algorithm == MadNLP.LDL, so the LDLᵀ check travels with the code (previously it was only implied by the enclosing branch).
| # cuDSS matching (`matching_alg`) fails the *analysis* phase with | ||
| # CUDSS_STATUS_NOT_SUPPORTED on a uniform-batch solver (through cuDSS 0.8), | ||
| # so never enable it there (e.g. the two-stage per-scenario batch solver). | ||
| Base.@warn "cuDSS matching is not supported on uniform-batch (ubatch) solvers; ignoring `cudss_matching = true` for this batched solver." maxlog = 1 |
There was a problem hiding this comment.
NVIDIA is using an external library for the matching (HSL MC64).
They probably didn't extended it for batch...
There was a problem hiding this comment.
That matches what we observe: the ubatch analysis phase itself returns CUDSS_STATUS_NOT_SUPPORTED as soon as matching_alg is set, so the guard just skips matching with a one-time warning instead of failing the whole batched solver.
… ubatch
cuDSS (through 0.8) stops reporting a usable inertia once matching is
enabled: it returns (0, 0) with info == 0 even though the factorization
is correct. InertiaBased/InertiaAuto then bump regularization forever and
dive into restoration. Recover the inertia from the sign counts of the
factor diagonal ("diag" data parameter) whenever cudss_matching is on,
using a buffer cached on the solver. Exact only for 1x1 pivots, which
holds for the quasi-definite condensed KKT systems this solver targets.
Also skip matching on uniform-batch solvers: setting matching_alg on a
ubatch solver fails the analysis phase with CUDSS_STATUS_NOT_SUPPORTED,
so the two-stage per-scenario batch solver must never enable it.
0fcad01 to
2ef3edd
Compare
…plicit LDL check Review feedback on #633 (amontoison): the factor diagonal D only determines the inertia for an LDL' factorization, so hard-check that before dumping it. Extract the recovery into inertia_from_diag so the guard travels with the code, and document why the dumped "diag" (D of the congruence P*S*A*S*P' = L*D*L') carries A's inertia under matching (frapac's question). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cuDSS (through 0.8) stops reporting a usable inertia once matching is enabled: it returns
(0, 0)withinfo == 0even though the factorization is correct.InertiaBased/InertiaAutothen bump regularization forever and dive into restoration.Matching with cuDSS batch solver is not supported.