Skip to content

Fix dual residual computation in final solution output - #1718

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
yuwenchen95:fix-residual
Aug 14, 2026
Merged

Fix dual residual computation in final solution output#1718
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
yuwenchen95:fix-residual

Conversation

@yuwenchen95

Copy link
Copy Markdown
Contributor

Description

get_lp_stats() reported a spurious, large l2_dual_residual for QPs and SOCPs solved via the barrier path, even at a fully optimal solution. The final-solution dual residual computed in iteration_data_t::to_solution() (cpp/src/barrier/barrier.cu) omitted the Q*x quadratic term, computing only ‖Aᵀy + z − c‖ instead of ‖Aᵀy + z − c − Qx‖.

Adds the missing Q*x term to the reported dual residual, mirroring the existing correct pattern used internally.

Also adds a regression test (qp_diagonal_only_dual_residual) that reuses the diagonal-Hessian QP problem from the linked issue and asserts l2_dual_residual is near zero at the known optimum.

Issue

Closes #1598

Signed-off-by: yuwenchen95 <yuwchen@nvidia.com>
@yuwenchen95 yuwenchen95 added this to the 26.10 milestone Aug 13, 2026
@yuwenchen95 yuwenchen95 self-assigned this Aug 13, 2026
@yuwenchen95
yuwenchen95 requested a review from a team as a code owner August 13, 2026 16:15
@yuwenchen95 yuwenchen95 added bug Something isn't working non-breaking Introduces a non-breaking change barrier labels Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a8158909-d027-454b-8a0a-715f6390ee2a

📥 Commits

Reviewing files that changed from the base of the PR and between 07bd5ea and 83578c0.

📒 Files selected for processing (1)
  • cpp/tests/qp/unit_tests/lp_parser_solve_test.cu
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpp/tests/qp/unit_tests/lp_parser_solve_test.cu

📝 Walkthrough

Walkthrough

The barrier solution calculation now includes Q*x in the dual residual for quadratic objectives. A regression test solves a diagonal QP and validates optimal termination, objective value, and near-zero dual residual.

Changes

Quadratic dual residual

Layer / File(s) Summary
Residual calculation and QP regression
cpp/src/barrier/barrier.cu, cpp/tests/qp/unit_tests/lp_parser_solve_test.cu
The solution residual calculation subtracts Q*x when the quadratic matrix is present. The regression test checks optimal termination, objective -32.0, and a near-zero l2_dual_residual.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to 83578

This localized fix corrects the reported dual-residual calculation and adds a regression test; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: rg20, ramakrishnap-nv, chris-maes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: correcting dual residual computation in final solution output.
Description check ✅ Passed The description accurately explains the missing Q*x term and the regression test added for issue #1598.
Linked Issues check ✅ Passed The PR addresses the dual residual defect and adds the requested regression coverage for the linked issue [#1598].
Out of Scope Changes check ✅ Passed The code changes are limited to dual residual computation and its regression test, with no unrelated changes identified.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Comment thread cpp/tests/qp/unit_tests/lp_parser_solve_test.cu Outdated
Comment thread cpp/tests/qp/unit_tests/lp_parser_solve_test.cu Outdated
Signed-off-by: yuwenchen95 <yuwchen@nvidia.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

@chris-maes chris-maes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks!

@chris-maes

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 22f99dc into NVIDIA:main Aug 14, 2026
183 of 185 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

barrier bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] get_lp_stats() reports garbage dual residual and objective for QPs and SOCPs

3 participants