Skip to content

Fix leak of stale duals in compute_dual_solution_from_basis - #2124

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mlubin:report13-stale-dual-fix
Oct 14, 2026
Merged

rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mlubin:report13-stale-dual-fix

Conversation

@mlubin

@mlubin mlubin commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

The resize/scatter steps assume that y is initially empty or size zero. (If y is already size m, then resize does not overwrite y with zeros.) That assumption doesn't hold:

if (superbasic_list.size() > 0) {
std::vector<f_t> save_x = solution.x;
i_t primal_push_status = primal_push(
lp, settings, start_time, solution, ft, basic_list, nonbasic_list, superbasic_list, vstatus);
if (primal_push_status < 0) { return return_to_status(primal_push_status); }
compute_dual_solution_from_basis(lp, ft, basic_list, nonbasic_list, solution.y, solution.z);
print_crossover_info(lp, settings, vstatus, solution, "Primal push complete");

At this point in the code, solution.y has already been populated in dual_push.

In practice this appears in the following logging:

Crossover start. Primal residual (abs): 1.35e-06 Primal infeasibility (abs): 0.00e+00
Crossover start. Dual   residual (abs): 1.81e-06 Dual   infeasibility (abs): 0.00e+00
Dual push complete. Primal residual (abs): 1.35e-06 Primal infeasibility (abs): 0.00e+00
Dual push complete. Dual   residual (abs): 2.53e-08 Dual   infeasibility (abs): 0.00e+00
Primal push complete. Primal residual (abs): 1.56e-11 Primal infeasibility (abs): 2.04e-05
Primal push complete. Dual   residual (abs): 1.46e+06 Dual   infeasibility (abs): 6.34e+08

Note the huge dual residual after the primal push.

With the patch instead we get:

Crossover start. Primal residual (abs): 1.35e-06 Primal infeasibility (abs): 0.00e+00
Crossover start. Dual   residual (abs): 1.81e-06 Dual   infeasibility (abs): 0.00e+00
Dual push complete. Primal residual (abs): 1.35e-06 Primal infeasibility (abs): 0.00e+00
Dual push complete. Dual   residual (abs): 2.53e-08 Dual   infeasibility (abs): 0.00e+00
Primal push complete. Primal residual (abs): 1.56e-11 Primal infeasibility (abs): 2.04e-05
Primal push complete. Dual   residual (abs): 2.91e-09 Dual   infeasibility (abs): 3.99e+08
``

@mlubin
mlubin requested a review from a team as a code owner October 14, 2026 01:57
@copy-pr-bot

copy-pr-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mlubin mlubin added bug Something isn't working non-breaking Introduces a non-breaking change labels Oct 14, 2026
@mlubin

mlubin commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 08432ce

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuopt/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 100e8b6e-3fa7-4056-ba0c-49d5253f8aba
📥 Commits

Reviewing files that changed from the base of the PR and between d10c658 and 08432ce.

📒 Files selected for processing: 1
  • cpp/src/dual_simplex/crossover.cpp

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📝 Walkthrough

The crossover function no longer resizes y before solving. It uses y_sparse.to_dense(y) to write the computed dual solution.

Changes: Dual solution conversion

Layer / File(s) Summary
Write the dense dual solution
cpp/src/dual_simplex/crossover.cpp
The function removes the initial resize of y and uses y_sparse.to_dense(y) instead of y_sparse.scatter(y).

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: chris-maes

Merge Risk: ⚪ Minimal · up to 08432

The conversion now replaces stale destination values with the computed dense dual vector. No actionable merge-blocking risk remains; the PR is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the main change: fixing stale dual values in compute_dual_solution_from_basis.
Description check Passed The description directly explains the stale dual issue, its cause, and the observed residual changes from the patch.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chris-maes chris-maes added this to the 26.10 milestone Oct 14, 2026

@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.

The change looks good to me.

I'm not clear on how often this occurs.

@github-actions

Copy link
Copy Markdown

CI Test Summary

✅ All 32 test job(s) passed.

@chris-maes

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 1bf10e1 into NVIDIA:main Oct 14, 2026
98 of 99 checks passed
@mlubin
mlubin deleted the report13-stale-dual-fix branch October 14, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants