Skip to content

Bug fix: Insert barrier slack columns in front of the cone block for range rows - #2029

Open
yuwenchen95 wants to merge 2 commits into
NVIDIA:mainfrom
yuwenchen95:fix-range-row-slack-cone-order
Open

yuwenchen95 wants to merge 2 commits into
NVIDIA:mainfrom
yuwenchen95:fix-range-row-slack-cone-order

Conversation

@yuwenchen95

Copy link
Copy Markdown
Contributor

Description

Keep [linear | slacks | cone] layout, which is missing for range row in presolve.

Signed-off-by: yuwenchen95 <yuwchen@nvidia.com>
@yuwenchen95 yuwenchen95 added this to the 26.10 milestone Oct 1, 2026
@yuwenchen95
yuwenchen95 requested review from chris-maes and rg20 October 1, 2026 08:47
@yuwenchen95 yuwenchen95 self-assigned this Oct 1, 2026
@yuwenchen95
yuwenchen95 requested a review from a team as a code owner October 1, 2026 08:47
@yuwenchen95 yuwenchen95 added bug Something isn't working non-breaking Introduces a non-breaking change barrier labels Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: ef0f96cc-ca02-4b4c-9dbe-9f67653f7390

📥 Commits

Reviewing files that changed from the base of the PR and between e380ddc and efa590e.

📒 Files selected for processing (1)
  • cpp/src/dual_simplex/presolve.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

Walkthrough

Presolve initializes the quadratic matrix before constraint conversion. Less-than and range rows use shared slack insertion before cone variables, with updates to the constraint and quadratic matrices. Two barrier solver tests cover SOC problems with linear and quadratic objectives.

Changes

SOC slack-column conversion

Layer / File(s) Summary
Quadratic matrix setup
cpp/src/dual_simplex/presolve.cpp
convert_user_problem initializes Q from user-provided offsets, indices, and values before constraint conversion. The later quadratic-matrix initialization is removed.
Slack conversion and SOC tests
cpp/src/dual_simplex/presolve.cpp, cpp/tests/socp/solve_barrier_socp.cu
Less-than and range-row conversion use insert_slack_columns to update A, Q indices, and cone_var_start. Barrier tests cover SOC problems with linear and quadratic objectives.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: akifcorduk, aliceb-nv

Merge Risk: ⚪ Minimal · up to efa59

The reviewed presolve changes preserve the quadratic terms and ranged-row feasible intervals. No actionable merge-blocking issue was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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 9 functions across 2 files. 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 identifies the main change: inserting barrier slack columns before cone variables for range rows.
Description check ✅ Passed The description directly explains that presolve must preserve the [linear | slacks | cone] layout for range rows.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

CI Test Summary

1 failed · 31 passed · 0 skipped

conda-cpp-tests / 12.2.2, 3.11, arm64, ubuntu22.04, a100, latest-driver, latest-deps — 2 failed tests
  • DefaultServerTests.DeleteQueuedJobPreventsRun
  • DefaultServerTests.DeleteRunningJobCancelsWorker

Comment thread cpp/src/dual_simplex/presolve.cpp Outdated
return 0;
}

// Insert slacks and keep [linear | slacks | cone] layout

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.

I'm worried about this layout for the future: MIP relies on slacks being last.

We don't have an MISOCP solver now. But I think we have a conflict where both the MIP solver and the cone solver want certain variables to appear last.


// Insert slacks and keep [linear | slacks | cone] layout
template <typename i_t, typename f_t>
static void insert_slack_columns(lp_problem_t<i_t, f_t>& problem,

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.

Please add a comment here explaining what this code is doing mathematically.

What are the inputs? What is rows? What is coefficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Add comments for input parameters.

problem.Q.m = problem.num_cols;
problem.Q.n = problem.num_cols;
problem.Q.nz_max = user_problem.Q_values.size();
problem.Q.row_start.assign(user_problem.Q_offsets.begin(),

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.

What about problem.Q.row_start from user_problem.num_cols to problem.num_cols?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just Q copy from user_problem to problem. Maybe I'd better change lines
problem.Q.m = problem.num_cols; problem.Q.n = problem.num_cols; to problem.Q.m = user_problem.num_cols; problem.Q.n = user_problem.num_cols; for clearer purpose.

problem.upper.insert(problem.upper.begin() + insert_at, upper.begin(), upper.end());

if (problem.Q.n > 0) {
// Slacks have empty Q rows and columns: add the empty rows, then shift the column indices

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.

Does it make sense to put the slacks into the middle? If we can have quadratic objective terms on cone variables, we know have a gap in the matrix. If we put slacks at the end we could use a smaller representation for Q, since we know that slacks can't participate in Q.

yuwenchen95 added a commit to yuwenchen95/cuopt that referenced this pull request Oct 2, 2026
…perf

Brings in upstream main up to the PR's base. Conflict resolutions:
- cusparse_view.cu: keep the on-device CSR build; port the device-side
  alg2_beta_bug_possible check so all three constructors set
  beta_bug_possible_{,transpose_} for the upstream ALG1/ALG2 selection.
- iterative_refinement.hpp: keep the fixed_point/gmres method argument,
  drop the default tol as upstream did.
- barrier.cu: keep the IR method enum, adopt upstream's
  use_high_accuracy_ir tolerance and switch.
- pdlp/solve.cu: keep barrier_relative_complementarity_tol.
- grpc codegen: regenerated from the merged field_registry.yaml.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: yuwenchen95 <yuwchen@nvidia.com>
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.

3 participants