Skip to content

fix Qc test and added canonicalization to allow CI tests to pass - #1594

Closed
Bubullzz wants to merge 7 commits into
NVIDIA:mainfrom
Bubullzz:mps-reader-fix
Closed

fix Qc test and added canonicalization to allow CI tests to pass#1594
Bubullzz wants to merge 7 commits into
NVIDIA:mainfrom
Bubullzz:mps-reader-fix

Conversation

@Bubullzz

Copy link
Copy Markdown
Contributor

Description

Issue

Checklist

  • I am familiar with the Contributing Guidelines.
  • Testing
    • New or existing tests cover these changes
    • Added tests
    • Created an issue to follow-up
    • NA
  • Documentation
    • The documentation is up to date with these changes
    • Added new documentation
    • NA

@Bubullzz
Bubullzz requested a review from a team as a code owner July 21, 2026 14:55
@Bubullzz
Bubullzz requested review from aliceb-nv and hlinsen July 21, 2026 14:55
@copy-pr-bot

copy-pr-bot Bot commented Jul 21, 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.

@Bubullzz Bubullzz added the non-breaking Introduces a non-breaking change label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

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: 74d91720-f3c9-4769-afff-fe971cf38cba

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4739a and b87f701.

📒 Files selected for processing (1)
  • cpp/src/pdlp/utilities/problem_checking.cuh

📝 Walkthrough

Walkthrough

The fast MPS parser now validates and canonicalizes QCMATRIX COO data before storing quadratic constraints. It adds int64_t canonicalization instantiations, updates an asymmetric QCMATRIX edge fixture, and directly includes the RMM device vector definition.

Changes

QCMATRIX canonicalization

Layer / File(s) Summary
Canonicalization utility support
cpp/src/io/mps_parser.cpp
Adds int64_t explicit instantiations of canonicalize_coo_matrix for float and double.
Fast-parser constraint finalization and validation
cpp/src/io/experimental_mps_fast/fast_parser.cpp, cpp/tests/linear_programming/experimental_mps_fast/fast_parser_edge_test.cpp
Validates and canonicalizes QCMATRIX COO rows, columns, and values before storing quadratic constraints, and extends the bitwise reference fixture with X2 X1 -2.5.

PDLP header dependency

Layer / File(s) Summary
RMM device vector definition
cpp/src/pdlp/utilities/problem_checking.cuh
Replaces the rmm::device_uvector forward declaration with its direct header include.

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

Suggested reviewers: hlinsen, yuwenchen95

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is mostly a template and does not describe the actual code changes. Add a brief summary of the parser canonicalization, test update, and template API changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: fixing Qc parsing/canonicalization so CI tests pass.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cpp/src/io/experimental_mps_fast/fast_parser.cpp (1)

2773-2783: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve valid small QCMATRIX coefficients.

canonicalize_coo_matrix drops every merged value with abs(value) <= epsilon, not only exact cancellations. A legitimate coefficient such as 1e-20 can therefore disappear and change the optimization model. Use an exact-zero or scale-aware cancellation policy, and add a regression case for a small nonzero coefficient. As per path instructions, QCMATRIX canonicalization is correctness-critical.

🤖 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/io/experimental_mps_fast/fast_parser.cpp` around lines 2773 - 2783,
Update canonicalize_coo_matrix in the QCMATRIX path to avoid dropping legitimate
small coefficients: remove only exact cancellations or apply a scale-aware
tolerance that preserves nonzero values such as 1e-20. Keep duplicate merging
and upper-triangular canonicalization intact, and add a regression case covering
a small nonzero QCMATRIX coefficient.

Source: Path instructions

🧹 Nitpick comments (1)
cpp/src/io/experimental_mps_fast/fast_parser.cpp (1)

2773-2783: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid sorting QCMATRIX entries twice.

The perm sort and allocation before this call are redundant because canonicalize_coo_matrix performs its own bucketing and per-row sort. Feed the entries directly into qc or extend the canonicalizer to accept the tuple representation, removing the extra O(n log n) pass in finalization. As per path instructions, avoid extra passes and allocations in hot finalization paths.

🤖 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/io/experimental_mps_fast/fast_parser.cpp` around lines 2773 - 2783,
The QCMATRIX finalization currently sorts entries through perm before
canonicalize_coo_matrix sorts them again. Remove the redundant perm-based
ordering and intermediate reserve/copy path, feeding block.entries directly into
qc or extending canonicalize_coo_matrix to consume the tuple representation
while preserving canonical upper-triangular COO output and avoiding extra
allocations and O(n log n) work.

Source: Path instructions

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

Outside diff comments:
In `@cpp/src/io/experimental_mps_fast/fast_parser.cpp`:
- Around line 2773-2783: Update canonicalize_coo_matrix in the QCMATRIX path to
avoid dropping legitimate small coefficients: remove only exact cancellations or
apply a scale-aware tolerance that preserves nonzero values such as 1e-20. Keep
duplicate merging and upper-triangular canonicalization intact, and add a
regression case covering a small nonzero QCMATRIX coefficient.

---

Nitpick comments:
In `@cpp/src/io/experimental_mps_fast/fast_parser.cpp`:
- Around line 2773-2783: The QCMATRIX finalization currently sorts entries
through perm before canonicalize_coo_matrix sorts them again. Remove the
redundant perm-based ordering and intermediate reserve/copy path, feeding
block.entries directly into qc or extending canonicalize_coo_matrix to consume
the tuple representation while preserving canonical upper-triangular COO output
and avoiding extra allocations and O(n log n) work.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 600971e8-a04c-4b87-85df-f1fffbdf036b

📥 Commits

Reviewing files that changed from the base of the PR and between 1e4e679 and a67fad3.

📒 Files selected for processing (3)
  • cpp/src/io/experimental_mps_fast/fast_parser.cpp
  • cpp/src/io/mps_parser.cpp
  • cpp/tests/linear_programming/experimental_mps_fast/fast_parser_edge_test.cpp

@Bubullzz Bubullzz added the bug Something isn't working label Jul 21, 2026
@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test a67fad3

@aliceb-nv aliceb-nv mentioned this pull request Jul 21, 2026
8 tasks
@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test 897712a

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 0 test job(s) passed.

@Bubullzz Bubullzz added this to the 26.08 milestone Jul 21, 2026

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

Tysm!!! :>

@yuwenchen95

Copy link
Copy Markdown
Contributor

Thanks a lot!

qc.cols.push_back(col);
qc.vals.push_back(val);
}
canonicalize_coo_matrix(qc.rows, qc.cols, qc.vals);

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 just realized we should have symmetric check check_symmetric_offdiagonal_pairs(qc.rows, qc.cols, qc.vals); just before canonicalize_coo_matrix. MPS file assumes symmetric input for off-diagonals in a quadratic constraint. The check_symmetric_offdiagonal_pairs is a new function I introduced after the PR is created, so it is missing in the current multithreaded MPS processing for quadratic constraints.

@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test 6b4739a

@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test b87f701

@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test 32ff68a

@Bubullzz

Copy link
Copy Markdown
Contributor Author

/ok to test d6791ba

@Bubullzz

Copy link
Copy Markdown
Contributor Author

already merged

@Bubullzz Bubullzz closed this Jul 22, 2026
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.

4 participants