Skip to content

extend getters on C API#1549

Open
tmckayus wants to merge 2 commits into
NVIDIA:mainfrom
tmckayus:feature/c-api-problem-attributes
Open

extend getters on C API#1549
tmckayus wants to merge 2 commits into
NVIDIA:mainfrom
tmckayus:feature/c-api-problem-attributes

Conversation

@tmckayus

@tmckayus tmckayus commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Additonal getters on cuOptOptimizationProblem. Uses generic get routines for different types and constants to identify the attribute, rather than fixed getters for each attribute.

@tmckayus tmckayus requested review from a team as code owners July 9, 2026 21:48
@tmckayus tmckayus requested review from Iroy30, aliceb-nv, bdice and mlubin July 9, 2026 21:48
@tmckayus tmckayus added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Jul 9, 2026
@tmckayus tmckayus force-pushed the feature/c-api-problem-attributes branch from 79f2f34 to 8a4ee93 Compare July 9, 2026 21:56
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

@coderabbitai

coderabbitai Bot commented Jul 9, 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: 9f3a9e06-76fb-40c0-be57-3590ba745ad3

📥 Commits

Reviewing files that changed from the base of the PR and between 8a4ee93 and 06baf7a.

📒 Files selected for processing (5)
  • cpp/include/cuopt/mathematical_optimization/constants.h
  • cpp/src/pdlp/cuopt_c_attributes.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_test.c
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.h
🚧 Files skipped from review as they are similar to previous changes (3)
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.h
  • cpp/include/cuopt/mathematical_optimization/constants.h
  • cpp/src/pdlp/cuopt_c_attributes.cpp

📝 Walkthrough

Walkthrough

The C API adds problem-attribute selectors and getters, plus a CSC accessor for linear constraint matrices. Implementations expose metadata, arrays, names, and matrix data, while C and C++ tests validate LP, MIP, QP, and created-problem behavior.

Changes

Problem accessor API

Layer / File(s) Summary
Public attribute and matrix contracts
cpp/include/cuopt/mathematical_optimization/constants.h, cpp/include/cuopt/mathematical_optimization/cuopt_c.h
Adds selector constants, generic attribute getter declarations, CSC matrix access, and clarifies linear CSR/CSC behavior.
Attribute getters and CSC export
cpp/src/pdlp/CMakeLists.txt, cpp/src/pdlp/cuopt_c_attributes.cpp
Implements validated scalar, array, string, and CSC accessors and includes the implementation in the adapter build.
Cross-checks and category coverage
cpp/tests/linear_programming/c_api_tests/c_api_test.c, cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp, cpp/tests/linear_programming/c_api_tests/c_api_tests.h
Adds getter consistency checks, CSR/CSC equivalence validation, parser comparisons, and LP, MIP, QP, and created-problem tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: kaatish, akifcorduk, mlubin, ramakrishnap-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% 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 is concise and accurately summarizes the main change: adding generic getters to the C API.
Description check ✅ Passed The description is clearly related to the change and explains the new generic attribute getters on cuOptOptimizationProblem.
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.

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/linear_programming/c_api_tests/c_api_tests.cpp`:
- Around line 797-802: The new QP test in c_api_tests::problem_attributes_qp
depends on quadratic_programming/QP_Test_1.qps, but that fixture is not included
in the dataset provisioning flow. Update the dataset download step or related
dataset manifest/script used by cuopt::test::get_rapids_dataset_root_dir() so
QP_Test_1.qps is downloaded with the other test assets, ensuring this test can
locate the file at runtime.
🪄 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: e0acf068-41ea-4d33-aa75-1ab654dc2651

📥 Commits

Reviewing files that changed from the base of the PR and between 24bf137 and 79f2f34.

📒 Files selected for processing (7)
  • cpp/include/cuopt/mathematical_optimization/constants.h
  • cpp/include/cuopt/mathematical_optimization/cuopt_c.h
  • cpp/src/pdlp/CMakeLists.txt
  • cpp/src/pdlp/cuopt_c_attributes.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_test.c
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.h

Comment thread cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp

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

🧹 Nitpick comments (1)
cpp/tests/linear_programming/c_api_tests/c_api_test.c (1)

3391-3414: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

CSC consistency check is structural-only; it won't catch a mis-populated CSC.

The transpose check compares only per-column nnz counts. A CSC exporter that produces correct column-offset gaps but wrong csc_row indices or csc_val values would still pass. Consider (a) range-checking csc_row[k] ∈ [0, nc) like csr_col is checked at Line 3401, and (b) cross-validating the actual nonzero values between the two layouts (e.g. per (row,col) lookup) so the CSC exporter's payload — not just its shape — is verified.

As per path instructions, added/modified C API tests should validate returned values/consistency (not just "success") and cover CSR-to-CSC consistency.

🤖 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/linear_programming/c_api_tests/c_api_test.c` around lines 3391 -
3414, The CSC validation in the C API test only checks offset structure and
transpose counts, so a bad CSC payload could still pass. Update the test around
cuOptGetConstraintMatrix and cuOptGetConstraintMatrixCSC to also range-check
csc_row entries like csr_col is checked, and add a content-level comparison
between CSR and CSC so the actual row/col/value payloads are verified, not just
the offsets.

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.

Nitpick comments:
In `@cpp/tests/linear_programming/c_api_tests/c_api_test.c`:
- Around line 3391-3414: The CSC validation in the C API test only checks offset
structure and transpose counts, so a bad CSC payload could still pass. Update
the test around cuOptGetConstraintMatrix and cuOptGetConstraintMatrixCSC to also
range-check csc_row entries like csr_col is checked, and add a content-level
comparison between CSR and CSC so the actual row/col/value payloads are
verified, not just the offsets.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 18d59cd8-5a5b-4ae1-9521-6beb92f7c8b0

📥 Commits

Reviewing files that changed from the base of the PR and between 79f2f34 and 8a4ee93.

📒 Files selected for processing (7)
  • cpp/include/cuopt/mathematical_optimization/constants.h
  • cpp/include/cuopt/mathematical_optimization/cuopt_c.h
  • cpp/src/pdlp/CMakeLists.txt
  • cpp/src/pdlp/cuopt_c_attributes.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_test.c
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.h
✅ Files skipped from review due to trivial changes (1)
  • cpp/src/pdlp/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (5)
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp
  • cpp/tests/linear_programming/c_api_tests/c_api_tests.h
  • cpp/include/cuopt/mathematical_optimization/constants.h
  • cpp/include/cuopt/mathematical_optimization/cuopt_c.h
  • cpp/src/pdlp/cuopt_c_attributes.cpp

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