-
Notifications
You must be signed in to change notification settings - Fork 209
Remove wrong exception of unsupported QCQP #1493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8bd08e1
Remove a wrong exception for QCQP
rg20 d789f4e
Add QCQP test
rg20 0c63012
Address PR reviews
rg20 ae2fea1
Merge remote-tracking branch 'upstream/main' into qcqp_remove_exception
rg20 8b1fef5
Use ALG1 for older cuda versions
rg20 fb18712
Merge remote-tracking branch 'upstream/main' into qcqp_remove_exception
rg20 d68726e
Merge remote-tracking branch 'upstream/main' into qcqp_remove_exception
rg20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ | |
| #include <cuopt/error.hpp> | ||
| #include <cuopt/mathematical_optimization/io/parser.hpp> | ||
| #include <cuopt/mathematical_optimization/optimization_problem_interface.hpp> | ||
| #include <cuopt/mathematical_optimization/pdlp/solver_settings.hpp> | ||
| #include <cuopt/mathematical_optimization/solve.hpp> | ||
| #include <dual_simplex/solve.hpp> | ||
| #include <dual_simplex/user_problem.hpp> | ||
| #include <linear_algebra/sparse_matrix.hpp> | ||
|
|
@@ -907,4 +909,40 @@ TEST(general_quadratic, rotated_soc_heads_free_rejected) | |
| cuopt::logic_error); | ||
| } | ||
|
|
||
| // Test QCQP with rotated SOC constraint and quadratic objective using high-level API. | ||
| // This is the recommended way to solve QCQP problems. | ||
| // minimize (1/2)*x^2 - x (quadratic objective) | ||
| // subject to x^2 - 2*t*u <= 0 (rotated SOC) | ||
| // t = 1, u = 0.5 | ||
| // Optimal: x = 1, objective = -0.5 | ||
| TEST(general_quadratic, qcqp_rotated_soc) | ||
| { | ||
| raft::handle_t handle{}; | ||
|
|
||
| auto problem = io::read_lp_from_string<i_t, f_t>(R"LP( | ||
| Minimize | ||
| - x + [ x ^2 ] / 2 | ||
| Subject To | ||
| t_eq: t = 1 | ||
| u_eq: u = 0.5 | ||
| rsoc: [ x ^2 - 2 t * u ] <= 0 | ||
| Bounds | ||
| x free | ||
| t >= 0 | ||
| u >= 0 | ||
| End | ||
| )LP"); | ||
|
|
||
| ASSERT_TRUE(problem.has_quadratic_objective()); | ||
| ASSERT_TRUE(problem.has_quadratic_constraints()); | ||
| ASSERT_EQ(problem.get_quadratic_constraints().size(), 1u); | ||
|
|
||
| pdlp_solver_settings_t<i_t, f_t> settings; | ||
| auto solution = solve_lp(&handle, problem, settings); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind leaving a TODO to redo all the other tests in this form? |
||
|
|
||
| EXPECT_EQ(solution.get_termination_status(), pdlp_termination_status_t::Optimal); | ||
| // Optimal: x=1, objective = (1/2)*1 - 1 = -0.5 | ||
| EXPECT_NEAR(solution.get_objective_value(), -0.5, 1e-4); | ||
| } | ||
|
|
||
| } // namespace cuopt::mathematical_optimization::barrier::test | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Can cusparseGetProperty runtime cuSPARSE version differ from CUSPARSE_VER_MAJOR/MINOR compile-time macros when linked dynamically?💡 Result:
Yes, the version reported by the runtime function cusparseGetProperty can differ from the versions defined by the CUSPARSE_VER_MAJOR and CUSPARSE_VER_MINOR compile-time macros [1][2]. Compile-time macros such as CUSPARSE_VER_MAJOR, CUSPARSE_VER_MINOR, and CUSPARSE_VER_PATCH are defined in the cuSPARSE header files (e.g., cusparse.h) available at the time the application is compiled [3][4][5]. These reflect the version of the cuSPARSE SDK used during the build process [1][2]. In contrast, cusparseGetProperty is a runtime API that queries the version of the specific cuSPARSE library (libcusparse.so or.dll) that is dynamically loaded into the application's process at execution time [6][7]. When linking dynamically, the library found at runtime by the system's dynamic linker may be different from the one against which the application was originally compiled (e.g., due to differences in the environment's LD_LIBRARY_PATH or PATH) [8]. This discrepancy is a known challenge in complex deployment environments where the runtime environment may contain a different version of the NVIDIA CUDA Toolkit or individual libraries than the development environment [1][2]. Developers are generally advised to rely on the runtime API (cusparseGetProperty) for features dependent on the loaded library version to ensure compatibility with the actual environment [1][2].
Citations:
CUSPARSE_VERSIONrather thanCUDA_VERSIONto choose how to use cuSPARSE TPL kokkos/kokkos-kernels#2009🏁 Script executed:
Repository: NVIDIA/cuopt
Length of output: 18107
Use the loaded cuSPARSE version for ALG selection
CUSPARSE_VER_*is build-time only, but this file already accounts for runtime/library mismatches elsewhere. Query the runtime cuSPARSE version here too (or cache it in the existing loader helper) so ALG1/ALG2 selection matches the actuallibcusparse.soand doesn’t reintroduce the beta=1 accumulate bug.🤖 Prompt for AI Agents