Skip to content

Fix adj_list check bug and improve clique cuts#1386

Open
akifcorduk wants to merge 36 commits into
NVIDIA:mainfrom
akifcorduk:main_baselin
Open

Fix adj_list check bug and improve clique cuts#1386
akifcorduk wants to merge 36 commits into
NVIDIA:mainfrom
akifcorduk:main_baselin

Conversation

@akifcorduk
Copy link
Copy Markdown
Contributor

Improve clique cut generation by simplifing the conflict-graph clique table and fix complement-pair handling in clique cut construction drop the paired variable to form a valid fixing cut; detect contradictory variable/complement cliques as infeasible.

Fixes a bug of skipping the small adjacency-list cliques, now we use clique_table_t::empty() function to check all clique data structures.

The mip gap or gap glosed doesn't change significantly but we add on average 1.5 optimal solutions. Tested on 2 batches for main and this PR.

PR_1 -> total_instances: 240, total_feasible: 228, average_error_gap: 10.75, total_optimal: 77, avg_mip_gap: 0.3136, geomean_mip_gap: 0.1990, n_low_error: 129, average_gap_closed: 0.29
PR_2 -> total_instances: 240, total_feasible: 225, average_error_gap: 12.49, total_optimal: 78, avg_mip_gap: 0.3116, geomean_mip_gap: 0.1958, n_low_error: 126, average_gap_closed: 0.29

main_1 -> total_instances: 240, total_feasible: 224, average_error_gap: 13.29, total_optimal: 76, avg_mip_gap: 0.3054, geomean_mip_gap: 0.1938, n_low_error: 124, average_gap_closed: 0.29
main_2 -> total_instances: 240, total_feasible: 228, average_error_gap: 11.04, total_optimal: 76, avg_mip_gap: 0.3243, geomean_mip_gap: 0.2001, n_low_error: 124, average_gap_closed: 0.30

Brings in upstream's unified OpenMP threading model (PR NVIDIA#1099) and other
fixes (NVIDIA#1206 concurrent LP exception cleanup, NVIDIA#1214/NVIDIA#1216 destruction/
capture fixes) while preserving local work on the cut and clique stack.

Conflict resolution highlights:
- Drop std::future/std::async clique flow; adopt upstream's omp task +
  omp_atomic_t<bool> signal_extend pattern.
- Drop modify_problem parameter from find_initial_cliques (we already
  removed the code that consumed it); adapt the omp-task call site in
  branch_and_bound::solve accordingly.
- Take upstream's [this, &population] capture for the root-LP CPUFJ
  improvement callback; the new omp taskwait-before-destruction guarantee
  makes the prior context-lifetime fix unnecessary.
- Take upstream's do_cut_pass refactor of the per-pass LP resolve loop;
  move our per-pass root_lp_with_cuts publish into do_cut_pass so the
  benchmark metric is still updated on early exits.
- Keep our out-of-line omp_mutex_t definitions in omp_helpers.cpp; the
  enhanced omp_atomic_t with std::memory_order is taken from upstream.
generate_clique_cuts() used a hand-rolled emptiness test on only
first + addtl_cliques, so it early-exited and skipped separation when
only small_clique_adj (the small/adjacency-list cliques) was populated.
Use the canonical clique_table_t::empty(), which also accounts for
small_clique_adj, so those smaller clique cuts are generated.

Signed-off-by: akif <akifcorduk@gmail.com>
@akifcorduk akifcorduk added this to the 26.08 milestone Jun 3, 2026
@akifcorduk akifcorduk requested review from a team as code owners June 3, 2026 20:11
@akifcorduk akifcorduk added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Jun 3, 2026
@akifcorduk akifcorduk requested a review from rgsl888prabhu June 3, 2026 20:11
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 3, 2026

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.

@akifcorduk
Copy link
Copy Markdown
Contributor Author

/ok to test 98b1ee2

