Skip to content

KKTSolver: static LDLᵀ fails or loses accuracy on an interior-point KKT matrix that cuDSS factors with matching #193

Closed

Description

@michel2323

Found while working on: no task; a trial of MadNLP 0.12 (MadCoreGPU.SDSSolver, madsuite-org/MadNLP.jl#728) with SparseDirectSolver 0.4.0 (#192, dc6989b) on a CO2 capture flowsheet (ExaModels, 1249 variables, 1322 constraints).

What: Under MadNLP's ShiftedPreset the design solve of that flowsheet takes 1550 iterations with SDSSolver and stops at the acceptable level (1e-6); with cuDSS it takes 84 iterations to 1e-8. MadNLP regularizes at every iteration with SDS. The KKT matrices explain it: KKTSolver(...; factorization = :ldl) (static pivots, fused pipeline on CUDA) fails on the second matrix of the solve with info = 888, although the matrix is nonsingular with the expected inertia, and MadNLP reads a failed factorization as a wrong inertia.

MWE (two consecutive KKT matrices of that solve, as the linear solver receives them, i.e. after MadNLP's scaling and dual shift of 1e-10; n = 2657, 1335 primal and 1322 dual rows; script and data): https://gist.github.com/michel2323/0e392ec1d943967fc5748ba5ae397fff

git clone https://gist.github.com/michel2323/0e392ec1d943967fc5748ba5ae397fff mwe
julia --project=<env with CUDA, CUDSS, SparseDirectSolver#maint/kkt-solver-0.4.0> mwe/mwe.jl

Each solver is analyzed and factorized on matrix 1 and refactorizes matrix 2; the residual is ‖Ax − b‖∞ / ‖b‖∞ of one solve without refinement (H200, CUDA 6.5.1, CUDSS 1.0.0, Julia 1.13.3):

matrix 1: n = 2657, inertia from the eigenvalues (1335, 0, 1322), smallest |eigenvalue| 1.1e-10
matrix 2: n = 2657, inertia from the eigenvalues (1335, 0, 1322), smallest |eigenvalue| 3.0e-06
SDS KKTSolver, static (fused pipeline)            info    0 inertia (1335, 0, 1322) residual 8.3e-06  |  info  888 inertia (1335, 0, 1322) residual NaN
SDS KKTSolver, static, fused = false              info    0 inertia (1335, 0, 1322) residual 2.1e-08  |  info    0 inertia (1335, 0, 1322) residual 1.4e-05
SDS KKTSolver, pivoting = :bk                     info    0 inertia (1335, 0, 1322) residual 9.8e-10  |  info    0 inertia (1335, 0, 1322) residual 7.8e-04
SDS DirectSolver, static, matching algo5          info    0 inertia (1335, 0, 1322) residual 8.9e-09  |  info    0 inertia (1335, 0, 1322) residual 1.0e-06
SDS DirectSolver, Bunch-Kaufman, matching algo5   info    0 inertia (1335, 0, 1322) residual 4.9e-09  |  info    0 inertia (1335, 0, 1322) residual 2.7e-07
cuDSS, matching (its default)                     info    0 inertia (1335, 0, 1322) residual 1.1e-10  |  info    0 inertia (1335, 0, 1322) residual 1.1e-08
cuDSS, matching none                              info    0 inertia (1335, 0, 1322) residual 3.8e-08  |  info    0 inertia (1335, 0, 1322) residual 3.1e-04

(The inertia printed with info = 888 is not valid; KKTSolver's inertia is defined for info = 0 only.)

The same variants over the first 60 KKT matrices of a design solve driven by cuDSS (each solver analyzed on the first matrix, then refactorizing; inertia compared with the eigenvalues; residuals of the 31 factorizations that were followed by a solve; these matrices are not in the gist):

solver wrong inertia failed (info ≠ 0) residual, median residual, max
SDS KKTSolver, static, fused (what MadNLP runs) 30 30 6.5e-05 4.3e-01
SDS KKTSolver, static, fused = false, pivot_epsilon = 1e-10 7 0 2.1e-06 2.6e-04
SDS KKTSolver, pivoting = :bk 19 0 1.9e-07 2.0e-02
SDS DirectSolver, static, matching_alg = "algo5", pivot_epsilon = 1e-10 0 0 1.1e-06 1.0e-05
SDS DirectSolver, Bunch–Kaufman, matching_alg = "algo5" 0 0 8.1e-08 2.9e-06
cuDSS, matching default, pivot_epsilon = 1e-10 (MadNLP's preset) 0 0 6.8e-09 4.2e-06
cuDSS, matching_alg = "none", pivot_epsilon = 1e-10 7 0 2.6e-06 9.5e-04

Three things differ from cuDSS:

  1. The fused LDLᵀ replaces no pivot (pivot_epsilon and pivot_sign are not read, as the KKTSolver docstring says), so a small pivot in the static order ends the factorization. cuDSS and the stock pipeline perturb it. This is what MadNLP hits: half of the factorizations fail.
  2. No matching through KKTSolver. Without matching the stock static LDLᵀ behaves like cuDSS with matching_alg = "none" (7 wrong inertias of 60 each, residuals near 1e-6 to 1e-4). With matching_alg = "algo5" the stock DirectSolver gets every inertia right, as cuDSS with matching does. KKTSolver has no keyword for it, and the fused pipeline has no matching.
  3. Residuals with matching are still about 100 times cuDSS's (median 1.1e-06 static, 8.1e-08 with Bunch–Kaufman, against 6.8e-09). Not investigated; which algorithm cuDSS's default matching is, and whether it scales differently, is not known here.

Bunch–Kaufman without matching is not a way out on these matrices: 19 wrong inertias of 60.

Why it is out of scope: none in TASKS.md. It does not block a task, but it decides whether SDSSolver can replace cuDSS under MadNLP's ShiftedPreset on KKT systems like this one.

Suggested fix or plan change: a matching keyword of KKTSolver (stock pipeline, analysis deferred to the first values as MadNLP does for cuDSS), and either pivot replacement in the fused LDLᵀ or fused = nothing choosing the stock pipeline when pivot_epsilon is given. MadNLP's SDSSolver preset would then ask for matching as its cuDSS preset does.

Activity

  1. added
    found-by-agent
    on Nov 10, 2026
  2. michel2323 commented on Nov 15, 2026

    @michel2323
    MemberAuthor

    Resolved in 0.4.0: KKTSolver has the matching keyword and the deferred analysis (ff4d287, PR #192), and the fused LDLᵀ replaces pivots (381572e, see #194). The commits said refs, so the issue stayed open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    found-by-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions