Skip to content

test(mip): Update incumbent callback API test to use a bit more complex problem - #1649

Merged
rapids-bot[bot] merged 7 commits into
mainfrom
fix/incumbent-callback-gb300
Jul 31, 2026
Merged

test(mip): Update incumbent callback API test to use a bit more complex problem#1649
rapids-bot[bot] merged 7 commits into
mainfrom
fix/incumbent-callback-gb300

Conversation

@ramakrishnap-nv

@ramakrishnap-nv ramakrishnap-nv commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1647

Root cause

The 2-variable MIP in _run_incumbent_solutions can be fully solved by presolve on GB300: y=39 is determined by bound tightening from the two constraints, then x=37 follows uniquely. No branch-and-bound runs, so the incumbent callback never fires.

Whether the callback fires for a given problem on a given GPU is tested in test_incumbent_callbacks.py.

…PI test

On fast hardware (GB300), presolve fixes both variables of the 2-variable
MIP directly, so branch-and-bound never runs and the incumbent callback
never fires. The assertion n_callbacks > 0 tests solver behavior, not API
shape. Whether callbacks fire is covered by test_incumbent_callbacks.py
with real MPS files; this test covers registration, argument types, and
no crash.

Fixes #1647
@ramakrishnap-nv
ramakrishnap-nv requested a review from a team as a code owner July 31, 2026 18:04
@ramakrishnap-nv
ramakrishnap-nv requested a review from Iroy30 July 31, 2026 18:04
On fast hardware (GB300), presolve fixes both variables of the 2-variable
MIP directly and no branch-and-bound runs, so the incumbent callback never
fires. Use the same pytest.skip pattern as test_incumbent_callbacks.py
instead of failing hard on n_callbacks == 0.

Fixes #1647
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The incumbent-solution callback test now uses an eight-item binary knapsack model. It validates binary values, capacity feasibility, and objective consistency for each callback solution. Coding conventions prohibit volatile identifiers and hardware names in comments and skip messages.

Changes

Incumbent callback test

Layer / File(s) Summary
Update callback model and validation
python/cuopt/cuopt/tests/linear_programming/test_python_API.py, skills/cuopt-developer/SKILL.md
The test uses an eight-item binary knapsack model and validates each callback solution. Coding conventions add restrictions for volatile identifiers and hardware names in comments and skip messages.

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

Suggested reviewers: iroy30

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The skills documentation update about volatile comments is unrelated to the incumbent callback test fix in issue #1647. Remove the unrelated skills documentation change or provide a clear link between that documentation update and issue #1647.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #1647 by removing the callback-count requirement that can fail when presolve completes the MIP.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly identifies the update to the incumbent callback API test and describes the use of a more complex problem.
Description check ✅ Passed The description explains the presolve root cause, the callback test behavior, and the intended fix for issue #1647.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/incumbent-callback-gb300

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@python/cuopt/cuopt/tests/linear_programming/test_python_API.py`:
- Around line 448-449: Update the callback-registration test around
settings.set_mip_callback to assert that the registered callback is the same
object as get_callback after registration. Keep zero callback invocations valid
and retain the existing API-shape checks, but do not rely on callback-count
assertions to verify registration.
- Around line 446-448: Generalize the explanatory comment in the test around
_run_incumbent_solutions to state that n_callbacks may be zero when the solver
produces no intermediate incumbent, without attributing this specifically to
presolve or branch-and-bound behavior. Keep zero callback invocations valid and
retain the API-shape focus of the test.
🪄 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: 9cbeadc0-ef53-4c93-85b7-4e6885206b84

📥 Commits

Reviewing files that changed from the base of the PR and between ef0d785 and 6b1cfc0.

📒 Files selected for processing (1)
  • python/cuopt/cuopt/tests/linear_programming/test_python_API.py

Comment thread python/cuopt/cuopt/tests/linear_programming/test_python_API.py Outdated
Comment on lines +448 to +449
# n_callbacks may be 0. This test covers API shape only: registration,
# argument types, and no crash.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Verify callback registration independently of invocation.

When the solver emits no incumbent, the solution-validation loop is empty. The test can then pass if settings.set_mip_callback silently stops retaining get_callback. Add an identity check after registration, but keep zero callback invocations valid.

Proposed assertion
     settings.set_mip_callback(get_callback, user_data)
+    assert any(
+        callback is get_callback
+        for callback in settings.get_mip_callbacks()
+    )

As per path instructions, removing the callback-count assertion must still leave meaningful callback-registration coverage.

🤖 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 `@python/cuopt/cuopt/tests/linear_programming/test_python_API.py` around lines
448 - 449, Update the callback-registration test around
settings.set_mip_callback to assert that the registered callback is the same
object as get_callback after registration. Keep zero callback invocations valid
and retain the existing API-shape checks, but do not rely on callback-count
assertions to verify registration.

Source: Path instructions

@mlubin

mlubin commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This doesn't feel like the right fix to me. Either we set up the code path so it deterministically calls the callback or we test something else.

@mlubin

mlubin commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Why does presolve behavior on a two-variable problem vary by GPU?

…er pointer

Add keywords to the conventions.md pointer so searches for 'stale',
'hardware', 'issue number', or 'skip message' hit the pointer and
redirect to references/conventions.md where the rule lives.
@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

Why does presolve behavior on a two-variable problem vary by GPU?

This happens intermittently and may not be connected to GPU exactly. But I agree with the other comment, it is better to add an example which will for sure get incumbent detail rather than skipping it.

Comment thread skills/cuopt-developer/SKILL.md Outdated
## Coding Conventions

For C++ naming (`snake_case`, `d_`/`h_` prefixes, `_t` suffix), file extensions (`.hpp`/`.cpp`/`.cu`/`.cuh` and which compiler each uses), include order, Python style, error handling (`CUOPT_EXPECTS`, `RAFT_CUDA_TRY`), memory management (RMM patterns, no raw `new`/`delete`), and test-impact rules, see [references/conventions.md](references/conventions.md).
For C++ naming (`snake_case`, `d_`/`h_` prefixes, `_t` suffix), file extensions (`.hpp`/`.cpp`/`.cu`/`.cuh` and which compiler each uses), include order, Python style, error handling (`CUOPT_EXPECTS`, `RAFT_CUDA_TRY`), memory management (RMM patterns, no raw `new`/`delete`), test-impact rules, and volatile-comment rules (no PR numbers, commit hashes, issue links, or hardware names in comments or skip messages — these go stale), see [references/conventions.md](references/conventions.md).

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.

PR numbers, commit hashes, and issue links don't go stale.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Stale in the sense out of context or doesn't have valid information. But I agree with issue number though. But claude use it in another way where it added issue number for which it was adding this PR, which doesn't add any value.

@ramakrishnap-nv ramakrishnap-nv self-assigned this Jul 31, 2026
@ramakrishnap-nv ramakrishnap-nv added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Jul 31, 2026
@mlubin

mlubin commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This happens intermittently

Why does presolve behave nondeterministically on a two variable problem?

@ramakrishnap-nv

ramakrishnap-nv commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

This happens intermittently

Why does presolve behave nondeterministically on a two variable problem?

Unsure, I have seen this problem happen in other test as well, where I had to skip in case it couldn't find one. https://github.com/NVIDIA/cuopt/pull/1512/changes#diff-3db7ef937cb0c65153bfa4aa4378af5326fb873b9fdd29fb240e141b1f9c68de

The original 2-variable MIP was solved without branch-and-bound on some
hardware, so the incumbent callback never fired. Replace it with an 8-item
0-1 knapsack whose LP relaxation is fractional, requiring B&B and
guaranteeing at least one incumbent callback.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@python/cuopt/cuopt/tests/linear_programming/test_python_API.py`:
- Around line 423-425: Remove the n_callbacks > 0 assertion from the callback
test and delete or correct the inaccurate claim that the highest-ratio item does
not fit exactly. Keep callback registration and callback argument-shape
validation independent of whether GetSolutionCallback is invoked, without adding
reliance on nondeterministic solver behavior.
- Around line 454-465: Strengthen the validation loop over
get_callback.solutions by asserting each sol["solution"] vector has the expected
item count and that every entry is numerically close to either 0 or 1 before
checking capacity and cost. Keep the existing tolerance-based capacity and
objective assertions, using the test’s n, tol, and established numerical
assertion conventions.
🪄 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: 26b3090a-ab2b-42b1-b803-d2c573ab3fa8

