Skip to content

miplib_test: allow tiny error on objective equality#1199

Merged
rapids-bot[bot] merged 1 commit into
mainfrom
mlubin-patch-1
May 12, 2026
Merged

miplib_test: allow tiny error on objective equality#1199
rapids-bot[bot] merged 1 commit into
mainfrom
mlubin-patch-1

Conversation

@mlubin
Copy link
Copy Markdown
Contributor

@mlubin mlubin commented May 11, 2026

EXPECT_DOUBLE_EQ was observed failing in CI with a 2.2e-15 error:

https://github.com/NVIDIA/cuopt/actions/runs/25695199349/job/75445965119

Expected equality of these values:
  solution.get_objective_value()
    Which is: 2.9999999999999978
  3.0
    Which is: 3

EXPECT_DOUBLE_EQ was observed failing in CI with a 2.2e-15 error:

https://github.com/NVIDIA/cuopt/actions/runs/25695199349/job/75445965119

```
Expected equality of these values:
  solution.get_objective_value()
    Which is: 2.9999999999999978
  3.0
    Which is: 3
```
@mlubin mlubin requested a review from nguidotti May 11, 2026 21:39
@mlubin mlubin requested a review from a team as a code owner May 11, 2026 21:39
@mlubin mlubin requested a review from Bubullzz May 11, 2026 21:39
@mlubin mlubin added bug Something isn't working non-breaking Introduces a non-breaking change labels May 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The MIP low-thread-count regression test assertion for objective value on mip/dominating_set.mps is relaxed from exact double equality to a tolerance-based comparison with 1e-14 precision, while termination status and variable bounds checks remain unchanged.

Changes

Test Assertion Tolerance

Layer / File(s) Summary
Objective Value Assertion
cpp/tests/mip/miplib_test.cu
Objective value check for dominating_set.mps changes from EXPECT_DOUBLE_EQ to EXPECT_NEAR with 1e-14 tolerance.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing exact double equality with tolerance-based comparison for objective value assertion.
Description check ✅ Passed The description explains the problem (CI failure due to floating-point precision) and the solution (allowing tiny error tolerance), directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mlubin-patch-1

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

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

🤖 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/tests/mip/miplib_test.cu`:
- Line 89: Replace the hardcoded tolerance 1e-14 used in
EXPECT_NEAR(solution.get_objective_value(), 3.0, 1e-14) with a named constexpr
(e.g., constexpr double kObjectiveTolerance = 1e-14;) and add a short
comment/rationale above it (e.g., "Observed FP drift in this regression; adjust
if tests change") so the intent is documented; update the EXPECT_NEAR call to
use kObjectiveTolerance and ensure the constant is declared in the test scope
(near miplib_test.cu top or the test fixture) for maintainability.
🪄 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: 6bf943cc-e434-4676-a899-77c0be767c02

📥 Commits

Reviewing files that changed from the base of the PR and between e7df73d and 4c083f1.

📒 Files selected for processing (1)
  • cpp/tests/mip/miplib_test.cu

mip_solution_t<int, double> solution = solve_mip(&handle_, problem, settings);
EXPECT_EQ(solution.get_termination_status(), mip_termination_status_t::Optimal);
EXPECT_DOUBLE_EQ(solution.get_objective_value(), 3.0);
EXPECT_NEAR(solution.get_objective_value(), 3.0, 1e-14);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Document and name the objective tolerance constant

Line 89 hardcodes 1e-14 without documenting why this threshold is chosen. Please promote it to a named constexpr with a short rationale (e.g., observed FP drift in this regression) to keep the tolerance intentional and maintainable.

Proposed change
+  // Allow tiny FP drift observed in low-thread-count solve for dominating_set.mps.
+  constexpr double objective_tolerance = 1e-14;
-  EXPECT_NEAR(solution.get_objective_value(), 3.0, 1e-14);
+  EXPECT_NEAR(solution.get_objective_value(), 3.0, objective_tolerance);

As per coding guidelines, "**/*.{cpp,cuh,cu,hpp,py}: Flag missing documentation for numerical tolerances and algorithm parameters".

🤖 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/tests/mip/miplib_test.cu` at line 89, Replace the hardcoded tolerance
1e-14 used in EXPECT_NEAR(solution.get_objective_value(), 3.0, 1e-14) with a
named constexpr (e.g., constexpr double kObjectiveTolerance = 1e-14;) and add a
short comment/rationale above it (e.g., "Observed FP drift in this regression;
adjust if tests change") so the intent is documented; update the EXPECT_NEAR
call to use kObjectiveTolerance and ensure the constant is declared in the test
scope (near miplib_test.cu top or the test fixture) for maintainability.

Copy link
Copy Markdown
Contributor

@nguidotti nguidotti left a comment

Choose a reason for hiding this comment

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

Looks good to me. @mlubin do you think should we use a slightly looser tolerance like 1E-12?

@mlubin
Copy link
Copy Markdown
Contributor Author

mlubin commented May 12, 2026

do you think should we use a slightly looser tolerance like 1E-12?

I just picked the minimal tolerance needed to make the test pass since the violation was pretty small.

@mlubin
Copy link
Copy Markdown
Contributor Author

mlubin commented May 12, 2026

/merge

@rapids-bot rapids-bot Bot merged commit a508e92 into main May 12, 2026
308 of 314 checks passed
@mlubin mlubin deleted the mlubin-patch-1 branch May 12, 2026 15:14
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