-
Notifications
You must be signed in to change notification settings - Fork 222
refactor: split host-only members out of CUDA translation units #1801
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
Open
ramakrishnap-nv
wants to merge
7
commits into
main
Choose a base branch
from
split/1-host-device-tus
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0f5ae25
refactor: split host-only members out of CUDA translation units
ramakrishnap-nv 5f80e9e
Merge branch 'main' into split/1-host-device-tus
ramakrishnap-nv 7e5737f
test: add gtest coverage for the host/device solver-settings and CPU …
ramakrishnap-nv e55ebec
test: cover the <int, float> solver_settings_t GPU-facing instantiations
ramakrishnap-nv c92008a
fix: unbreak conda-cpp-build after macro-comma break in solver_settin…
ramakrishnap-nv 4cd9ff1
fix: revert <int, float> solver_settings_t tests, float is never inst…
ramakrishnap-nv c77ffde
Merge remote-tracking branch 'origin/main' into pr-1801
ramakrishnap-nv 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
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 |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| // Device-facing members of solver_settings_t, split out of solver_settings.cu. | ||
| // | ||
| // Everything else in that class is host-only parameter handling, so the remainder now | ||
| // builds as solver_settings.cpp into the CUDA-free cuopt_client library. Only these | ||
| // members take an rmm::cuda_stream_view or hand back a device_uvector, so they are the | ||
| // only ones that must stay in a CUDA TU inside libcuopt. | ||
| // | ||
| // The `template class` instantiation in solver_settings.cpp cannot emit these members | ||
| // (their definitions are not visible there), so they are instantiated explicitly below. | ||
|
|
||
| #include <cuopt/mathematical_optimization/solver_settings.hpp> | ||
|
|
||
| #include <rmm/cuda_stream_view.hpp> | ||
| #include <rmm/device_uvector.hpp> | ||
|
|
||
| #include <mip_heuristics/mip_constants.hpp> | ||
|
|
||
| namespace cuopt { | ||
| namespace CUOPT_EXPORT mathematical_optimization { | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| void solver_settings_t<i_t, f_t>::set_initial_pdlp_primal_solution(const f_t* solution, | ||
| i_t size, | ||
| rmm::cuda_stream_view stream) | ||
| { | ||
| pdlp_settings.set_initial_primal_solution(solution, size, stream); | ||
| } | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| void solver_settings_t<i_t, f_t>::set_initial_pdlp_dual_solution(const f_t* solution, | ||
| i_t size, | ||
| rmm::cuda_stream_view stream) | ||
| { | ||
| pdlp_settings.set_initial_dual_solution(solution, size, stream); | ||
| } | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| void solver_settings_t<i_t, f_t>::set_pdlp_warm_start_data( | ||
| const f_t* current_primal_solution, | ||
| const f_t* current_dual_solution, | ||
| const f_t* initial_primal_average, | ||
| const f_t* initial_dual_average, | ||
| const f_t* current_ATY, | ||
| const f_t* sum_primal_solutions, | ||
| const f_t* sum_dual_solutions, | ||
| const f_t* last_restart_duality_gap_primal_solution, | ||
| const f_t* last_restart_duality_gap_dual_solution, | ||
| i_t primal_size, | ||
| i_t dual_size, | ||
| f_t initial_primal_weight, | ||
| f_t initial_step_size, | ||
| i_t total_pdlp_iterations, | ||
| i_t total_pdhg_iterations, | ||
| f_t last_candidate_kkt_score, | ||
| f_t last_restart_kkt_score, | ||
| f_t sum_solution_weight, | ||
| i_t iterations_since_last_restart) | ||
| { | ||
| pdlp_settings.set_pdlp_warm_start_data(current_primal_solution, | ||
| current_dual_solution, | ||
| initial_primal_average, | ||
| initial_dual_average, | ||
| current_ATY, | ||
| sum_primal_solutions, | ||
| sum_dual_solutions, | ||
| last_restart_duality_gap_primal_solution, | ||
| last_restart_duality_gap_dual_solution, | ||
| primal_size, | ||
| dual_size, | ||
| initial_primal_weight, | ||
| initial_step_size, | ||
| total_pdlp_iterations, | ||
| total_pdhg_iterations, | ||
| last_candidate_kkt_score, | ||
| last_restart_kkt_score, | ||
| sum_solution_weight, | ||
| iterations_since_last_restart); | ||
| } | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| const rmm::device_uvector<f_t>& solver_settings_t<i_t, f_t>::get_initial_pdlp_primal_solution() | ||
| const | ||
| { | ||
| return pdlp_settings.get_initial_primal_solution(); | ||
| } | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| const rmm::device_uvector<f_t>& solver_settings_t<i_t, f_t>::get_initial_pdlp_dual_solution() const | ||
| { | ||
| return pdlp_settings.get_initial_dual_solution(); | ||
| } | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| void solver_settings_t<i_t, f_t>::add_initial_mip_solution(const f_t* solution, | ||
| i_t size, | ||
| rmm::cuda_stream_view stream) | ||
| { | ||
| mip_settings.add_initial_solution(solution, size, stream); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| #if MIP_INSTANTIATE_FLOAT | ||
| template CUOPT_EXPORT void solver_settings_t<int, float>::set_initial_pdlp_primal_solution( | ||
| const float*, int, rmm::cuda_stream_view); | ||
| template CUOPT_EXPORT void solver_settings_t<int, float>::set_initial_pdlp_dual_solution( | ||
| const float*, int, rmm::cuda_stream_view); | ||
| template CUOPT_EXPORT const rmm::device_uvector<float>& | ||
| solver_settings_t<int, float>::get_initial_pdlp_primal_solution() const; | ||
| template CUOPT_EXPORT const rmm::device_uvector<float>& | ||
| solver_settings_t<int, float>::get_initial_pdlp_dual_solution() const; | ||
| template CUOPT_EXPORT void solver_settings_t<int, float>::add_initial_mip_solution( | ||
| const float*, int, rmm::cuda_stream_view); | ||
| // The 19-argument host overload. It was moved into this TU with the rest of the block, but | ||
| // `template class` in solver_settings.cpp cannot emit it (definition not visible there), so | ||
| // without this line the symbol disappears -- and it is the one the Cython layer binds to, | ||
| // which takes down every Python test, docs-build and wheel-test job. | ||
| template CUOPT_EXPORT void solver_settings_t<int, float>::set_pdlp_warm_start_data(const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| const float*, | ||
| int, | ||
| int, | ||
| float, | ||
| float, | ||
| int, | ||
| int, | ||
| float, | ||
| float, | ||
| float, | ||
| int); | ||
| #endif | ||
|
|
||
| #if MIP_INSTANTIATE_DOUBLE | ||
| template CUOPT_EXPORT void solver_settings_t<int, double>::set_initial_pdlp_primal_solution( | ||
| const double*, int, rmm::cuda_stream_view); | ||
| template CUOPT_EXPORT void solver_settings_t<int, double>::set_initial_pdlp_dual_solution( | ||
| const double*, int, rmm::cuda_stream_view); | ||
| template CUOPT_EXPORT const rmm::device_uvector<double>& | ||
| solver_settings_t<int, double>::get_initial_pdlp_primal_solution() const; | ||
| template CUOPT_EXPORT const rmm::device_uvector<double>& | ||
| solver_settings_t<int, double>::get_initial_pdlp_dual_solution() const; | ||
| template CUOPT_EXPORT void solver_settings_t<int, double>::add_initial_mip_solution( | ||
| const double*, int, rmm::cuda_stream_view); | ||
| // The 19-argument host overload. It was moved into this TU with the rest of the block, but | ||
| // `template class` in solver_settings.cpp cannot emit it (definition not visible there), so | ||
| // without this line the symbol disappears -- and it is the one the Cython layer binds to, | ||
| // which takes down every Python test, docs-build and wheel-test job. | ||
| template CUOPT_EXPORT void solver_settings_t<int, double>::set_pdlp_warm_start_data(const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| const double*, | ||
| int, | ||
| int, | ||
| double, | ||
| double, | ||
| int, | ||
| int, | ||
| double, | ||
| double, | ||
| double, | ||
| int); | ||
| #endif | ||
|
|
||
| } // namespace CUOPT_EXPORT mathematical_optimization | ||
| } // namespace cuopt | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.