📥 Commits

Reviewing files that changed from the base of the PR and between 4dc3f84 and 496e4f5.

📒 Files selected for processing (1)
  • python/cuopt/cuopt/tests/linear_programming/test_python_API.py

Comment on lines +423 to +425
# (the highest-ratio item doesn't fit exactly), so B&B is required and
# the incumbent callback is guaranteed to fire when a feasible integer
# solution is found.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major

Remove the callback-count requirement.

Line 452 reintroduces the flaky n_callbacks > 0 assertion. A fractional LP relaxation proves an integrality gap, but it does not guarantee branch-and-bound or a GetSolutionCallback invocation. Root cuts or heuristics can complete the solve without an intermediate incumbent. Lines 423-425 also contain a factual error: the highest-ratio item has weight 1 and fits exactly.

Remove the count assertion, or use a solver-documented deterministic callback trigger. Keep callback registration and argument-shape checks independent of invocation count.

As per path instructions, Python callback tests must not rely on nondeterministic callback invocation.

Also applies to: 452-452

🤖 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 `@python/cuopt/cuopt/tests/linear_programming/test_python_API.py` around lines
423 - 425, Remove the n_callbacks > 0 assertion from the callback test and
delete or correct the inaccurate claim that the highest-ratio item does not fit
exactly. Keep callback registration and callback argument-shape validation
independent of whether GetSolutionCallback is invoked, without adding reliance
on nondeterministic solver behavior.

Source: Path instructions

Comment thread python/cuopt/cuopt/tests/linear_programming/test_python_API.py
- Correct inaccurate comment about 'highest-ratio item' (greedy fill
  leaves a partial item, not necessarily the highest-ratio one)
- Add len check and binary-value assertion (each entry must be 0 or 1)
  to the incumbent solution validation loop
@ramakrishnap-nv
ramakrishnap-nv requested a review from mlubin July 31, 2026 20:17
@ramakrishnap-nv ramakrishnap-nv changed the title test(mip): remove solver-behavior assertion from incumbent callback API test test(mip): Update incumbent callback API test to use a bit more complex problem Jul 31, 2026

@Iroy30 Iroy30 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding a robust callback test!

@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

/merge

@rapids-bot
rapids-bot Bot merged commit d3520f4 into main Jul 31, 2026
93 checks passed
rapids-bot Bot pushed a commit that referenced this pull request Jul 31, 2026
GB300 has been fixed by #1649.

This reverts commit 1637fb0.

## Issue
#1647

Authors:
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #1651
@ramakrishnap-nv
ramakrishnap-nv deleted the fix/incumbent-callback-gb300 branch September 9, 2026 14:26
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.

[BUG] Failing tests on GB300

3 participants