f_t cut_generation_start_time = tic();
i_t cut_pool_size = 0;
f_t cut_generation_start_time = tic();
auto publish_cut_generation_time = [&](bool force_time_limit_value = false) {
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.

I think it is useful to be able to track cut generation time, but i am commenting on this to discuss.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

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: 6974b6fe-5d75-41f8-830e-f579da170d01

📥 Commits

Reviewing files that changed from the base of the PR and between b3e0eef and bd4228d.

📒 Files selected for processing (2)
  • cpp/src/cuts/cuts.cpp
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh
💤 Files with no reviewable changes (2)
  • cpp/src/cuts/cuts.cpp
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh

📝 Walkthrough

Walkthrough

Adds per-instance MIPLIB gap-stat reporting and root-LP/cut timing telemetry, forwards benchmark pointers through solver components, and refactors clique-table storage/extension to CSR-backed maps with accompanying cut-generation and test updates.

Changes

Benchmark gap reporting

Layer / File(s) Summary
Benchmark metric contracts and solver wiring
cpp/include/cuopt/linear_programming/mip/solver_settings.hpp, cpp/src/dual_simplex/simplex_solver_settings.hpp, cpp/src/mip_heuristics/solver.cu
benchmark_info_t gains root_lp_no_cuts, root_lp_with_cuts, cut_generation_time_sec; simplex_solver_settings_t adds optional benchmark_info_ptr; solver forwards the pointer into branch-and-bound.
Branch-and-bound metric publication
cpp/src/branch_and_bound/branch_and_bound.cpp
Publishes root-LP objectives and cut-generation time at initialization, integer-feasible early return, time-limit/early-return, and after cut-loop completion via a clamped helper.
MIPLIB optimum catalog and gap printer
benchmarks/linear_programming/cuopt/miplib2017_optima.hpp
New header normalizes instance names, embeds MIPLIB2017 optima/infeasible lists, and implements print_miplib_gap_stat that emits one grep-friendly per-instance stats line with known/infeasible/unknown-opt handling.
run_mip reporting integration
benchmarks/linear_programming/cuopt/run_mip.cpp
Includes the new header, prints a post-solve MIPLIBGapStat line using solution and benchmark_info, and refactors the single-run path through a run_single lambda.

Clique table storage and cut-generation refactor

Layer / File(s) Summary
CSR clique storage contracts
cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh
Adds min_extend_work/max_extend_work, introduces csr_var_map_t, replaces unordered-set maps with CSR-backed var_clique_first/var_clique_addtl/small_clique_adj, updates constness and copy/move semantics, and declares fill_var_clique_maps.
Clique build and extension pipeline
cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu
Knapsack conversion drops external set-packing bookkeeping; remove_small_cliques accumulates edges and finalizes CSR; adjacency methods are const and query CSR slices; extend_clique/extend_cliques refactored to a work-budget scheduler; find_initial_cliques signature updated and base cliques always generated.
Clique cut generation and validation
cpp/src/cuts/cuts.cpp, cpp/src/cuts/cuts.hpp, cpp/tests/mip/cuts_test.cu
build_clique_cut uses two-pass complement-pair handling (infeasible/fixing/normal); work estimates include extra adjacency-scan cost; empty checks use clique_table_->empty(); adjacency assertions relaxed; headers and tests aligned with CSR maps.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • yuwenchen95
  • nguidotti
  • rgsl888prabhu
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% 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 concisely captures the main improvements: fixing an adjacency-list check bug and enhancing clique cut generation logic.
Description check ✅ Passed The description clearly relates to the changeset, detailing the complement-pair handling fix, adjacency-list bug fix, and providing relevant benchmark results.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@akifcorduk
Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@akifcorduk
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

✅ Action performed

Full review finished.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benchmarks/linear_programming/cuopt/miplib2017_optima.hpp`:
- Line 25: Replace the lone "`#pragma` once" in the header with a traditional
include guard: remove "`#pragma` once", add an `#ifndef` / `#define` pair using a
unique uppercase macro (e.g.
BENCHMARKS_LINEAR_PROGRAMMING_CUOPT_MIPLIB2017_OPTIMA_HPP) at the top of the
file and close with a matching `#endif` with a trailing comment at the end of the
file; ensure the macro name matches the header (miplib2017_optima.hpp) and is
unique across the repo.

In `@cpp/include/cuopt/linear_programming/mip/solver_settings.hpp`:
- Around line 33-40: The comment incorrectly says the stored LP values are in
the "solver objective sense" which encourages mixing objective spaces; update
the text to state that root_lp_no_cuts and root_lp_with_cuts are published via
compute_user_objective(...) (see branch_and_bound.cpp) and therefore represent
user-space/objective values compatible with MIPLIB comparisons; replace the
phrase "in B&B's solver objective sense" with wording that they are user-space
objectives (or already converted by compute_user_objective) and clarify
quiet_NaN() meaning remains the same.

In `@cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh`:
- Around line 83-95: csr_var_map_t's slice helpers can compute pointers into an
empty indices vector causing UB; change slice_begin(i_t v) and slice_end(i_t v)
to first check if indices.empty() and return nullptr when empty, and update
slice_contains(i_t v, i_t value) to treat a nullptr range as empty (return
false) before calling std::binary_search; keep avg_slice_size() as-is. Also
ensure callers like fill_var_clique_maps / finalize_from_unsorted_pairs /
get_adj_set_of_var / check_adjacency rely on slice_contains or handle a nullptr
range as an empty slice.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9be46e1d-b244-43be-ae7b-4ad7221fb149

📥 Commits

Reviewing files that changed from the base of the PR and between d6d6f9e and 98b1ee2.

📒 Files selected for processing (12)
  • benchmarks/linear_programming/cuopt/miplib2017_optima.hpp
  • benchmarks/linear_programming/cuopt/run_mip.cpp
  • cpp/include/cuopt/linear_programming/mip/solver_settings.hpp
  • cpp/src/branch_and_bound/branch_and_bound.cpp
  • cpp/src/cuts/cuts.cpp
  • cpp/src/cuts/cuts.hpp
  • cpp/src/dual_simplex/simplex_solver_settings.hpp
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh
  • cpp/src/mip_heuristics/solver.cu
  • cpp/src/utilities/omp_helpers.hpp
  • cpp/tests/mip/cuts_test.cu

Comment thread benchmarks/linear_programming/cuopt/miplib2017_optima.hpp
Comment thread benchmarks/linear_programming/cuopt/miplib2017_optima.hpp
Comment thread cpp/include/cuopt/linear_programming/mip/solver_settings.hpp
Comment thread cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cpp/src/utilities/omp_helpers.hpp (1)

31-31: ⚡ Quick win

Remove redundant include.

<utility> is already included unconditionally at line 11, so the guarded include here is redundant.

♻️ Proposed fix
 `#include` <omp.h>
 `#include` <memory>
-#include <utility>
 
 namespace cuopt {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/src/utilities/omp_helpers.hpp` at line 31, Remove the redundant guarded
include of <utility> in omp_helpers.hpp — the header is already included
unconditionally earlier (the "`#include` <utility>" at the top), so delete the
second "`#include` <utility>" occurrence to avoid duplication and keep includes
clean.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cpp/src/branch_and_bound/branch_and_bound.cpp`:
- Around line 2680-2692: The current lambda publish_cut_generation_time
overwrites the measured cut_generation_time with settings_.time_limit whenever
the measured time exceeds the global solver time limit, which overreports
because cut_generation_start_time is taken after earlier solver work; change the
logic so you only force-set cut_generation_time to settings_.time_limit when
force_time_limit_value is true (remove or tighten the condition "||
cut_generation_time > settings_.time_limit"), leaving the actual measured
cut_generation_time otherwise; apply the same change to the analogous code at
the other location (the block around the lines referenced 2743-2745) and keep
references to publish_cut_generation_time, cut_generation_start_time,
force_time_limit_value, and settings_.time_limit.

---

Nitpick comments:
In `@cpp/src/utilities/omp_helpers.hpp`:
- Line 31: Remove the redundant guarded include of <utility> in omp_helpers.hpp
— the header is already included unconditionally earlier (the "`#include`
<utility>" at the top), so delete the second "`#include` <utility>" occurrence to
avoid duplication and keep includes clean.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7f53375c-0094-41f7-8499-7263553edbda

📥 Commits

Reviewing files that changed from the base of the PR and between d6d6f9e and 98b1ee2.

📒 Files selected for processing (12)
  • benchmarks/linear_programming/cuopt/miplib2017_optima.hpp
  • benchmarks/linear_programming/cuopt/run_mip.cpp
  • cpp/include/cuopt/linear_programming/mip/solver_settings.hpp
  • cpp/src/branch_and_bound/branch_and_bound.cpp
  • cpp/src/cuts/cuts.cpp
  • cpp/src/cuts/cuts.hpp
  • cpp/src/dual_simplex/simplex_solver_settings.hpp
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu
  • cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cuh
  • cpp/src/mip_heuristics/solver.cu
  • cpp/src/utilities/omp_helpers.hpp
  • cpp/tests/mip/cuts_test.cu

Comment thread cpp/src/branch_and_bound/branch_and_bound.cpp
@rgsl888prabhu rgsl888prabhu removed request for a team and rgsl888prabhu June 4, 2026 14:51
@akifcorduk
Copy link
Copy Markdown
Contributor Author

/ok to test

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 5, 2026

/ok to test

@akifcorduk, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@akifcorduk
Copy link
Copy Markdown
Contributor Author

/ok to test b3e0eef

@akifcorduk
Copy link
Copy Markdown
Contributor Author

/ok to test bd4228d

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

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant