Skip to content
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

Add relaxed mb tolerance parameter #5173

Merged
merged 4 commits into from
Feb 20, 2024
Merged

Add relaxed mb tolerance parameter #5173

merged 4 commits into from
Feb 20, 2024

Conversation

totto82
Copy link
Member

@totto82 totto82 commented Feb 8, 2024

The relaxed tolerance is for now defaulted to the same as the standard tolerance. The idea is to keep the 1e-6 for the relaxed tolerance while updating target to 1e-7. With 19 as default number of strict iterations, this means that if the simulator reach maximum 20 newton iterations it will accept the results if tol < 1e-6.

related to #5157

@totto82
Copy link
Member Author

totto82 commented Feb 8, 2024

jenkins build this please

@atgeirr
Copy link
Member

atgeirr commented Feb 8, 2024

I think this is a good idea, and the goal of stricter default tolerance is good. But I am not sure the "strict for X iterations" approach is good, or user friendly. The behaviour I would seek is to work with the strict tolerance until we have no more iterations (i.e. we are going to say not converged in the current code), then check if the relaxed tolerance is fulfilled, and if it is accept the step and maybe log a warning.

I suggest the following: default the min strict mb iterations to -1, and take that to mean the above behaviour, this would let the user override it completely to a different iteration number if necessary.

Also, the Jenkins failure is a little strange to me, I would expect 0 differences on all cases when not actively setting this parameter?

@totto82
Copy link
Member Author

totto82 commented Feb 8, 2024

I suggest the following: default the min strict mb iterations to -1, and take that to mean the above behaviour, this would let the user override it completely to a different iteration number if necessary.

Good idea. Will update.

The failed test runs with --tolerance-mb=1.e-7.

@totto82
Copy link
Member Author

totto82 commented Feb 9, 2024

jenkins build this please

@totto82
Copy link
Member Author

totto82 commented Feb 9, 2024

Good idea. Will update.

I have updated as you suggested. This may effect results though.

@atgeirr
Copy link
Member

atgeirr commented Feb 9, 2024

I have updated as you suggested. This may effect results though.

It should not as long as the tolerances are identical?

@totto82
Copy link
Member Author

totto82 commented Feb 9, 2024

It should not as long as the tolerances are identical?

Good point. But if you look closely I included the relaxed CNV, which are already different.

@totto82
Copy link
Member Author

totto82 commented Feb 9, 2024

benchmark please

@blattms
Copy link
Member

blattms commented Feb 12, 2024

Results did not travel back here either:

Test Configuration Relative
opm-git OPM Benchmark: drogon - Threads: 1 1.002
opm-git OPM Benchmark: drogon - Threads: 8 0.829
opm-git OPM Benchmark: punqs3 - Threads: 1 1.014
opm-git OPM Benchmark: punqs3 - Threads: 8 0.982
opm-git OPM Benchmark: smeaheia - Threads: 1 0.955
opm-git OPM Benchmark: smeaheia - Threads: 8 0.882
opm-git OPM Benchmark: spe10_model_1 - Threads: 1 1.012
opm-git OPM Benchmark: spe10_model_1 - Threads: 8 0.998
opm-git OPM Benchmark: flow_mpi_extra - Threads: 1 - FOIT (Total Oil Injection At End Of Run) 1
opm-git OPM Benchmark: flow_mpi_extra - Threads: 8 - FOIT (Total Oil Injection At End Of Run) 1
opm-git OPM Benchmark: flow_mpi_norne - Threads: 1 0.988
opm-git OPM Benchmark: flow_mpi_norne - Threads: 8 0.976
opm-git OPM Benchmark: flow_mpi_norne_4c_msw - Threads: 1 0.989
opm-git OPM Benchmark: flow_mpi_norne_4c_msw - Threads: 8 0.984
  • Speed-up = Total time master / Total time pull request. Above 1.0 is an improvement. *

@ytelses
Copy link

ytelses commented Feb 12, 2024

Benchmark result overview:

Test Configuration Relative
opm-git OPM Benchmark: drogon - Threads: 1 1.002
opm-git OPM Benchmark: drogon - Threads: 8 0.829
opm-git OPM Benchmark: punqs3 - Threads: 1 1.014
opm-git OPM Benchmark: punqs3 - Threads: 8 0.982
opm-git OPM Benchmark: smeaheia - Threads: 1 0.955
opm-git OPM Benchmark: smeaheia - Threads: 8 0.882
opm-git OPM Benchmark: spe10_model_1 - Threads: 1 1.012
opm-git OPM Benchmark: spe10_model_1 - Threads: 8 0.998
opm-git OPM Benchmark: flow_mpi_extra - Threads: 1 - FOIT (Total Oil Injection At End Of Run) 1
opm-git OPM Benchmark: flow_mpi_extra - Threads: 8 - FOIT (Total Oil Injection At End Of Run) 1
opm-git OPM Benchmark: flow_mpi_norne - Threads: 1 0.988
opm-git OPM Benchmark: flow_mpi_norne - Threads: 8 0.976
opm-git OPM Benchmark: flow_mpi_norne_4c_msw - Threads: 1 0.989
opm-git OPM Benchmark: flow_mpi_norne_4c_msw - Threads: 8 0.984
  • Speed-up = Total time master / Total time pull request. Above 1.0 is an improvement. *

@totto82 totto82 requested a review from atgeirr February 14, 2024 14:00
Copy link
Member

@atgeirr atgeirr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is getting very close, but the logic needs a small fix.

use_relaxed_mb = true;
use_relaxed_cnv = true;
if ( terminal_output_ ) {
std::ostringstream ss;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using fmt::format instead, that would simplify this as you do not have to worry about restoring flags and precision etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated accordingly.

const bool use_relaxed = cnvErrorPvFraction < param_.relaxed_max_pv_fraction_ && iteration >= param_.min_strict_cnv_iter_;
const double tol_cnv = use_relaxed ? param_.tolerance_cnv_relaxed_ : param_.tolerance_cnv_;
bool use_relaxed_cnv = cnvErrorPvFraction < param_.relaxed_max_pv_fraction_ && iteration >= param_.min_strict_cnv_iter_;
bool use_relaxed_mb = param_.min_strict_mb_iter_ < 0? false : iteration >= param_.min_strict_mb_iter_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: space around ?. However, I think the logic here is a little too complicated, and also slightly flawed. With this code, even if I set the number of strict iterations to 1000, I will still get a relaxed final iteration, but that should only happen with -1. Also, it is better to keep these bools const. I suggest:

const bool relax_final_iteration = (param_.min_strict_mb_iter_ < 0) && (iteration + 1 == maxIter);
const bool use_relaxed_mb = relax_final_iteration || (iteration >= param_.min_strict_mb_iter_);

And then replace the if () below with

if (relax_final_iteration) {
    // Write the message about trying with relaxed tolerances in the final iteration.
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated accordingly.

@totto82
Copy link
Member Author

totto82 commented Feb 15, 2024

jenkins build this please

2 similar comments
@totto82
Copy link
Member Author

totto82 commented Feb 15, 2024

jenkins build this please

@totto82
Copy link
Member Author

totto82 commented Feb 15, 2024

jenkins build this please

@alfbr
Copy link
Member

alfbr commented Feb 19, 2024

Time to merge?

@atgeirr atgeirr merged commit f79b5ab into OPM:master Feb 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants