-
Notifications
You must be signed in to change notification settings - Fork 220
Add a solver setting for controlling adaptive regularization in barrier #1743
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
rg20
wants to merge
6
commits into
NVIDIA:main
Choose a base branch
from
rg20:qp_adaptive_reg
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
6 commits
Select commit
Hold shift + click to select a range
8d2b601
Add a setting for controlling adaptive regularization
rg20 63954b2
Add docs
rg20 06c8bb5
Add an initializer
rg20 90b1c7c
Move the adaptive refinement logic to initial point computation
rg20 852c6e7
Merge remote-tracking branch 'upstream/main' into qp_adaptive_reg
rg20 ef2a58d
Correct variable description
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 |
|---|---|---|
|
|
@@ -97,6 +97,15 @@ bool validate_barrier_cone_layout(const lp_problem_t<i_t, f_t>& problem, | |
| return true; | ||
| } | ||
|
|
||
| // -1 automatic: enable for cones, disable otherwise; 0 off; 1 on | ||
| template <typename i_t, typename f_t> | ||
| bool should_use_adaptive_regularization(const simplex_solver_settings_t<i_t, f_t>& settings, | ||
| bool has_cones) | ||
| { | ||
| return settings.barrier_adaptive_regularization > 0 || | ||
| (settings.barrier_adaptive_regularization < 0 && has_cones); | ||
| } | ||
|
|
||
| template <typename f_t> | ||
| [[maybe_unused]] static void pairwise_multiply( | ||
| f_t* a, f_t* b, f_t* out, int size, rmm::cuda_stream_view stream) | ||
|
|
@@ -479,14 +488,11 @@ class iteration_data_t { | |
| f_t estimated_nz_AAT = 0.0; | ||
|
|
||
| const bool has_soc = has_cones(); | ||
|
|
||
| if (has_soc) { | ||
| primal_perturb = 1e-8; | ||
| dual_perturb = 1e-8; | ||
| } else { | ||
| primal_perturb = 1e-6; | ||
| dual_perturb = 0; | ||
| } | ||
| // Apply the adaptive-regularization policy before form_augmented / initial | ||
| // factorization so an explicit enable/disable is honored from the start. | ||
| const bool adaptive_reg = should_use_adaptive_regularization(settings, has_soc); | ||
| primal_perturb = has_soc ? 1e-8 : 1e-6; | ||
| dual_perturb = adaptive_reg ? 1e-8 : 0; | ||
|
|
||
| if (has_soc) { | ||
| // SOCP always use the augmented KKT; skip dense-column / ADAT heuristics. | ||
|
|
@@ -2914,7 +2920,7 @@ i_t barrier_solver_t<i_t, f_t>::gpu_compute_search_direction(iteration_data_t<i_ | |
|
|
||
| // Adaptive regularization: increase/decrease based on IR quality. | ||
| // Only adapt on calls where we actually (re)factorized — the affine step. | ||
| if (did_factorize && data.has_cones()) { | ||
| if (did_factorize && should_use_adaptive_regularization(settings, data.has_cones())) { | ||
| constexpr f_t min_perturb = 1e-8; | ||
| constexpr f_t max_perturb = 1e-1; | ||
| if (solve_err > 1e-2) { | ||
|
|
@@ -4163,6 +4169,15 @@ lp_status_t barrier_solver_t<i_t, f_t>::solve(f_t start_time, lp_solution_t<i_t, | |
| return lp_status_t::TIME_LIMIT; | ||
| } | ||
|
|
||
| // Handle automatic adaptive regularization (-1: auto, 0: off, 1: on). | ||
| // Policy is already applied to data.dual_perturb during construction | ||
| // (before form_augmented / initial_point). | ||
| const bool adaptive_regularization = | ||
| should_use_adaptive_regularization(settings, data.has_cones()); | ||
| if (settings.barrier_adaptive_regularization == -1 && adaptive_regularization) { | ||
|
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. Shouldn't it be
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. That is, you also want to turn it on when the user explicitly sets it to 1. |
||
| settings.log.printf("Adaptive regularization enabled\n"); | ||
| } | ||
|
|
||
| i_t initial_status = initial_point(data); | ||
| if (toc(start_time) > settings.time_limit) { | ||
| settings.log.printf("Barrier time limit exceeded\n"); | ||
|
|
@@ -4176,6 +4191,7 @@ lp_status_t barrier_solver_t<i_t, f_t>::solve(f_t start_time, lp_solution_t<i_t, | |
| settings.log.printf("Unable to compute initial point\n"); | ||
| return lp_status_t::NUMERICAL_ISSUES; | ||
| } | ||
|
|
||
| // Upload initial point to device and compute initial residuals/norms on GPU | ||
| data.d_complementarity_wv_residual_.resize(data.n_upper_bounds, stream_view_); | ||
| data.d_complementarity_wv_rhs_.resize(data.n_upper_bounds, stream_view_); | ||
|
|
@@ -4271,7 +4287,7 @@ lp_status_t barrier_solver_t<i_t, f_t>::solve(f_t start_time, lp_solution_t<i_t, | |
| const i_t iteration_limit = settings.iteration_limit; | ||
|
|
||
| // Adaptive regularization for the augmented system. | ||
| f_t dual_perturb = data.has_cones() ? 1e-8 : 0; | ||
| f_t dual_perturb = adaptive_regularization ? 1e-8 : 0; | ||
| f_t primal_perturb = data.has_cones() ? 1e-8 : 1e-6; | ||
|
|
||
| while (iter < iteration_limit) { | ||
|
|
||
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
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.
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.
Nit: rename
should_use_adaptive_regularizationtocheck_adaptive_regularization.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.
I disagree.
checkwould imply that you are checking something about the regularization.should_useis better if you are deciding if you should apply the regularization.Alternatives would be
should_apply_adaptive_regularizationor justapply_adaptive_regularization.