Skip to content

Commit ea05ba1

Browse files
authored
No cuda graph in batched pdlp (#225)
Temporarly disable cuda graph in batched PDLP until we find the root cause. This allows use to re-enable the tests on the Python side Closes #207 Authors: - Nicolas Blin (https://github.com/Kh4ster) Approvers: - Akif ÇÖRDÜK (https://github.com/akifcorduk) - Trevor McKay (https://github.com/tmckayus) URL: #225
1 parent c5bcf44 commit ea05ba1

16 files changed

Lines changed: 111 additions & 68 deletions

File tree

cpp/include/cuopt/linear_programming/solve.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ optimization_problem_solution_t<i_t, f_t> solve_lp(
5151
optimization_problem_t<i_t, f_t>& op_problem,
5252
pdlp_solver_settings_t<i_t, f_t> const& settings = pdlp_solver_settings_t<i_t, f_t>{},
5353
bool problem_checking = true,
54-
bool use_pdlp_solver_mode = true);
54+
bool use_pdlp_solver_mode = true,
55+
bool is_batch_mode = false);
5556

5657
/**
5758
* @brief Linear programming solve function.

cpp/include/cuopt/linear_programming/utilities/cython_solve.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ struct solver_ret_t {
104104

105105
std::unique_ptr<solver_ret_t> call_solve(cuopt::mps_parser::data_model_view_t<int, double>*,
106106
linear_programming::solver_settings_t<int, double>*,
107-
unsigned int flags = cudaStreamNonBlocking);
107+
unsigned int flags = cudaStreamNonBlocking,
108+
bool is_batch_mode = false);
108109

109110
std::pair<std::vector<std::unique_ptr<solver_ret_t>>, double> call_batch_solve(
110111
std::vector<cuopt::mps_parser::data_model_view_t<int, double>*>,

cpp/src/linear_programming/pdhg.cu

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ namespace cuopt::linear_programming::detail {
3535

3636
template <typename i_t, typename f_t>
3737
pdhg_solver_t<i_t, f_t>::pdhg_solver_t(raft::handle_t const* handle_ptr,
38-
problem_t<i_t, f_t>& op_problem_scaled)
38+
problem_t<i_t, f_t>& op_problem_scaled,
39+
bool is_batch_mode)
3940
: handle_ptr_(handle_ptr),
4041
stream_view_(handle_ptr_->get_stream()),
4142
problem_ptr(&op_problem_scaled),
@@ -57,8 +58,8 @@ pdhg_solver_t<i_t, f_t>::pdhg_solver_t(raft::handle_t const* handle_ptr,
5758
reusable_device_scalar_value_0_{0.0, stream_view_},
5859
reusable_device_scalar_value_neg_1_{f_t(-1.0), stream_view_},
5960
reusable_device_scalar_1_{stream_view_},
60-
graph_all{stream_view_},
61-
graph_prim_proj_gradient_dual{stream_view_},
61+
graph_all{stream_view_, is_batch_mode},
62+
graph_prim_proj_gradient_dual{stream_view_, is_batch_mode},
6263
d_total_pdhg_iterations_{0, stream_view_}
6364
{
6465
}

cpp/src/linear_programming/pdhg.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ namespace cuopt::linear_programming::detail {
3131
template <typename i_t, typename f_t>
3232
class pdhg_solver_t {
3333
public:
34-
pdhg_solver_t(raft::handle_t const* handle_ptr, problem_t<i_t, f_t>& op_problem);
34+
pdhg_solver_t(raft::handle_t const* handle_ptr,
35+
problem_t<i_t, f_t>& op_problem,
36+
bool is_batch_mode = false);
3537

3638
saddle_point_state_t<i_t, f_t>& get_saddle_point_state();
3739
cusparse_view_t<i_t, f_t>& get_cusparse_view();

cpp/src/linear_programming/pdlp.cu

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void set_pdlp_hyper_parameters(rmm::cuda_stream_view stream_view)
5353

5454
template <typename i_t, typename f_t>
5555
pdlp_solver_t<i_t, f_t>::pdlp_solver_t(problem_t<i_t, f_t>& op_problem,
56-
pdlp_solver_settings_t<i_t, f_t> const& settings)
56+
pdlp_solver_settings_t<i_t, f_t> const& settings,
57+
bool is_batch_mode)
5758
: handle_ptr_(op_problem.handle_ptr),
5859
stream_view_(handle_ptr_->get_stream()),
5960
problem_ptr(&op_problem),
@@ -67,8 +68,8 @@ pdlp_solver_t<i_t, f_t>::pdlp_solver_t(problem_t<i_t, f_t>& op_problem,
6768
dual_step_size_{stream_view_},
6869
primal_weight_{stream_view_},
6970
step_size_{(f_t)pdlp_hyper_params::initial_step_size_scaling, stream_view_},
70-
step_size_strategy_{handle_ptr_, &primal_weight_, &step_size_},
71-
pdhg_solver_{handle_ptr_, op_problem_scaled_},
71+
step_size_strategy_{handle_ptr_, &primal_weight_, &step_size_, is_batch_mode},
72+
pdhg_solver_{handle_ptr_, op_problem_scaled_, is_batch_mode},
7273
settings_(settings, stream_view_),
7374
initial_scaling_strategy_{handle_ptr_,
7475
op_problem_scaled_,
@@ -100,7 +101,8 @@ pdlp_solver_t<i_t, f_t>::pdlp_solver_t(problem_t<i_t, f_t>& op_problem,
100101
op_problem,
101102
average_op_problem_evaluation_cusparse_view_,
102103
primal_size_h_,
103-
dual_size_h_},
104+
dual_size_h_,
105+
is_batch_mode},
104106
average_termination_strategy_{handle_ptr_,
105107
op_problem,
106108
average_op_problem_evaluation_cusparse_view_,

cpp/src/linear_programming/pdlp.cuh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class pdlp_solver_t {
6565
*/
6666
pdlp_solver_t(
6767
problem_t<i_t, f_t>& op_problem,
68-
pdlp_solver_settings_t<i_t, f_t> const& settings = pdlp_solver_settings_t<i_t, f_t>{});
68+
pdlp_solver_settings_t<i_t, f_t> const& settings = pdlp_solver_settings_t<i_t, f_t>{},
69+
bool is_batch_mode = false);
6970

