Skip to content

Fused LDLᵀ: scaling, matching-pair ordering and pivot replacement, so KKT systems that need matching keep the fused speed (follow-up of #193) #194

Closed

Description

@michel2323

Found while working on: no task; follow-up of #193 (the wiring half lands in PR #192: KKTSolver gets matching and a deferred analysis, and chooses the stock pipeline when matching or pivot replacement is asked for).

What: With #193 resolved through the stock pipeline, an interior-point KKT system that needs matching (MadNLP's ShiftedPreset, as its cuDSS preset asks for) no longer runs on the fused pipeline. STATE.md §2 (cuDSS 1.0 comparison, PR #190) puts the stock LDLᵀ with algo5 matching on the K2 dumps at 3.57× cuDSS's factorization time and 4.21× its solve time, so SDSSolver gets cuDSS's iteration count at several times its cost per iteration. The fused LDLᵀ (src/fused.jl) cannot take over because it has none of the three ingredients:

  1. no pivot replacement: a zero or non-finite pivot fails the front (isfinite(dk) && !iszero(dk) in the "S" paths of the fused factorization kernel); pivot_epsilon and pivot_sign are not read;
  2. no scaling: _check_fused_options rejects matching_alg ≠ "none";
  3. no ordering from the matching: the 2×2 pairs of the matching cycles (matching_pairs, 2×2 pivot pairs: fixed candidate tolerance τ = 1e-6 and greedy matching; matching-based pairs (T21) #67) never reach its analysis.

The measurements of #193 suggest these three are enough for the inertia: the row "SDS DirectSolver, static, matching_alg = "algo5", pivot_epsilon = 1e-10" factors with pivot_type = 'N', so every pivot is 1×1 (the reference returns (k, 0) for PIVOT_NONE); what it has over the failing rows is the symmetric scaling D A D, the ordering compressed by the matching pairs, and the ±ε replacement with pivot_sign. It gets 0 wrong inertias of 60 and no failure (median residual 1.1e-06, max 1.0e-05; cuDSS with matching: 6.8e-09 and 4.2e-06). None of the three needs pivoting inside the kernel:

  • scaling: the values enter as dᵢ aᵢⱼ dⱼ (one extra multiply where the fused assembly scatters nzval, or a scaled copy as the stock _numeric_values makes), and the solve scales the right-hand side and the solution as SolveScaling does;
  • ordering: the fused plans are built from the inner DirectSolver's host analysis, which already computes the matching and the pairs;
  • replacement: at the two pivot sites, |d| < ε becomes pivot_sign · ε instead of a failure, counted for "npivots".

Not known: whether a residual near 1e-6 without Bunch–Kaufman is good enough for MadNLP's iteration count on the flowsheet of #193 (the stock Bunch–Kaufman + matching row is at 8.1e-08), and what the replacement costs in the fused kernel.

Why it is out of scope: none in TASKS.md. It does not block a task; it decides whether SDSSolver under MadNLP's ShiftedPreset is competitive with cuDSS in time, not only in iterations.

Suggested fix or plan change: a task "fused LDLᵀ for interior-point KKT systems: symmetric scaling, matching-pair ordering, static pivot replacement", gated on the 60-matrix table of #193 (0 wrong inertias, no failure) and on the fused factor/solve times staying near today's; KKTSolver then selects the fused pipeline for matching ≠ "none" with pivoting = :none. First step before any kernel work: run MadNLP on the flowsheet with the stock static + matching configuration to see whether its residuals give cuDSS's iteration count.

Activity

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

    @michel2323
    MemberAuthor

    Measurement that changes the first step proposed above. Same 60 KKT matrices as the table of #193 (design solve of the CO2 capture flowsheet driven by cuDSS, n = 2657), pivot_epsilon = 1e-10, analysis on the first matrix, then refactorization; residual ‖Ax − b‖∞ / ‖b‖∞ of the 31 factorizations followed by a solve (H200, CUDSS 1.0.0, SDS maint/kkt-solver-0.4.0 at dc6989b, stock DirectSolver with reordering_alg = "algo4" and pivot_sign):

    solver matching pivot ir_n_steps wrong inertia residual, median residual, max replaced pivots, median / max
    cuDSS algo6 (default) 'A' (default) 0 0 6.3e-09 4.2e-06 0 / 4
    cuDSS algo6 'B' 0 0 5.6e-09 4.2e-06 0 / 4
    cuDSS algo6 'N' 0 0 9.4e-05 2.0e-03 41 / 78
    cuDSS algo5 'A' 0 0 5.9e-09 4.2e-06 0 / 4
    cuDSS algo5 'N' 0 0 9.4e-05 2.0e-03 41 / 78
    cuDSS none 'A' 0 6 2.1e-06 3.4e-04 4 / 76
    cuDSS none 'N' 0 10 2.6e-06 3.5e-04 5 / 78
    cuDSS algo6 'N' 1 0 6.4e-10 9.9e-07 41 / 78
    cuDSS algo6 'N' 2 0 2.7e-12 8.8e-10 41 / 78
    SDS stock algo5 'N' (static) 0 0 7.6e-07 1.2e-05 13 / 102
    SDS stock algo5 'N' (static) 1 0 1.8e-12 1.4e-09 13 / 102
    SDS stock algo5 'N' (static) 2 0 6.0e-13 1.6e-11 13 / 102
    SDS stock algo5 Bunch–Kaufman 0 0 6.1e-08 3.1e-06 0 / 4

    No factorization failed in any row.

    What it says for this issue:

    • cuDSS's residual advantage in KKTSolver: static LDLᵀ fails or loses accuracy on an interior-point KKT matrix that cuDSS factors with matching #193 (item 3 there) is its pivoting inside the fronts, not its scaling or matching: with pivot_type = 'N' its median goes from 6e-09 to 9.4e-05. algo5 and algo6 give the same residuals and the same replaced-pivot counts on these matrices, so building the fused path on algo5 loses nothing against cuDSS's default here.
    • Matching alone gives the inertia: every row with matching has 0 wrong of 60, with or without pivoting.
    • One refinement step on the static factorization with matching (1.8e-12) is more accurate than cuDSS's pivoted factorization without refinement (6.3e-09). So the target for the fused pipeline is static + scaling + matching-pair ordering + pivot replacement + one refinement step, without pivoting in the kernel.
    • The static SDS factorization with matching is about 100 times more accurate than cuDSS's (7.6e-07 against 9.4e-05, 13 against 41 replaced pivots in the median). Not investigated; the ordering compressed by the matching pairs and pivot_sign are the candidates.

    Open: FusedSolver rejects ir_n_steps > 0, so the refinement step is either new there or left to MadNLP's own refinement; the rows above ran on the stock pipeline. With Bunch–Kaufman, SDS is about 10 times behind cuDSS in the median (6.1e-08 against 5.6e-09) at the same replaced-pivot counts; not investigated (pivot_threshold, 0.01 here, is one difference).

  3. michel2323 commented on Nov 15, 2026

    @michel2323
    MemberAuthor

    Resolved in 0.4.0: the fused LDLᵀ has static pivot replacement (381572e), matching with scaling and pivot pairs (2c5e879), and iterative refinement (f219ebf); KKTSolver keeps the fused pipeline with matching and pivot replacement (5d38cfa). Instances that still need pivoting inside the fronts are tracked in #167.

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-agentfusedperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions