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

automatic tuning of (QUDA)-MG parameters [WIP, DO NOT MERGE] #537

Merged
merged 42 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f38f097
skeleton for automatic tuning of (QUDA)-MG parameters for usage in fe…
kostrzewa Mar 24, 2022
49ae26b
fix a few typos and a forgotten newline processor
kostrzewa Mar 24, 2022
c0081a3
first concrete implementation of a search algorithm (which kinda brea…
kostrzewa Mar 25, 2022
daa4a53
first kind of working implementation of QUDA-MG parameter tuner
kostrzewa Mar 25, 2022
42d9848
fix tuning logic and use multiple passes to improve on tuning result
kostrzewa Mar 26, 2022
76b5fbe
deriv_mg_tune: simplify input format and temporarily remove support f…
kostrzewa Mar 28, 2022
ec02c47
refine tuning logic to always start from the best set of parameters w…
kostrzewa Apr 4, 2022
55bd8b2
suppress one instance of console output by 'find_best_params'
kostrzewa Apr 4, 2022
28e9caf
we were stopping early in tuning due to a logic bug
kostrzewa Apr 4, 2022
dfc93ce
print number of tuning iterations and total
kostrzewa Apr 4, 2022
d5d681a
Merge branch 'quda_work_add_actions' of github.com:etmc/tmLQCD into d…
kostrzewa Apr 25, 2022
a008824
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Nov 1, 2022
293315b
ansatz to provide some explanatory strings for MG tuning directions
kostrzewa Nov 1, 2022
1870d09
extraneous curly brace
kostrzewa Nov 1, 2022
6d9e92a
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Nov 2, 2022
2efe069
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Mar 16, 2023
e24efb4
typo in sample_deriv_mg_tune_tmclover.input
kostrzewa Mar 16, 2023
783af10
first stab at a multi-config MG tuner
kostrzewa Mar 22, 2023
e017035
fix some issues with multi-config MG auto-tuner and test it successfully
kostrzewa Mar 22, 2023
41ed324
add treshold below which time-to-solution improvements are ignored in…
kostrzewa Mar 25, 2023
378dad4
tuning_plam is a pointer
kostrzewa Mar 25, 2023
9f7a328
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Mar 28, 2023
c3248ba
install benchmark, offline_measurement and deriv_mg_tune too
kostrzewa Mar 29, 2023
afd73e9
set good defaults for MGTuningIgnoreThreshold and MGTuningTolerance b…
kostrzewa Apr 6, 2023
eeb5c43
support 0 tuning iterations and reset tuning plan between calls of tuner
kostrzewa Jul 28, 2023
f7c21be
only replace current tuning params with 'best' params if the 'best' s…
kostrzewa Aug 1, 2023
2fe1762
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Aug 1, 2023
8f74a25
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Oct 15, 2023
bb1c8bf
document the MG autotuner
kostrzewa Oct 15, 2023
2f144d0
clarify balance between MGTuningTolerance and MGTuningIgnoreThreshold
kostrzewa Oct 16, 2023
3798564
add example log from tuning procedure
kostrzewa Oct 16, 2023
a1971be
typo in docs
kostrzewa Dec 28, 2023
2fed63c
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Dec 28, 2023
405f70c
merge with current quda_work
kostrzewa Jan 29, 2024
2812388
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa Feb 10, 2024
7f90d21
Merge remote-tracking branch 'origin/master' into deriv_mg_tune
kostrzewa Jun 14, 2024
7d30f29
fix undefined behaviour in part of the MG autotuner (without conseque…
kostrzewa Jul 18, 2024
66fa8e8
interchange ordering of coarse solver tolerance and coarse solver max…
kostrzewa Jul 18, 2024
0c8d86f
add MPI_Barrier in mg_tune before and after MG update and after inver…
kostrzewa Jul 19, 2024
d2d1848
more tuning params that can go negative but shouldn't
kostrzewa Jul 19, 2024
80c41db
Merge remote-tracking branch 'origin/master' into deriv_mg_tune
kostrzewa Jan 28, 2025
7c007b6
correct mistake in Autotuner docs
kostrzewa Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/quda_work' into deriv_mg_tune
kostrzewa committed Nov 1, 2022
commit a0088248e5b39774d935e21ee83b6d5d32ac9f64
56 changes: 53 additions & 3 deletions quda_interface.c
Original file line number Diff line number Diff line change
@@ -99,7 +99,6 @@
#include <string.h>
#include <math.h>
#include <float.h>
#include <stdbool.h> // boolean types in C
#include "quda_interface.h"
#include "quda_types.h"
#include "boundary.h"
@@ -270,7 +269,6 @@ void _setDefaultQudaParam(void){

inv_param.residual_type = (QudaResidualType)(QUDA_L2_RELATIVE_RESIDUAL);
inv_param.tol_hq = 0.1;
// alternative reliable does not seem to work well with twisted mass (clover) fermions
inv_param.use_alternative_reliable = 0;

// Tests show that setting reliable_delta = 1e-1 results in good time to solution and good
@@ -364,7 +362,6 @@ void _setVerbosityQuda(){

// general verbosity
setVerbosityQuda(gen_verb, "# QUDA: ", stdout);

}

void set_force_gauge_param( QudaGaugeParam * f_gauge_param){
@@ -2932,4 +2929,57 @@ void quda_mg_tune_params(void * spinorOut, void * spinorIn, const int max_iter){
free(tunable_params);
}

void compute_WFlow_quda(const double eps, const double tmax, const int traj, FILE* outfile){
tm_stopwatch_push(&g_timers, __func__, "");

_initQuda();
_loadGaugeQuda(NO_COMPRESSION);//check here the input

QudaGaugeSmearParam wflow_params = newQudaGaugeSmearParam();
wflow_params.smear_type = QUDA_GAUGE_SMEAR_WILSON_FLOW;
wflow_params.n_steps = (int)(tmax / eps) + 3;
wflow_params.epsilon = eps;
wflow_params.meas_interval = 1;

int n_meas= wflow_params.n_steps / wflow_params.meas_interval + 1 ;
QudaGaugeObservableParam *obs_param;
obs_param = (QudaGaugeObservableParam*) malloc(sizeof(QudaGaugeObservableParam) * n_meas);
for (int i=0; i<n_meas; i++){
obs_param[i] = newQudaGaugeObservableParam();
obs_param[i].compute_plaquette = QUDA_BOOLEAN_TRUE;
obs_param[i].compute_qcharge = QUDA_BOOLEAN_TRUE;
obs_param[i].su_project = QUDA_BOOLEAN_TRUE;
}

setVerbosityQuda(QUDA_SILENT, "# QUDA: ", stdout);
performWFlowQuda(&wflow_params, obs_param);
_setVerbosityQuda();

tm_debug_printf(0, 3, "traj t P Eplaq Esym tsqEplaq tsqEsym Wsym Qsym\n");

for(int i=1; i< wflow_params.n_steps; i+=2){
const double t1 = i*eps;
const double P = obs_param[i].plaquette[0];
const double E0 = obs_param[i-1].energy[0]; // E(t=t0)
const double E1 = obs_param[i].energy[0]; // E(t=t1)
const double E2 = obs_param[i+1].energy[0]; // E(t=t2)
const double W = t1*t1 * (2 * E1 + t1 * ((E2 - E0) / (2 * eps)));
const double Q = -obs_param[i].qcharge; // topological charge Q

tm_debug_printf(0, 3,
"# GRADFLOW: sym(plaq) t=%lf 1-P(t)=%1.8lf E(t)=%2.8lf(%2.8lf) t^2E=%2.8lf(%2.8lf) "
"W(t)=%2.8lf Q(t)=%.8lf \n",
t1, 1 - P, E1, 36 * (1 - P), t1*t1*E1, t1*t1 * 36 * (1 - P), W, Q);

if (g_proc_id == 0) {
fprintf(outfile, "%06d %f %2.12lf %2.12lf %2.12lf %2.12lf %2.12lf %2.12lf %.12lf \n", traj,
t1, P, 36 * (1 - P), E1, t1 * t1 * 36 * (1 - P), t1*t1*E1, W, Q);
fflush(outfile);
}

}

free(obs_param);
tm_stopwatch_pop(&g_timers, 0, 1, "TM_QUDA");
}

10 changes: 7 additions & 3 deletions read_input.l
Original file line number Diff line number Diff line change
@@ -234,6 +234,7 @@ static inline double fltlist_next_token(int * const list_end){
double mstarsq;
int no_sources_z2;


double mixcg_innereps;
int mixcg_maxinnersolverit;

@@ -739,8 +740,9 @@ static inline double fltlist_next_token(int * const list_end){
^DflFieldIter{EQL} BEGIN(DFLFIELDITER);
^DflPolyIter{EQL} BEGIN(DFLPOLYITER);

^BeginDeflation BEGIN(INITDEFLATION);
^BeginDDalpha BEGIN(INITMULTIGRID);

^BeginDeflation BEGIN(INITDEFLATION);
^BeginDDalpha BEGIN(INITMULTIGRID);
^MixCGInnerEps{EQL} BEGIN(MIXCGEPS);
^MixCGMaxIter{EQL} BEGIN(MIXCGIT);

@@ -750,6 +752,7 @@ static inline double fltlist_next_token(int * const list_end){
^BarrierMonomialsConverge{EQL} BEGIN(BARRIER_MONOMIALS_CONVERGE);



<INITDEFLATION>Init{SPC}* {
if(myverbose) printf("Initialising DEFLATION line %d\n", line_of_file);
BEGIN(DEFLATION);
@@ -3604,7 +3607,7 @@ static inline double fltlist_next_token(int * const list_end){
BEGIN(comment_caller);
}

<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,NDPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,INITGPU,GPU,RATMONOMIAL,RATCORMONOMIAL,CLRATMONOMIAL,CLRATCORMONOMIAL,INITDEFLATION,DEFLATION,INITMULTIGRID,MULTIGRID,INITEXTERNALINVERTER,QUDAINVERTER,QPHIXINVERTER,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL,TUNEQUDAMGPARAMS>{SPC}*\n {
<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,CLDETRATRWMONOMIAL,NDPOLYMONOMIAL,NDRATMONOMIAL,NDRATCORMONOMIAL,NDCLRATMONOMIAL,NDCLRATCORMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,ORIENTEDPLAQUETTESMEAS,GRADIENTFLOWMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,RATMONOMIAL,RATCORMONOMIAL,CLRATMONOMIAL,CLRATCORMONOMIAL,INITDEFLATION,DEFLATION,INITMULTIGRID,MULTIGRID,INITEXTERNALINVERTER,QUDAINVERTER,QPHIXINVERTER,NDDETRATMONOMIAL,NDCLDETRATMONOMIAL,TUNEQUDAMGPARAMS>{SPC}*\n {
line_of_file++;
}
<*>{SPC}*\n {
@@ -3776,6 +3779,7 @@ int read_input(char * conf_file){
mstarsq = _default_mstarsq;
no_sources_z2 = _default_no_sources_z2;


mixcg_innereps = _default_mixcg_innereps;
mixcg_maxinnersolverit = _default_mixcg_maxinnersolverit;

You are viewing a condensed version of this merge commit. You can view the full changes here.