7071
optimization_problem_solution_t<i_t, f_t> run_solver(
7172
const std::chrono::high_resolution_clock::time_point& start_time);

cpp/src/linear_programming/restart_strategy/pdlp_restart_strategy.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ pdlp_restart_strategy_t<i_t, f_t>::pdlp_restart_strategy_t(
108108
problem_t<i_t, f_t>& op_problem,
109109
const cusparse_view_t<i_t, f_t>& cusparse_view,
110110
const i_t primal_size,
111-
const i_t dual_size)
111+
const i_t dual_size,
112+
bool is_batch_mode)
112113
: handle_ptr_(handle_ptr),
113114
stream_view_(handle_ptr_->get_stream()),
114-
weighted_average_solution_{handle_ptr_, primal_size, dual_size},
115+
weighted_average_solution_{handle_ptr_, primal_size, dual_size, is_batch_mode},
115116
primal_size_h_(primal_size),
116117
dual_size_h_(dual_size),
117118
problem_ptr(&op_problem),

cpp/src/linear_programming/restart_strategy/pdlp_restart_strategy.cuh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class pdlp_restart_strategy_t {
101101
problem_t<i_t, f_t>& op_problem,
102102
const cusparse_view_t<i_t, f_t>& cusparse_view,
103103
const i_t primal_size,
104-
const i_t dual_size);
104+
const i_t dual_size,
105+
bool is_batch_mode = false);
105106

106107
// Compute kkt score on passed argument using the container tmp_kkt score and stream view
107108
f_t compute_kkt_score(const rmm::device_scalar<f_t>& l2_primal_residual,

cpp/src/linear_programming/restart_strategy/weighted_average_solution.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace cuopt::linear_programming::detail {
2929
template <typename i_t, typename f_t>
3030
weighted_average_solution_t<i_t, f_t>::weighted_average_solution_t(raft::handle_t const* handle_ptr,
3131
i_t primal_size,
32-
i_t dual_size)
32+
i_t dual_size,
33+
bool is_batch_mode)
3334
: handle_ptr_(handle_ptr),
3435
stream_view_(handle_ptr_->get_stream()),
3536
primal_size_h_(primal_size),
@@ -39,7 +40,7 @@ weighted_average_solution_t<i_t, f_t>::weighted_average_solution_t(raft::handle_
3940
sum_primal_solution_weights_{0.0, stream_view_},
4041
sum_dual_solution_weights_{0.0, stream_view_},
4142
iterations_since_last_restart_{0},
42-
graph(stream_view_)
43+
graph(stream_view_, is_batch_mode)
4344
{
4445
RAFT_CUDA_TRY(
4546
cudaMemsetAsync(sum_primal_solutions_.data(), 0.0, sizeof(f_t) * primal_size_h_, stream_view_));

cpp/src/linear_programming/restart_strategy/weighted_average_solution.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ namespace cuopt::linear_programming::detail {
2929
template <typename i_t, typename f_t>
3030
class weighted_average_solution_t {
3131
public:
32-
weighted_average_solution_t(raft::handle_t const* handle_ptr, i_t primal_size, i_t dual_size);
32+
weighted_average_solution_t(raft::handle_t const* handle_ptr,
33+
i_t primal_size,
34+
i_t dual_size,
35+
bool is_batch_mode);
3336

3437
void reset_weighted_average_solution();
3538
void add_current_solution_to_weighted_average_solution(const f_t* primal_solution,

0 commit comments

Comments
 (0)