-
Notifications
You must be signed in to change notification settings - Fork 222
Add solver caching to support re-solves for barrier QP #1821
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,11 @@ | |
|
|
||
| #include <cuda/std/span> | ||
|
|
||
|
|
||
| namespace cuopt::cython { | ||
| class barrier_cache_t; | ||
| } | ||
|
|
||
| namespace cuopt { | ||
| namespace CUOPT_EXPORT mathematical_optimization { | ||
|
|
||
|
|
@@ -356,6 +361,10 @@ class pdlp_solver_settings_t { | |
| // Used to force batch PDLP to solve a subbatch of the problems at a time | ||
| // The 0 default value will make the solver use its heuristic to determine the subbatch size | ||
| i_t fixed_batch_size{0}; | ||
| /** When true, first GPU barrier/QCQP solve returns a ``barrier_cache_t`` capsule. */ | ||
| bool sequence_solve{false}; | ||
| /** Non-owning cache pointer set by ``call_solve`` for barrier symbolic reuse. */ | ||
| cuopt::cython::barrier_cache_t* barrier_cache{nullptr}; | ||
|
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. Do we want to store |
||
|
|
||
| private: | ||
| /** Initial primal solution */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cuopt/export.hpp> | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <raft/core/handle.hpp> | ||
| #include <rmm/cuda_stream.hpp> | ||
|
|
||
| namespace cuopt::mathematical_optimization::barrier { | ||
| template <typename i_t, typename f_t> | ||
| class iteration_data_t; | ||
|
|
||
| void destroy_iteration_data(iteration_data_t<int, double>* data); | ||
|
|
||
| void apply_barrier_linear_objective(iteration_data_t<int, double>& data, | ||
| double const* barrier_c, | ||
| int n); | ||
| } // namespace cuopt::mathematical_optimization::barrier | ||
|
|
||
| namespace cuopt { | ||
| namespace CUOPT_EXPORT cython { | ||
|
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. Why |
||
|
|
||
| struct barrier_transform_t; | ||
|
|
||
| /** | ||
| * @brief GPU solve cache owned by DataModel when sequence_solve is on. | ||
| * | ||
| * After an Optimal full solve, holds iteration_data_t and the user↔barrier transform. | ||
|
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. Nit: Remove <-> non-ascii character |
||
| * update_q crushes the new linear objective and sets c_dirty so the next Solve | ||
|
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.
|
||
| * reuses that workspace (skip convert/presolve/scaling). | ||
| */ | ||
| class barrier_cache_t { | ||
| public: | ||
| static std::unique_ptr<barrier_cache_t> create(unsigned stream_flags); | ||
|
Comment on lines
+33
to
+42
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. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the public cache API description. Line 37 refers to As per path instructions, “New public functions/classes need Doxygen-style documentation.” 🤖 Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| barrier_cache_t(barrier_cache_t&&) noexcept; | ||
| barrier_cache_t& operator=(barrier_cache_t&&) noexcept; | ||
| ~barrier_cache_t(); | ||
|
|
||
| [[nodiscard]] raft::handle_t* handle_ptr(); | ||
| [[nodiscard]] raft::handle_t const* handle_ptr() const; | ||
| [[nodiscard]] rmm::cuda_stream_view stream_view() const; | ||
|
|
||
| /** Drop cached iteration workspace and transform (handle/stream stay). */ | ||
| void clear(); | ||
|
|
||
| /** | ||
| * @brief Take ownership of barrier iteration workspace. @p data may be null (clears). | ||
| */ | ||
| void store_iteration_data( | ||
| mathematical_optimization::barrier::iteration_data_t<int, double>* data); | ||
|
|
||
| /** | ||
| * @brief Release ownership of cached iteration workspace; caller must delete or wrap it. | ||
| */ | ||
| mathematical_optimization::barrier::iteration_data_t<int, double>* release_iteration_data(); | ||
|
|
||
| void store_transform(std::unique_ptr<barrier_transform_t> transform); | ||
| [[nodiscard]] barrier_transform_t* transform(); | ||
| [[nodiscard]] barrier_transform_t const* transform() const; | ||
| void set_c_dirty(bool dirty); | ||
| [[nodiscard]] bool c_dirty() const; | ||
|
|
||
| /** | ||
| * Crush user-space linear objective into cached iteration_data_t.c / d_c_ and set c_dirty. | ||
| * Requires a stored transform and iteration_data from an Optimal solve. | ||
| */ | ||
| void update_linear_objective(double const* c, int n); | ||
|
|
||
| private: | ||
| barrier_cache_t(std::unique_ptr<rmm::cuda_stream> stream, | ||
| std::unique_ptr<raft::handle_t> handle); | ||
|
|
||
| struct impl; | ||
| std::unique_ptr<impl> impl_; | ||
| }; | ||
|
|
||
| } // namespace CUOPT_EXPORT cython | ||
| } // namespace cuopt | ||
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.
barrier_cache_t should probably live the
cuopt::mathematical_optimizationnamespace