Skip to content

[MadNLPGPU] cuDSS: recover inertia under matching; guard matching off ubatch - #633

Open
michel2323 wants to merge 2 commits into
masterfrom
ms/cudss-matching-inertia
Open

[MadNLPGPU] cuDSS: recover inertia under matching; guard matching off ubatch#633
michel2323 wants to merge 2 commits into
masterfrom
ms/cudss-matching-inertia

Conversation

@michel2323

@michel2323 michel2323 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

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.

Matching with cuDSS batch solver is not supported.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.91%. Comparing base (e102809) to head (9010247).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michel2323
michel2323 force-pushed the ms/cudss-matching-inertia branch from 0011ceb to 0fcad01 Compare July 20, 2026 16:50
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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frapac @sshin23 @amontoison Is this what we want to do, or do we want to automatically switch to inertia-free if matching is enabled?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your solution is the most appropriate. Are we sure M.diag is the diagonal factor?

@amontoison amontoison Jul 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but we should always check that the factorization is an LDL' before dumping the diagonal D.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@amontoison amontoison Jul 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVIDIA is using an external library for the matching (HSL MC64).
They probably didn't extended it for batch...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@michel2323
michel2323 force-pushed the ms/cudss-matching-inertia branch from 0fcad01 to 2ef3edd Compare July 23, 2026 15:48
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants