extend getters on C API#1549
Conversation
79f2f34 to
8a4ee93
Compare
CI Test Summary1 failed · 30 passed · 0 skipped
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughChangesThe C API adds generic problem attribute selectors and getters, explicit CSR and CSC linear constraint-matrix accessors, and deprecates the previous matrix getter. Tests cover scalar, array, name, and matrix data across created, ranged, quadratic, and parsed problems. Problem accessors
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
cpp/include/cuopt/mathematical_optimization/constants.hcpp/include/cuopt/mathematical_optimization/cuopt_c.hcpp/src/pdlp/CMakeLists.txtcpp/src/pdlp/cuopt_c_attributes.cppcpp/tests/linear_programming/c_api_tests/c_api_test.ccpp/tests/linear_programming/c_api_tests/c_api_tests.cppcpp/tests/linear_programming/c_api_tests/c_api_tests.h
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/tests/linear_programming/c_api_tests/c_api_test.c (1)
3391-3414: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCSC 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_rowindices orcsc_valvalues would still pass. Consider (a) range-checkingcsc_row[k] ∈ [0, nc)likecsr_colis 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
📒 Files selected for processing (7)
cpp/include/cuopt/mathematical_optimization/constants.hcpp/include/cuopt/mathematical_optimization/cuopt_c.hcpp/src/pdlp/CMakeLists.txtcpp/src/pdlp/cuopt_c_attributes.cppcpp/tests/linear_programming/c_api_tests/c_api_test.ccpp/tests/linear_programming/c_api_tests/c_api_tests.cppcpp/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
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
a8746a5 to
7a3447f
Compare
@tmckayus, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/ |
|
/ok to test 7a3447f |
|
/ok to test 93bf501 |
93bf501 to
4e489ad
Compare
|
/ok to test 4e489ad |
* remove cosmetic static casts in new fuctions * move attribute helpers into cuopt_c.cpp instead of a new file * add cuOptGetConstraintMatrixCSR and deprecate cuOptGetConstraintMatrix * revise/remove comments
Use the create functions with direct comparison of values returned from getters wherever possible. Use mps read for checking getters of names.
Signed-off-by: Trevor McKay <tmgithub1@gmail.com>
4e489ad to
64f505d
Compare
|
/ok to test 64f505d |
| std::vector<cuopt_float_t> values; | ||
| switch (attribute) { | ||
| case CUOPT_ARRAY_ATTR_OBJECTIVE_COEFFICIENTS: | ||
| values = iface->get_objective_coefficients_host(); |
There was a problem hiding this comment.
As a future TODO we can consider changing this interface to pass in a pointer/span to write the coefficients to, avoiding an extra memory allocation and copy.
There was a problem hiding this comment.
do we want to note this formally as a todo in the file?
There was a problem hiding this comment.
actually I'll add an issue for it since this passed CI :)
* simplify tests * move tests to C++ * revise comments * use existing transpose functions in constraint matrix CSC impl
|
/ok to test 4fcec52 |
|
/merge |
Additonal getters on cuOptOptimizationProblem. Uses generic get routines for different types and constants to identify the attribute, rather than fixed getters for each attribute.