arXiv:2611.01193math.NAOct 2026

Manuscript Offprint

arXiv:2611.01193

Online Autotuning of Algebraic Multigrid via Contextual Bandits and Reinforcement Learning

Xudong He, Ruiyu Wang, Yilang Ding, Rui Peng Li, Yuanzhe Xi

XUDONG HE*, RUIYU WANG*, YILANG DING*, RUI PENG LI†, AND YUANZHE XI*

Abstract. Algebraic multigrid (AMG) methods are widely used for solving large sparse linear systems, but their efficiency depends strongly on interacting setup and solve parameters. Effective parameter choices typically depend on the problem. We develop a phase-aware online autotuning method for hypre's BoomerAMG to reduce cumulative time-to-solution over sequences of related linear systems. A LinUCB-based contextual bandit selects mixed-type parameters for AMG hierarchy construction using a shared cost model over PDE descriptors and configuration encodings. A recursive LSTDQ controller uses residual and timing observations to estimate the AMG solve time within each attempt and adapt relaxation weights between multigrid cycles. Both learners update from ongoing solves without offline pretraining. Across grids of sizes 40340^3, 60360^3, and 80380^3, the joint autotuning method reduces total runtime, including recurring learner computation, by 36.1–43.3% for diffusion problems and 19.8–31.0% for diffusion-advection problems over sequences of 5000 linear systems, relative to the reference BoomerAMG default configuration. On a variable-flow diffusion-advection benchmark comprising 30,000 systems on a 60360^3 grid, 2 systems fail to converge with joint autotuning, compared with 1677 for the reference configuration, under their respective attempt budgets.

Key words. AMG, online learning, contextual bandits, reinforcement learning, autotuning

MSC codes. 65F08, 65F10, 65N55, 68T05

  1. Introduction. Many scientific and engineering applications, including time-dependent partial differential equations, inverse problems, uncertainty quantification, and optimization loops, require the repeated solution of related sparse linear systems [6, 26]. We represent such a sequence of TT linear systems as
(1.1)A(t)u(t)=f(t),t=1,2,…,T,(1.1) \qquad \mathbf{A}^{(t)} \mathbf{u}^{(t)} = \mathbf{f}^{(t)}, \qquad t = 1, 2, \ldots, T,

where A(t)∈Rnt×nt\mathbf{A}^{(t)} \in \mathbb{R}^{n_t \times n_t} is large and sparse, and tt indexes the problem instance. The practical objective is to reduce cumulative time-to-solution across the sequence. Solving a sequence of related problems creates an opportunity for online autotuning: information collected from earlier solves can guide parameter choices on later instances.

We focus on algebraic multigrid (AMG) methods, which are scalable and can achieve near-linear complexity for many elliptic problems. These methods apply to matrices from unstructured discretizations or algebraically defined operators [10, 23]. Their practical efficiency depends strongly on setup and solve parameters, including the choices of coarsening, interpolation, and smoothing methods, and cycle structure, which affect convergence, operator complexity, memory use, communication, and runtime [23, 10, 8, 2, 27]. hypre's BoomerAMG is a scalable parallel AMG implementation. It exposes these choices through interacting continuous, integer-valued, and categorical parameters. Default configurations provide useful general-purpose baselines, but need not be the most efficient ones for a particular problem sequence.

*Department of Mathematics, Emory University (xudong.he@emory.edu, jonathan.wang@emory.edu, lance.ding@emory.edu, yxi26@emory.edu). The work of Y. Xi is supported by the National Science Foundation under awards DMS-2038118 and DMS-2338904.

†Center for Applied Scientific Computing, Lawrence Livermore National Laboratory, P.O. Box 808, L-561, Livermore, CA 94551 (li50@llnl.gov). This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344. LLNL-JRNL-XXXXXXX. The United States Government retains, and the publisher, by accepting the article for publication, acknowledges that the United States Government retains a non-exclusive, paid-up, irrevocable, worldwide license to publish or reproduce the published form of this manuscript, or allow others to do so, for United States Government purposes.

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

2

Tuning AMG requires balancing hierarchy-construction cost against subsequent solve cost. Setup parameters determine the multilevel hierarchy, while solve-phase parameters control its application through relaxation and coarse-grid correction. Together, they determine the cost of each cycle and the number of cycles needed to reach tolerance. An AMG hierarchy that is inexpensive to construct or apply may require more cycles, so minimizing setup cost or iteration count alone need not minimize total solution time. Although AMG theory provides valuable insight into convergence and algorithm design [10, 20, 25], predicting these tradeoffs across a large, mixed-type parameter space remains challenging [4, 9]. This motivates learning from measured setup and solve costs.

Existing autotuners can exploit such measurements. GPTune shares information across tuning tasks using multi-task Gaussian-process (GP) models, while GP-TuneBand additionally leverages evaluations at multiple fidelities [17, 28]. These frameworks have been applied to multi-parameter tuning of hypre. Online parameter selection for sequences of linear systems is studied in Learning to Relax [14], which develops bandit and contextual-bandit methods for selecting SOR and SSOR relaxation parameters, together with learning-theoretic guarantees under the stated assumptions. Since SOR and SSOR can also be used as AMG smoothers, this work is closely related to our setting. However, it selects a single scalar relaxation weight for each system and keeps that weight fixed throughout the solve, rather than adapting a sequence of actions across multigrid cycles within a solve.

Neural networks have been used to learn AMG prolongation operators [19], smoothers [12], and sparse coarse-grid operators [11]. Other approaches retain existing components and learn their configuration. Caldana et al. [4] use an offline-trained runtime surrogate to select the AMG strength threshold. Antonietti et al. [1] extend this approach to jointly select the strength-of-connection (SoC) threshold and smoother type, accounting for interactions between hierarchy and relaxation choices. Both approaches select configurations using previously trained predictors. AMG parameters have also been adapted during solver execution. Mishra et al. [21] use online Bayesian optimization to update polynomial-multigrid cycle configurations as a simulation progresses. Huergo et al. [13] use proximal policy optimization (PPO) to adjust smoothing sweeps and a correction fraction between V-cycles in h/p-multigrid. Their controller responds to residual information and uses rewards based on residual reduction per unit time; the reported tests evaluate a previously trained policy.

Our contribution is a phase-aware online autotuning method that learns mixed-type setup configurations and cycle-level relaxation weights while solving a finite sequence of related linear systems. The method combines two components: a setup learner for AMG setup parameters that control hierarchy construction and a solve learner for AMG solve parameters, in particular the relaxation weights. They maintain separate models but are coupled through solver execution: the selected hierarchy affects solve performance, while the relaxation policy affects the cost and success of a setup choice. The distinction from prior work is the integration of these decisions with continued learning within the workload being solved.

The setup learner makes one configuration-level decision before each attempt. It observes feedback only for the selected configuration, including the cost of the subsequent solve, without modeling individual cycle transitions. We use a LinUCB-based contextual-bandit method [16, 5] with a shared linear cost model over PDE descriptors and setup parameters. This representation allows observations from one configuration to inform predictions for related, untested configurations. The solve learner instead makes a sequence of decisions on the constructed hierarchy. The relaxation weight selected for each cycle affects the residual state on which subsequent cycles act, so maximizing immediate residual reduction does not necessarily minimize total solve time. We use recursive least-squares temporal-difference action-value estimation (LSTDQ) [15] to predict the execution time of the remaining cycles within the current attempt. These predictions guide relaxation-weight selection with exploration, and the learner updates using cycle-level residual and timing feedback.

Both learners update from the first problem in the sequence without offline pre-training. Our main online comparisons include cumulative setup and solve time, parameter-selection and model-update costs, and every executed attempt, including failures and retries. The evaluation therefore asks whether solver savings outweigh learning costs within the available sequence, rather than measuring performance only after training. Experiments on structured anisotropic diffusion and diffusion-advection problems, including a spatially varying advection benchmark, evaluate runtime and convergence reliability under the prescribed retry and fallback protocols. Matched-hierarchy tests separately compare learned relaxation with grid-searched fixed weights and a prescribed period-two policy, distinguishing relaxation performance from changes in hierarchy selection. The results demonstrate runtime savings for the complete method on the tested sequences and improvements over the tested fixed-weight references.

The remainder of the paper is organized as follows. Section 2 defines the auto-tuning problem. Sections 3 and 4 present the setup and solve learners, respectively. Section 5 reports the numerical results, and Section 6 concludes.

  1. Problem Setup and Formulation. This section describes how the online tuning method processes each linear system (1.1). We distinguish the AMG hierarchy-construction attempts from the AMG cycles within an attempt, define the information available to the learners, and specify the runtime objective used to evaluate the complete method.

2.1. AMG parameters and execution. BoomerAMG first constructs a multilevel hierarchy and then applies multigrid cycles using the hierarchy. We therefore partition its parameters as

(2.1)

Θ=Θsetup×Θsolve,\Theta=\Theta_{\mathrm{s e t u p}}\times\Theta_{\mathrm{s o l v e}},

where setup parameters determine hierarchy construction and solve parameters determine how the cycle is performed.

For problem tt, let jj index successive attempts. Attempt (t,j)(t,j) first constructs a hierarchy using at,j∈Θsetupa_{t,j} \in \Theta_{\mathrm{setup}}. If the construction succeeds, AMG cycles are performed using that hierarchy. The attempt fails either if hierarchy construction fails or if the following solve does not reach the prescribed tolerance within the cycle limit. For methods with learned setup selection, a failed attempt may be followed by another learner-selected configuration while the attempt budget permits. If all learned attempts fail, methods with fallback make one final attempt using the reference setup and solve settings. This process stops at the first successful attempt.

Let Jmax⁡J_{\max} denote the maximum number of attempts and Jt≤Jmax⁡J_t \leq J_{\max} the number actually executed on problem tt. Method-specific attempt budgets are given in Section 5.1. For a successful setup configuration aa, let Ht(a)\mathcal{H}_t(a) denote the resulting AMG hierarchy. Attempt (t,j)(t,j) uses Ht(at,j)\mathcal{H}_t(a_{t,j}) throughout its solve. Changing solve phase parameters such as the relaxation weight between cycles does not rebuild the hierarchy; a new hierarchy is constructed only when a new setup attempt begins. Let uk(t,j)\mathbf{u}_k^{(t,j)}

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

TABLE 1

Representative BoomerAMG parameters and reference settings used in this study. Here r, i, and c denote real-valued, integer-valued, and categorical parameters, respectively.

ParameterTypeRoleReference
Setup parameters
strong_threshold0≤r<10 \le r < 1Strength-of-connection threshold.0.25
max_row_sum0<r<10 < r < 1Row-sum criterion related to diagonal dominance.0.9
coarsen_typecCoarsening algorithm.10
interp_typecInterpolation algorithm.6
trunc_factorr≥0r \ge 0Interpolation truncation factor.0.0
P_max_elmtsi>0i > 0Maximum interpolation entries per row.4
agg_num_levelsi≥0i \ge 0Number of aggressive coarsening levels.0
agg_interp_typecInterpolation type with aggressive coarsening.4
nongalerkin_tolr≥0r \ge 0Non-Galerkin dropping tolerance.0.0
Solve parameters
relax_typecRelaxation method in the AMG cycles.18/18
num_sweepsi>0i > 0Number of relaxation sweeps.1
relax_weightr>0r > 0Weight used by the relaxation scheme.1.0
cycle_typecMultigrid cycle type, such as a V-cycle or W-cycle.V

denote the iterate after k completed cycles of attempt (t,j)(t,j). Define the corresponding residual and relative residual norm reduction as

(2.2)

rk(t,j)=f(t)−A(t)uk(t,j),ϱt,j,k=∥rk(t,j)∥2∥r0(t,j)∥2,\mathbf{r}_{k}^{(t,j)}=\mathbf{f}^{(t)}-\mathbf{A}^{(t)}\mathbf{u}_{k}^{(t,j)},\qquad \varrho_{t,j,k}=\frac{\|\mathbf{r}_{k}^{(t,j)}\|_{2}}{\|\mathbf{r}_{0}^{(t,j)}\|_{2}},

for a nonzero initial residual r0(t,j)\mathbf{r}_0^{(t,j)}. Let wt,j,kw_{t,j,k} denote the relaxation weight used in the cycle that advances uk(t,j)\mathbf{u}_k^{(t,j)} to uk+1(t,j)\mathbf{u}_{k+1}^{(t,j)}. When solve-phase learning is enabled, the solve learner selects the weight using the information observed up to the kk-th cycle. Let Kmax⁡K_{\max} be the maximum number of cycles per attempt and εtol>0\varepsilon_{\mathrm{tol}} > 0 the relative residual tolerance. An attempt succeeds if there exists a kk such that ϱt,j,k<εtol\varrho_{t,j,k} < \varepsilon_{\mathrm{tol}} and k<Kmax⁡k < K_{\max}; otherwise, it is recorded as a failure.

Table 1 lists representative BoomerAMG parameters and their reference settings. Our experiments tune the 8 setup controls in Table 3 and the solve-phase relaxation weight; all remaining controls are fixed.

2.2. Online objective and runtime accounting. When processing problem tt, the learners observe a context vector χt∈Rdx\chi_t \in \mathbb{R}^{d_x}, containing problem descriptors available before the AMG hierarchy construction. The same context is provided to both learners and remains fixed across all attempts on the problem. The specific descriptors used in the experiments are given in Section 5.1.

Let Π\Pi denote a complete online learning method, including its setup and solve decisions, retry and fallback rules, and learner updates. All decisions use only the information available at the time they are made. Let τt,jset\tau_{t,j}^{\mathrm{set}} and τt,jsol\tau_{t,j}^{\mathrm{sol}} denote the setup and solve execution times of attempt (t,j)(t,j), excluding learner computation. If hierarchy construction fails, τt,jsol=0\tau_{t,j}^{\mathrm{sol}} = 0, while the time spent on construction remains included.

Let OtsetO_{t}^{\mathrm{set}} and OtsolO_{t}^{\mathrm{sol}} denote the total setup- and solve-learner computation recorded on problem tt, including action selection, target construction, and model updates. We

TABLE 2 Main notation for problem indices, parameter choices, and runtime accounting.

SymbolMeaning
t,Tt, TProblem index and number of problems in the sequence.
j,Jt,Jmax⁡j, J_t, J_{\max}Attempt index, number of attempts on problem tt, and maximum attempt budget.
k,Kmax⁡k, K_{\max}Number of completed cycles within an attempt and the per-attempt cycle limit.
at,ja_{t,j}Setup configuration selected for attempt (t,j)(t,j).
wt,j,kw_{t,j,k}Relaxation weight applied to cycle k+1k+1 of attempt (t,j)(t,j).
ϱt,j,k\varrho_{t,j,k}Relative residual after kk completed cycles of attempt (t,j)(t,j).
χt\chi_tProblem context available to both learners.
τt,jset,τt,jsol\tau_{t,j}^{\text{set}}, \tau_{t,j}^{\text{sol}}Setup and solve times for attempt (t,j)(t,j), excluding learner computation.
Otset,OtsolO_t^{\text{set}}, O_t^{\text{sol}}Setup- and solve-learner computation times totaled over problem tt.
Ctsolver,CttotalC_t^{\text{solver}}, C_t^{\text{total}}Solver execution time and total recorded runtime for problem tt.
CTtotalC_T^{\text{total}}Total recorded runtime over the TT-problem sequence.

then define

(2.3)

Ctsolver(Π)=∑j=1Jt(τt,jset+τt,jsol),Cttotal(Π)=Ctsolver(Π)+Otset+Otsol.\begin{aligned}C_{t}^{\text{solver}}(\Pi)&=\sum_{j=1}^{J_{t}}\left(\tau_{t,j}^{\text{set}}+\tau_{t,j}^{\text{sol}}\right),\\C_{t}^{\text{total}}(\Pi)&=C_{t}^{\text{solver}}(\Pi)+O_{t}^{\text{set}}+O_{t}^{\text{sol}}.\end{aligned}

Here CtsolverC_{t}^{\text{solver}} measures the setup and solve time, while CttotalC_{t}^{\text{total}} additionally includes the time for learner computation, and Otset=∑jOt,jsetO_{t}^{\text{set}}=\sum_{j}O_{t,j}^{\text{set}} and Otsol=∑jOt,jsolO_{t}^{\text{sol}}=\sum_{j}O_{t,j}^{\text{sol}} denote the setup- and solve-learner computation times, respectively. For a sequence of TT problems, the cumulative recorded runtime is

(2.4)

CTtotal(Π)=∑t=1TCttotal(Π).\mathcal{C}_{T}^{\text{total}}(\Pi)=\sum_{t=1}^{T}C_{t}^{\text{total}}(\Pi).

The online objective is to reduce this cumulative cost, including learner computation from the beginning of the sequence.

Because runtime depends on the problem sequence, learner randomization, and timing variability, the experiments compare multiple independent runs. We also report the number of problems that fail to converge within the allowed attempt budgets, since runtime comparisons alone are insufficient when the compared solver configurations successfully solve different numbers of problems. Table 2 summarizes the main notation used throughout the paper.

  1. Setup-Phase Contextual Bandit. The setup learner uses the problem context χt\chi_t and observations from previously executed configurations to select an AMG-setup configuration. Since only the selected configuration is executed, the learner receives contextual-bandit feedback [14, 16]. A context-action cost model, trained from previously executed attempts, ranks candidate configurations for the first setup attempt on each problem. If an attempt fails, its binary failure outcome is available immediately, whereas its final cost target may depend on subsequent attempts and is therefore not yet known. We consequently use a separate failure model, updated immediately after the failed attempt, to rank configurations for the next retry.

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

TABLE 3

Setup search space for a=(a1,…,a8)a = (a_1, \ldots, a_8). Coarsening and interpolation values are algorithmic labels. Aggressive-interpolation truncation and row-limit controls remain fixed at zero.

SymbolParameterValues
a1a_1strong_threshold0, 0.05, ..., 0.95
a2a_2max_row_sum10−610^{-6}, 0.05, 0.10, ..., 0.95
a3a_3trunc_factor0, 0.05, ..., 0.95
a4a_4P_max_elmts2, 4, 6, 8, 12, 16
a5a_5agg_num_levels0, 1, 2
a6a_6coarsen_type0, 2, 3, 6, 8, 10
a7a_7interp_type0, 2, 3, 4, 6, 8, 17, 18
a8a_8agg_interp_type4, when a5=0a_5 = 0; 4, 6, 7, when a5>0a_5 > 0

3.1. Setup actions and feedback. Let U⊆Θsetup\mathcal{U} \subseteq \Theta_{setup} denote the finite setup search space. Each configuration a=(a1,…,a8)∈Ua = (a_1, \ldots, a_8) \in \mathcal{U} specifies the 8 control parameters that are listed in Table 3. The first five parameters, a1−a5a_1-a_5, are numeric and discretized. The remaining three, a6−a8a_6-a_8, are categorical, which select the algorithmic choices in BoomerAMG's setup. In particular, when aggressive coarsening is disabled, the aggressive-interpolation parameter is inactive and fixed at its reference value to avoid duplicate configurations.

The first setup decision of the online run uses the default configuration. For each subsequent setup decision, the learner constructs a candidate set Ut,j⊆U\mathcal{U}_{t,j} \subseteq \mathcal{U} containing at most 1024 configurations. This candidate set includes the default, the most recently selected configuration, and previously evaluated configurations with low setup-learning loss. Additional candidates are generated by changing one active parameter of selected configurations, drawing samples from the discrete search space, and mapping scrambled Sobol points to the numeric grids. Sobol sequences provide low-discrepancy points that cover the parameter space evenly; scrambling randomizes these points while preserving their low-discrepancy structure [24, 22]. Duplicates are removed, and unused precomputed candidates fill any remaining slots.

The candidate generation uses only the information available at the current attempt. For a retry, configurations that have failed on the current problem are removed. The learner scores all candidates in Ut,j\mathcal{U}_{t,j} but constructs and evaluates only the selected configuration, at,ja_{t,j}. Each executed learned attempt provides two forms of feedback: a cost feedback that measures the computational cost of the selected configuration and is used by the setup cost model, and a binary failure feedback that is used by a separate failure model to guide retries. We define these two signals as follows.

Cost feedback. Each learned attempt (t,j)(t, j) is assigned a cost Bt,jB_{t,j} used to construct the setup-learning target. This training cost is distinct from the measured per-problem runtime CttotalC_{t}^{total} and is defined by

(3.1)

Bt,j=(τt,jset+Ot,j,selset)+(τt,jsol+Ot,jsol)+∑i=1Jt−1Ot−1,i,updset,B_{t,j}=(\tau_{t,j}^{\mathrm{set}}+O_{t,j,\mathrm{sel}}^{\mathrm{set}})+(\tau_{t,j}^{\mathrm{sol}}+O_{t,j}^{\mathrm{sol}})+\sum_{i=1}^{J_{t-1}}O_{t-1,i,\mathrm{upd}}^{\mathrm{set}},

where the first two groups account for setup execution and candidate selection, and solve execution and controller computation, respectively. The time required to update the setup learner's models for the current attempt, including delayed updates using its finalized cost target, is not yet known. We therefore charge every learned attempt on problem tt the total setup-update time from problem t−1t-1, with J0=0J_0 = 0. Hence Bt,jB_{t,j} is a training-cost convention rather than the elapsed runtime of the attempt.

Reported runtime counts learner computation only when it is incurred.

The default fallback uses the reference setup and solve settings and therefore receives no setup-selection, solve-learner, or carried setup-update charge:

(3.2)

Bt,j=τt,jset+τt,jsol.B_{t,j}=\tau_{t,j}^{\mathrm{s e t}}+\tau_{t,j}^{\mathrm{s o l}}.

The cost feedback for a learned attempt is

(3.3)

ℓt,jset={Bt,j,if attempt(t,j)succeeds,Bt,j+Bt,j+1+⋯+Bt,j+s,if attempt(t,j)fails,\ell_{t,j}^{\mathrm{s e t}}=\left\{\begin{aligned}&B_{t,j},&&\text{if attempt}(t,j)\text{succeeds},\\ &B_{t,j}+B_{t,j+1}+\cdots+B_{t,j+s},&&\text{if attempt}(t,j)\text{fails},\end{aligned}\right.

where ss is the smallest positive integer for which attempt (t,j+s)(t,j+s) successfully constructs a hierarchy, regardless of its solve convergence. If no subsequent hierarchy construction, including that of the default fallback, succeeds within the budget, we take j+s=Jtj+s=J_{t}, so the feedback includes the costs of all remaining failed attempts. Thus, a successful attempt receives its own assigned cost, while a failed attempt, whether due to construction failure or nonconvergence, receives the cumulative assigned cost through the attempt (t,j+s)(t,j+s). This hierarchy-dependent training feedback is designed to avoid favoring configurations that fail quickly during construction. All executed attempts still contribute to the measured total per-problem runtime CttotalC_{t}^{total}.

Failure feedback. Each learned attempt also produces a binary outcome

(3.4)

ft,j={0,if attempt (t,j) succeeds1,if attempt (t,j) failsf_{t,j}=\begin{cases}0,&if~attempt~(t,j)~succeeds\\1,&if~attempt~(t,j)~fails\end{cases}

which is used by the auxiliary failure model when selecting a retry. Unlike the cost feedback of a failed attempt that depends on the costs of subsequent attempts, ft,jf_{t,j} is known immediately when attempt (t,j)(t,j) terminates. The failure model can therefore incorporate this observation before the next retry is selected. The two feedback signals serve different purposes:

• ℓt,jset\ell_{t,j}^{set} trains the cost model used for initial setup selection;

ft,jf_{t,j} trains the failure model used to avoid unreliable configurations during retries. Both models and their shared feature representation are defined in Section 3.2.

3.2. Shared context–action models and training. The setup learner maintains two linear models that use the same features but different responses. The cost model predicts the setup-learning loss ℓt,jset\ell_{t,j}^{set}, while the failure model uses the binary outcome ft,jf_{t,j}. We first encode a setup configuration aa. The five numeric controls are scaled as

(3.5)

zr=(ar−aˉr)/sr,r=1,…,5,z_{r}=(a_{r}-\bar{a}_{r})/s_{r},\qquad r=1,\ldots,5,

where aˉ=(0.25,0.90,0,4,0)\bar{a} = (0.25, 0.90, 0, 4, 0), and s=(0.25,0.10,0.20,4,1)s = (0.25, 0.10, 0.20, 4, 1). We encode the categorical parameters using one-hot encoding, with the default category chosen as the reference. Each retained indicator equals 1 when its category is selected and 0 otherwise, so the default category is represented by an all-zero vector. For a6a_6, a7a_7, and a8a_8, the default values are 10, 6, and 4, respectively. These parameters have 6, 8, and 3 categories, including the default, giving 5, 7, and 2 indicators, respectively. Concatenating the three indicator vectors gives c(a)∈{0,1}14c(a) \in \{0,1\}^{14}. With z=(z1,…,z5)⊤z = (z_1, \ldots, z_5)^\top, we encode the setup configuration by

(3.6)

g(a)=(z⊤,(zr2)r=15,(zrzs)1≤r<s≤5,c(a)⊤,(c(a)⊗z)⊤)⊤∈R104,g(a)=\left(z^{\top},(z_{r}^{2})_{r=1}^{5},(z_{r}z_{s})_{1\leq r<s\leq5},c(a)^{\top},(c(a)\otimes z)^{\top}\right)^{\top}\in\mathbb{R}^{104},

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

which includes the scaled numeric controls, their squares and pairwise products, the categorical indicators, and numeric-categorical interactions.

We then combine this setup encoding with the problem context. Let χ∈Rdχ\chi \in \mathbb{R}^{d_\chi} denote a generic problem context vector, where χ=(1,χ2,…,χdχ)⊤\chi = (1, \chi_2, \ldots, \chi_{d_\chi})^\top with χ(1)=1\chi(1) = 1 providing an intercept. Define the feature vector used by both models as

(3.7)

ϕset(χ,a)=(χ⊤,g(a)⊤,χ2g(a)⊤,…,χdχg(a)⊤)⊤∈Rdset,dset=105dχ.\phi^{\mathrm{s e t}}(\chi,a)=\left(\chi^{\top},g(a)^{\top},\chi_{2}g(a)^{\top},\ldots,\chi_{d_{\chi}}g(a)^{\top}\right)^{\top}\in\mathbb{R}^{d_{\mathrm{s e t}}},\quad d_{\mathrm{s e t}}=105d_{\chi}.

The interaction terms χig(a)⊤\chi_i g(a)^\top allow the effect of a setup configuration to depend on the problem context. Each executed learned attempt or successful default fallback provides one observation for both models. Index these observations by i=1,…,ni = 1, \ldots, n, with (ti,ji)(t_i, j_i) denoting the corresponding problem and attempt. The two models use the same input ϕset(χti,ati,ji)\phi^{\text{set}}(\chi_{t_i}, a_{t_i, j_i}), but different responses that are yiset=ℓti,jisety_i^{\text{set}} = \ell_{t_i, j_i}^{\text{set}} in (3.3), and fi=fti,jif_i = f_{t_i, j_i} in (3.4), respectively.

Cost model. The cost model is

(3.8)

μ^nset(χ,a)=ϕset(χ,a)⊤θ^nset.\widehat{\mu}_{n}^{\mathrm{s e t}}(\chi,a)=\phi^{\mathrm{s e t}}(\chi,a)^{\top}\widehat{\theta}_{n}^{\mathrm{s e t}}.

With λset=1\lambda_{set}=1, define

(3.9)

Vnset=λsetI+∑i=1nϕset(χti,ati,ji)ϕset(χti,ati,ji)⊤,bnset=∑i=1nyisetϕset(χti,ati,ji),θ^nset=(Vnset)−1bnset.\begin{align*}\mathsf{V}_{n}^{\mathrm{set}}&=\lambda_{\mathrm{set}}I+\sum_{i=1}^{n}\phi^{\mathrm{set}}(\chi_{t_{i}},a_{t_{i},j_{i}})\phi^{\mathrm{set}}(\chi_{t_{i}},a_{t_{i},j_{i}})^{\top},\\\mathbf{b}_{n}^{\mathrm{set}}&=\sum_{i=1}^{n}y_{i}^{\mathrm{set}}\phi^{\mathrm{set}}(\chi_{t_{i}},a_{t_{i},j_{i}}),\\\widehat{\theta}_{n}^{\mathrm{set}}&=(\mathsf{V}_{n}^{\mathrm{set}})^{-1}\mathbf{b}_{n}^{\mathrm{set}}.\end{align*}

Failure model. The failure model uses the same feature matrix Vnset\mathbf{V}_{n}^{\mathrm{set}}, but replaces the cost response yisety_{i}^{\mathrm{set}} by the failure response fif_{i}:

(3.10)

bnfail=∑i=1nfiϕset(χti,ati,ji),θ^nfail=(Vnset)−1bnfail.\mathbf{b}_{n}^{\mathrm{f a i l}}=\sum_{i=1}^{n}f_{i}\phi^{\mathrm{s e t}}(\chi_{t_{i}},a_{t_{i},j_{i}}),\qquad\widehat{\theta}_{n}^{\mathrm{f a i l}}=(\mathsf{V}_{n}^{\mathrm{s e t}})^{-1}\mathbf{b}_{n}^{\mathrm{f a i l}}.

Its prediction for candidate a is

(3.11)

f^n(χ,a)=ϕset(χ,a)⊤θ^nfail.\widehat{f}_{n}(\chi,a)=\phi^{\mathrm{s e t}}(\chi,a)^{\top}\widehat{\theta}_{n}^{\mathrm{f a i l}}.

Because this is least-squares regression on binary responses, f^n\widehat{f}_{n} is a ranking score rather than a calibrated failure probability and need not lie in [0,1].

The two models are updated online as learned attempts are executed. Failure feedback is available immediately, whereas the final cost response may depend on subsequent attempts; the corresponding update procedure is described in Section 3.3.

3.3. LinUCB selection, retries, and online feedback. Let n denote the number of setup-learning observations incorporated before the current selection. For context χ\chi and candidate a, define the LinUCB width

(3.12)

σnset(χ,a)=ϕset(χ,a)⊤(Vnset)−1ϕset(χ,a).\sigma_{n}^{\mathrm{s e t}}(\chi,a)=\sqrt{\phi^{\mathrm{s e t}}(\chi,a)^{\top}(\mathsf{V}_{n}^{\mathrm{s e t}})^{-1}\phi^{\mathrm{s e t}}(\chi,a)}.

The first setup decision of the online run uses BoomerAMG's default. For the first attempt of each subsequent problem, candidates are ranked using the cost model:

(3.13)

LCBnset(χ,a)=μ^nset(χ,a)−αnσnset(χ,a),αn=1n+1,\mathrm{L C B}_{n}^{\mathrm{s e t}}(\chi,a)=\widehat{\mu}_{n}^{\mathrm{s e t}}(\chi,a)-\alpha_{n}\sigma_{n}^{\mathrm{s e t}}(\chi,a),\qquad\alpha_{n}=\frac{1}{\sqrt{n+1}},

and the candidate with the smallest score is selected. Because cost is minimized, the negative uncertainty term temporarily favors less-observed feature directions. This effect decreases as αn\alpha_{n} decays with n.

If a learned attempt fails and another learned attempt is allowed, its outcome is incorporated before the retry is selected. Configurations that have already failed on the current problem are removed, and the remaining candidates are ranked using the failure model:

(3.14)

UCBnfail(χ,a)=f^n(χ,a)+βfailσnset(χ,a),βfail=2.\mathrm{U C B}_{n}^{\mathrm{f a i l}}(\chi,a)=\widehat{f}_{n}(\chi,a)+\beta_{\mathrm{f a i l}}\sigma_{n}^{\mathrm{s e t}}(\chi,a),\qquad\beta_{\mathrm{f a i l}}=2.

The candidate with the smallest score is selected. A smaller f^n\widehat{f}_n indicates less association with previous failures, while the positive uncertainty term penalizes poorly observed feature directions. Thus, uncertainty encourages exploration for the first attempt but discourages uncertain choices after a failure. Ties in UCBnfail\mathrm{UCB}_n^{\text{fail}} are broken using the current cost LCB, followed by random selection if necessary. If the learned-attempt budget is exhausted, a final attempt uses the default setup and solve settings. After each learned attempt, its feature vector is incorporated once into the shared matrix Vnset\mathbf{V}_n^{\text{set}}, and the failure response fif_i is immediately incorporated into the failure model. A retry on the same problem therefore uses the newly observed failure information.

The cost model is also updated at this point, but the final response may not yet be available. If an attempt fails, ℓt,jset\ell_{t,j}^{\text{set}} depends on the costs of subsequent attempts through (3.3). The implementation therefore first uses the current cost prediction as a provisional response. Once the required subsequent cost is known, the provisional response is replaced by the final value yiset=ℓt,i,jisety_i^{\text{set}} = \ell_{t,i,j_i}^{\text{set}}. This correction changes the cost response but does not add a second observation to Vnset\mathbf{V}_n^{\text{set}}.

All executed learned attempts are retained as setup-learning observations. A default fallback enters the cost target of the preceding failed learned attempt. If it succeeds, it also provides a setup-learning observation for the default configuration, with cost target Bt,jB_{t,j} and failure label zero. An unsuccessful default fallback does not add a separate setup-learning observation.

  1. Solve-Phase Reinforcement Learning. The setup learner selects the parameters used to construct the AMG hierarchy, whereas the solve learner selects a relaxation weight before each AMG V-cycle. The hierarchy remains fixed throughout an attempt, but the relaxation weight chosen at one cycle affects the residual state, and therefore the effectiveness and cost of subsequent cycles. Thus, the solve decisions are sequentially coupled. We therefore train the solve learner to minimize the expected execution time of the remaining cycles in the current attempt, rather than optimizing the residual reduction or execution time of the next cycle alone.

Sequential multigrid control has previously been studied using offline-trained PPO policies [13]. In contrast, our solve learner updates online throughout the problem sequence and conditions its decisions on the problem context, selected setup configuration, and observed solve trajectory. We use an online variant of least-squares temporal-difference action-value estimation (LSTDQ) [15], augmented with eligibility traces following the LSTD( λ\lambda) construction [3].

4.1. Cycle-level control and remaining-time objective. Fix problem tt and attempt jj, with setup configuration at,ja_{t,j} and hierarchy Ht(at,j)\mathcal{H}_{t}(a_{t,j}). The hierarchy remains fixed throughout the attempt. During the solve, the learner repeatedly observes the current solver state, selects a relaxation weight, executes one V-cycle, and observes the resulting cycle cost and new state.

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

Let kk denote the number of completed cycles and uk(t,j)\mathbf{u}_{k}^{(t,j)} the current iterate. Before cycle k+1k+1, the learner selects

(4.1)

wt,j,k∈W,W={1,1.05,…,3}.w_{t,j,k}\in\mathcal{W},\qquad\mathcal{W}=\{1,1.05,\ldots,3\}.

All other solve settings remain fixed: one ℓ1\ell_{1}-Jacobi sweep in each direction and a direct coarsest-level solve. The solve terminates at convergence, the cycle limit Kmax⁡K_{\max}, or solver failure. Let Kt,j≤Kmax⁡K_{t,j} \leq K_{\max} denote the number of executed cycles. The cost observed after applying wt,j,kw_{t,j,k} is

(4.2)

ct,j,ksol=solver execution time of cycle k+1.c_{t,j,k}^{\mathrm{s o l}}=\mathrm{s o l v e r~e x e c u t i o n~t i m e~o f~c y c l e~}k+1.

This includes solver-side parameter updates, the AMG cycle, and residual and stopping checks, but excludes solve-learner computation. Let st,j,ks_{t,j,k} denote the solver state immediately before cycle k+1k+1. It summarizes the fixed problem and hierarchy together with the solve history available at that point. To use this state in the LSTDQ model, we represent it by the feature vector h(st,j,k)h(s_{t,j,k}) defined in (4.7) in Section 4.2. Within an attempt, we suppress (t,j)(t,j), writing sks_k, wkw_k, cksolc_k^{\text{sol}}, and KK. Thus, each cycle produces the transition

(sk,wk)⟶(cksol,sk+1).(s_{k},w_{k})\longrightarrow(c_{k}^{\mathrm{s o l}},s_{k+1}).

The solve learner seeks weights that reduce the time required to complete the remaining cycles. To define this learning target, consider a specified, possibly randomized solve policy πsol\pi^{\mathrm{sol}}. Its action value is

(4.3)

Qπsol(s,w)=Eπsol[∑r=kK−1crsol∣sk=s,wk=w].Q^{\pi^{\mathrm{s o l}}}(s,w)=\mathbb{E}_{\pi^{\mathrm{s o l}}}\left[\sum_{r=k}^{K-1}c_{r}^{\mathrm{s o l}}\Bigg|s_{k}=s,w_{k}=w\right].

Hence Qπsol(s,w)Q^{\pi^{\mathrm{sol}}}(s,w) is the expected remaining cycle execution time after choosing weight w in state s and following πsol\pi^{\mathrm{sol}} thereafter. Costs are undiscounted ( γ=1\gamma = 1), and the value after termination is zero. The target in (4.3) measures remaining cycle execution time until the current attempt terminates. It excludes learner computation, subsequent recovery attempts, and any terminal failure penalty.

4.2. LSTDQ model and online training. The solve learner approximates the remaining-time target in (4.3). For a specified solve policy,

(4.4)

Qπsol(sk,wk)=Eπsol[cksol+Qπsol(sk+1,wk+1)∣sk,wk],Q^{\pi^{\mathrm{s o l}}}(s_{k},w_{k})=\mathbb{E}_{\pi^{\mathrm{s o l}}}\left[c_{k}^{\mathrm{s o l}}+Q^{\pi^{\mathrm{s o l}}}(s_{k+1},w_{k+1})\Big|s_{k},w_{k}\right],

with zero successor value at termination. LSTDQ uses this one-step relation to learn a remaining-time predictor from observed cycle transitions.

State representation. The solve learner represents the current state using the problem context, selected hierarchy, cycle index, and recent solve history. Within attempt (t,j)(t,j), write a=at,ja = a_{t,j}, ϱk=ϱt,j,k\varrho_k = \varrho_{t,j,k}, and χt=(1,ξ⊤)⊤\chi_t = (1,\xi^\top)^\top, with ξ∈Rdx−1\xi \in \mathbb{R}^{d_x-1}. For k≥1k \geq 1, define

(4.5)

gk=log⁡(ϱk/εtol)log⁡(1/εtol),dk=log⁡(ϱk/ϱk−1)log⁡(1/εtol),qk=log⁡(1+ck−1sol10−3s),wˉk=wk−1−2.\begin{aligned}&g_{k}=\frac{\log(\varrho_{k}/\varepsilon_{\mathrm{tol}})}{\log(1/\varepsilon_{\mathrm{tol}})},\quad&d_{k}=\frac{\log(\varrho_{k}/\varrho_{k-1})}{\log(1/\varepsilon_{\mathrm{tol}})},\\&q_{k}=\log\left(1+\frac{c_{k-1}^{\mathrm{sol}}}{10^{-3}\mathrm{s}}\right),\quad&\bar{w}_{k}=w_{k-1}-2.\\ \end{aligned}

These features measure the residual gap to tolerance, recent residual change, logarithmically scaled absolute cycle time, and previous relaxation weight. We initialize (g0,d0,q0,wˉ0)=(1,0,0,−1)(g_0, d_0, q_0, \bar{w}_0) = (1, 0, 0, -1).

To identify the AMG hierarchy used by the solve learner, encode the selected setup configuration by

(4.6)

ζ(a)=(z~⊤,c(a)⊤)⊤∈R19,z~r=2(ar−armin⁡)armax⁡−armin⁡−1,\zeta(a)=(\widetilde{z}^{\top},c(a)^{\top})^{\top}\in\mathbb{R}^{19},\qquad\widetilde{z}_{r}=\frac{2(a_{r}-a_{r}^{\min})}{a_{r}^{\max}-a_{r}^{\min}}-1,

using the five numeric controls normalized to [−1,1][-1,1] over their allowed ranges and 14 categorical indicators from Section 3.2. This descriptor is fixed within an attempt. The state feature vector is

(4.7)

h(sk)=(1,k/Kmax⁡,gk,gk2,dk,qk,wˉk,ξ⊤,ζ(a)⊤)⊤∈R25+dx.h(s_{k})=\left(1,k/K_{\max},g_{k},g_{k}^{2},d_{k},q_{k},\bar{w}_{k},\xi^{\top},\zeta(a)^{\top}\right)^{\top}\in\mathbb{R}^{25+d_{x}}.

Weight representation and predictor. The action set contains 41 relaxation weights. To reduce the dimension of the LSTDQ model and the cost of evaluating all actions, we represent ww using nine localized basis functions centered at κr=1+0.25(r−1)\kappa_{r}=1+0.25(r-1), r=1,…,9r=1,\ldots,9:

(4.8)

b~r(w)=exp⁡(−(w−κr)22(0.2)2)1{∣w−κr∣≤0.5},br(w)=b~r(w)∑v=19b~v(w),b(w)=(b1(w),…,b9(w))⊤.\begin{align*}\widetilde{b}_{r}(w)&=\exp\biggl(-\frac{(w-\kappa_{r})^{2}}{2(0.2)^{2}}\biggr)\mathbf{1}\{|w-\kappa_{r}|\leq0.5\},\\b_{r}(w)&=\frac{\widetilde{b}_{r}(w)}{\sum_{v=1}^{9}\widetilde{b}_{v}(w)},\qquad b(w)=(b_{1}(w),\ldots,b_{9}(w))^{\top}.\end{align*}

Nearby weights therefore have similar representations.

Combining the action and state representations gives

(4.9)

ϕsol(s,w)=b(w)⊗h(s)∈Rdsol,dsol=9(25+dχ).\phi^{\mathrm{s o l}}(s,w)=b(w)\otimes h(s)\in\mathbb{R}^{d_{\mathrm{s o l}}},\qquad d_{\mathrm{s o l}}=9(25+d_{\chi}).

The remaining-time predictor is

(4.10)

Q^n(s,w)=(θ^nsol)⊤ϕsol(s,w),\widehat{Q}_{n}(s,w)=(\widehat{\theta}_{n}^{\mathrm{s o l}})^{\top}\phi^{\mathrm{s o l}}(s,w),

where θ^nsol\widehat{\theta}_{n}^{\mathrm{sol}} is estimated by LSTDQ below. Writing θ^nsol\widehat{\theta}_{n}^{\mathrm{sol}} as nine blocks θ^n,rsol\widehat{\theta}_{n,r}^{\mathrm{sol}} gives

Q^n(s,w)=∑r=19br(w)(θ^n,rsol)⊤h(s).\widehat{Q}_{n}(s,w)=\sum_{r=1}^{9}b_{r}(w)\big(\widehat{\theta}_{n,r}^{\mathrm{s o l}}\big)^{\top}h(s).

Thus, for a fixed state, only the nine quantities (θ^n,rsol)⊤h(s)(\widehat{\theta}_{n,r}^{\mathrm{sol}})^{\top}h(s) need to be computed. They are then reused with the precomputed b(w)b(w) to evaluate all 41 candidate weights, rather than evaluating 41 separate state-dependent predictors.

LSTDQ update. For transition i, let

(4.11)

ϕisol=ϕsol(si,wi),ϕisol′=ϕsol(si+1,wi+1),\phi_{i}^{\mathrm{s o l}}=\phi^{\mathrm{s o l}}(s_{i},w_{i}),\qquad\phi_{i}^{\mathrm{s o l}\prime}=\phi^{\mathrm{s o l}}(s_{i+1},w_{i+1}),

where wi+1w_{i+1} is the next weight actually executed. At termination, ϕisol=0\phi_i^{\text{sol}} = 0. To propagate each observed cycle cost to recent state-weight pairs, LSTDQ maintains an eligibility-trace vector zi\mathbf{z}_i:

(4.12)

zi=λtrzi−1+ϕisol,\mathbf{z}_{i}=\lambda_{\mathrm{tr}}\mathbf{z}_{i-1}+\phi_{i}^{\mathrm{sol}},

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

where λtr=0.8\lambda_{tr}=0.8 controls the geometric decay of contributions from preceding cycles. Thus, zi\mathbf{z}_{i} combines the current feature with decaying contributions from earlier transitions in the same solve attempt.

With regularization parameter λsol=1\lambda_{sol}=1, the LSTDQ system is

(4.13)

Ansol=λsolI+∑i=1nzi(ϕisol−ϕisoll)⊤,bnsol=∑i=1nzicisol,θ^nsol=(Ansol)−1bnsol.\begin{align*}\mathsf{A}_{n}^{\mathrm{sol}}&=\lambda_{\mathrm{sol}}I+\sum_{i=1}^{n}\mathbf{z}_{i}(\phi_{i}^{\mathrm{sol}}-\phi_{i}^{\mathrm{sol}l})^{\top},\\\mathbf{b}_{n}^{\mathrm{sol}}&=\sum_{i=1}^{n}\mathbf{z}_{i}c_{i}^{\mathrm{sol}},\\\widehat{\theta}_{n}^{\mathrm{sol}}&=(\mathsf{A}_{n}^{\mathrm{sol}})^{-1}\mathbf{b}_{n}^{\mathrm{sol}}.\end{align*}

The eligibility trace is reset between solve attempts: for the first transition of each attempt, the preceding trace is set to zero.

4.3. Weight selection and exploration. At each cycle, the solve learner uses the current LSTDQ predictor Q^n(s,w)\widehat{Q}_n(s, w) together with a mismatch-based exploration score σn,msol(s,w)\sigma_{n,m}^{\text{sol}}(s, w). With a small probability it instead selects a weight uniformly at random. We define these two exploration mechanisms below.

Mismatch-based exploration. Let mm denote the number of solve attempts retained in the LSTDQ model. For attempt ee, let Ie\mathcal{I}_e denote its cycle transitions and define

(4.14)

ΔAesol=∑i∈Iezi(ϕisol−ϕisoll)⊤,Δbesol=∑i∈Iezicisol.\Delta\mathsf{A}_{e}^{\mathrm{s o l}}=\sum_{i\in\mathcal{I}_{e}}\mathbf{z}_{i}(\phi_{i}^{\mathrm{s o l}}-\phi_{i}^{\mathrm{s o l}l})^{\top},\qquad\Delta\mathbf{b}_{e}^{\mathrm{s o l}}=\sum_{i\in\mathcal{I}_{e}}\mathbf{z}_{i}c_{i}^{\mathrm{s o l}}.

Let θ^eend\widehat{\theta}_{e}^{\mathrm{end}} be the fitted LSTDQ coefficient vector at the end of attempt e, and define its mismatch by

(4.15)

ge=Δbesol−ΔAesolθ^eend.\mathbf{g}_{e}=\Delta\mathbf{b}_{e}^{\mathrm{s o l}}-\Delta\mathsf{A}_{e}^{\mathrm{s o l}}\widehat{\theta}_{e}^{\mathrm{e n d}}.

Accumulating these mismatches gives

(4.16)

Ωmsol=(10−3)2λsolI+∑e=1mgege⊤,σn,msol(s,w)2=ϕsol(s,w)⊤(Ansol)−1Ωmsol(Ansol)−⊤ϕsol(s,w).\begin{align*}\Omega_{m}^{\mathrm{sol}}&=(10^{-3})^{2}\lambda_{\mathrm{sol}}I+\sum_{e=1}^{m}\mathbf{g}_{e}\mathbf{g}_{e}^{\top},\\\sigma_{n,m}^{\mathrm{sol}}(s,w)^{2}&=\phi^{\mathrm{sol}}(s,w)^{\top}(\mathsf{A}_{n}^{\mathrm{sol}})^{-1}\Omega_{m}^{\mathrm{sol}}(\mathsf{A}_{n}^{\mathrm{sol}})^{-\top}\phi^{\mathrm{sol}}(s,w).\end{align*}

A larger σn,msol(s,w)\sigma_{n,m}^{\mathrm{sol}}(s,w) indicates a state-weight direction associated with larger past LSTDQ mismatch. It is used as an exploration score rather than as a calibrated standard error.

The model-based weight is selected by

(4.17)

wk∈arg⁡min⁡w∈Wmax⁡{Q^n(sk,w)−2σn,msol(sk,w),0}.w_{k}\in\underset{w\in\mathcal{W}}{\arg\min}\max\Big\{\widehat{Q}_{n}(s_{k},w)-2\sigma_{n,m}^{\mathrm{sol}}(s_{k},w),0\Big\}.

Thus, a small predicted remaining time is preferred, while a large mismatch score encourages exploration.

Random exploration. To provide model-independent exploration, we also select a weight uniformly from W with probability

(4.18)

ϵnrand=0.03+0.27exp⁡(−n/20000),\epsilon_{n}^{\mathrm{r a n d}}=0.03+0.27\exp(-n/20000),

where nn is the total number of solve-cycle transitions observed so far. The first solve action uses w=1w=1; thereafter, (4.17) is used with probability 1−ϵnrand1-\epsilon_{n}^{\mathrm{rand}}. Hence, random

Figure

FIG. 1. Online LinUCB-LSTDQ autotuning of BoomerAMG. The contextual bandit selects the AMG setup between solve attempts, while recursive LSTDQ selects the relaxation weight between V-cycles within a fixed hierarchy. Failed learned configurations trigger retries and, after the retry budget is exhausted, a fixed Default fallback. Both learners retain information across the problem sequence and optimize the cumulative recorded runtime.

exploration is strongest early in the online run and decreases as more transitions are observed.

Figure 1 summarizes the complete LinUCB-LSTDQ procedure. The setup learner selects a BoomerAMG configuration between attempts, while the solve learner selects relaxation weights between V-cycles within the resulting fixed hierarchy. Failed learned configurations may trigger another setup attempt, followed by the fixed default configuration after at most Jmax⁡−1J_{\max} - 1 learned attempts. Both learners retain information across problems.

  1. Numerical Experiments. In this section, we evaluate the online autotuner on sequences of structured anisotropic diffusion and diffusion-advection systems. The experiments address four questions:

  2. whether setup and solve learning reduce end-to-end runtime;

  3. how performance evolves during online learning;

  4. how the method behaves on a more difficult variable-flow problem family;

  5. whether adaptive relaxation provides benefit when the hierarchy is held fixed. We first compare BoomerAMG's default, LSTDQ, LinUCB, and LinUCB-LSTDQ across problem sizes and random seeds, then examine the online trajectories and cycle-

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

level relaxation choices. A matched-hierarchy study isolates the effect of relaxation control from setup selection, and a diffusion-advection test with a spatially varying flow field evaluates robustness beyond the constant-coefficient sequences. The primary metric is total recorded runtime, including recurring learner computation; setup-plus-solve execution time is also reported separately. The code and experiment scripts are publicly available 1^{1}.

All runs use the same source and solver-library versions on an Apple M5 Pro with 24 GB RAM, running macOS 27.0 (ARM64), with HYPRE 3.0.0 and Python 3.10.21, one MPI rank, and one compute thread per solver process. The four methods execute serially within each problem using balanced random-permutation ordering.

5.1. Problem families, features, and protocol. We compare four complete online procedures. Throughout the experiments, Default denotes BoomerAMG's default setup configuration with fixed relaxation weight w=1w = 1 and the common ℓ1\ell_1-Jacobi smoothing profile specified below; it uses one attempt per problem, Jmax⁡=1J_{\max} = 1. LSTDQ keeps the default setup but learns the cycle-level relaxation weights; if its learned solve attempt fails, one default fallback is allowed with Jmax⁡=2J_{\max} = 2. LinUCB learns the setup parameters while retaining the reference solve settings, and the combined LinUCB-LSTDQ learns both the setup and solve. The two setup-learning methods, namely LinUCB and LinUCB-LSTDQ, allow up to three learned setup attempts followed by one default fallback where Jmax⁡=4J_{\max} = 4. The reported runtime includes all executed attempts. Each learned method maintains and updates its own model. Thus, the four-way comparison evaluates complete online procedures rather than different relaxation policies on the same hierarchy. Section 5.6 isolates the relaxation effect using matched hierarchies.

Diffusion family. The first problem family is the seven-point finite-difference discretization of

(5.1)

−∂x(cx∂xu)−∂y(cy∂yu)−∂z(cz∂zu)=fin(0,1)3,u∣∂(0,1)3=0.-\partial_{x}(c_{x}\partial_{x}u)-\partial_{y}(c_{y}\partial_{y}u)-\partial_{z}(c_{z}\partial_{z}u)=f\quad\mathrm{i n}(0,1)^{3},\qquad u|_{\partial(0,1)^{3}}=0.

The diffusion-convection problem generator in hypre (DifConv) is used on the grids of sizes 40340^{3}, 60360^{3}, and 80380^{3}, giving 64,000, 216,000, and 512,000 unknowns. For each problem, cx,cy,czc_{x}, c_{y}, c_{z} are sampled independently and uniformly from [1, 1000] and remain spatially constant; advection is zero. The learners use normalized PDE coefficients as context, rather than spectral information extracted from the matrix. Define

(5.2)

ℓi,t=log⁡(ci,t)log⁡(1000),i∈{x,y,z}.\ell_{i,t}=\frac{\log(c_{i,t})}{\log(1000)},\qquad i\in\{x,y,z\}.

Both learners receive

(5.3)

χt=(1,ℓx,t,ℓy,t,ℓz,t)⊤∈R4.\chi_{t}=(1,\ell_{x,t},\ell_{y,t},\ell_{z,t})^{\top}\in\mathbb{R}^{4}.

Diffusion-advection family. The second family discretizes

(5.4)

−∇⋅(Dt∇u)+bt⋅∇u=f,Dt=diag(cx,t,cy,t,cz,t),-\nabla\cdot(\mathbf{D}_{t}\nabla u)+\mathbf{b}_{t}\cdot\nabla u=f,\qquad\mathbf{D}_{t}=\mathrm{d i a g}(c_{x,t},c_{y,t},c_{z,t}),

on the same domain and grids, with homogeneous Dirichlet boundary conditions. The generator uses centered differences for diffusion and upwind differences for advection. The three diffusion and three advection coefficients are sampled independently and

1^{1}https://github.com/EriseHe/BoomerAMG-Autotuner uniformly from [1,1000] and remain spatially constant within each problem. Using the same ℓi,t\ell_{i,t} as above and bscale=1000b_{scale}=1000, define

(5.5)

b~i,t=sgn(bi,t)log⁡(1+∣bi,t∣)log⁡(1+bscale),i∈{x,y,z}.\widetilde{b}_{i,t}=\frac{\mathrm{s g n}(b_{i,t})\log(1+|b_{i,t}|)}{\log(1+b_{\mathrm{s c a l e}})},\qquad i\in\{x,y,z\}.

The context is

(5.6)

χt=(1,ℓx,t,ℓy,t,ℓz,t,b~x,t,b~y,t,b~z,t)⊤∈R7.\chi_{t}=(1,\ell_{x,t},\ell_{y,t},\ell_{z,t},\widetilde{b}_{x,t},\widetilde{b}_{y,t},\widetilde{b}_{z,t})^{\top}\in\mathbb{R}^{7}.

Solver and online protocol. All experiments use seeded random right-hand sides with zero initial iterates. The common solve profile uses one ℓ1\ell_1-Jacobi pre- and post-smoothing sweep and Gaussian elimination on the coarsest level, which correspond to hypre relaxation options 18 and 9. The reference relaxation weight is w=1w = 1. Every attempt uses relative residual tolerance 10−610^{-6} and cycle limit Kmax⁡=50K_{\max} = 50.

At each grid size, all four methods receive the same ordered sequence of 5000 matrix/right-hand-side pairs. The learned methods start without pretraining and update throughout this online phase. They then process 1000 additional problems with model updates and random exploration disabled. Recurring overhead, including feature construction and action selection, remains included in both phases. Both of the setup learners use the search space in Table 3 and the same 1024-candidate construction procedure, but evolve independently. Each solve learner likewise receives the setup descriptor ζ(a)\zeta(a) selected by its own branch. We report six seed settings for every family and grid. Each seed determines the problem sequence, learner randomization, candidate generation, and within-problem method ordering.

Timing and aggregation. The solver cost CtsolverC_{t}^{solver} in (2.3) includes setup and solve execution across all attempts. The total cost CttotalC_{t}^{total} additionally includes recurring setup- and solve-learner computation. The times of matrix and right-hand-side assembly, experiment orchestration, one-time preparation, and output I/O are excluded. Failed attempts remain included in both costs.

We report runtime reductions over the full online learning sequence and the additional frozen phase to evaluate generalization to new instances. The corresponding index sets are

(5.7)

Wonline={1,…,5000},Wfrozen={5001,…,6000}.W_{\mathrm{o n l i n e}}=\{1,\ldots,5000\},\qquad W_{\mathrm{f r o z e n}}=\{5001,\ldots,6000\}.

For seed ss, window W∈{Wonline,Wfrozen}W \in \{W_{\mathrm{online}}, W_{\mathrm{frozen}}\}, and method Π\Pi, the total-time reduction relative to the default is

(5.8)

Rs,Wtotal(Π)=100[1−∑t∈WCs,ttotal(Π)∑t∈WCs,ttotal(Πdef)].R_{s,W}^{\mathrm{t o t a l}}(\Pi)=100\left[1-\frac{\sum_{t\in W}C_{s,t}^{\mathrm{t o t a l}}(\Pi)}{\sum_{t\in W}C_{s,t}^{\mathrm{t o t a l}}(\Pi_{\mathrm{d e f}})}\right].

All problems ultimately succeed in the constant-coefficient experiments, so these sums include the full cost of any failed attempts and subsequent recovery. Solver-time reduction is defined analogously using CsolverC^{solver}. Reported reductions are the mean and sample standard deviation of paired seed-level values, with seeds weighted equally. The standard deviation therefore measures variation across independent adaptive runs; individual problems within a sequence are not treated as independent replicates.

5.2. Runtime across problem sizes. Table 4 summarizes online runtime and total-time reductions for all four methods at the three grid sizes. Setup and solve execution times are reported separately from learner overhead, and total-time reductions

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

TABLE 4

Online runtime decomposition and total-time reductions during the online (problems 1–5000) and frozen (problems 5001–6000) phases. Setup and solve execution include all attempts, and learner overhead includes recurring setup- and solve-learner computation. Time columns are in ms per problem and average the six seed-level means. Both reduction columns report the mean ± sample standard deviation of paired total-time reductions relative to the default, including learner overhead; positive values favor the learned method.

MethodOnline (1–5000)Frozen (5001–6000)
SetupSolveLearner overheadTotal-time reductionTotal-time reduction
Diffusion, 40³
The default57.424.90.0——
LSTDQ57.417.52.06.5 ± 0.5%8.1 ± 0.7%
LinUCB21.940.73.120.2 ± 0.7%28.4 ± 1.3%
LinUCB–LSTDQ20.725.66.236.1 ± 1.0%47.0 ± 1.7%
Diffusion, 60³
The default203.788.40.0——
LSTDQ204.264.62.57.1 ± 0.6%9.2 ± 0.6%
LinUCB73.6135.73.127.3 ± 1.1%32.9 ± 0.9%
LinUCB–LSTDQ70.787.96.943.3 ± 1.3%49.8 ± 0.8%
Diffusion, 80³
The default514.3232.40.0——
LSTDQ515.3161.42.89.0 ± 0.4%9.8 ± 0.4%
LinUCB208.8350.83.824.6 ± 4.0%29.9 ± 2.4%
LinUCB–LSTDQ178.9242.37.942.5 ± 2.3%49.1 ± 1.3%
Diffusion–advection, 40³
The default58.324.60.0——
LSTDQ58.317.32.26.2 ± 0.4%7.9 ± 0.5%
LinUCB28.742.64.28.9 ± 2.7%24.8 ± 3.2%
LinUCB–LSTDQ23.034.78.819.8 ± 1.3%37.0 ± 1.7%
Diffusion–advection, 60³
The default206.987.90.0——
LSTDQ207.462.22.77.6 ± 0.7%9.1 ± 0.7%
LinUCB100.0147.94.314.5 ± 2.5%25.6 ± 2.2%
LinUCB–LSTDQ78.1115.89.631.0 ± 2.0%40.5 ± 2.1%
Diffusion–advection, 80³
The default521.1229.60.0——
LSTDQ522.0159.23.08.9 ± 0.3%9.8 ± 0.3%
LinUCB222.8413.94.514.6 ± 1.6%23.1 ± 2.7%
LinUCB–LSTDQ201.8311.410.630.2 ± 1.6%36.8 ± 1.4%

include all three components. Across the 40³, 60³, and 80³ grids, LinUCB–LSTDQ reduces total runtime by 36.1%, 43.3%, and 42.5% for diffusion and 19.8%, 31.0%, and 30.2% for diffusion–advection. Its learner overhead accounts for approximately 11.8–13.2%, 4.2–4.7%, and 1.8–2.0% of total online runtime, respectively.

Table 4 also compares the full online sequence and frozen phase. For LinUCB–LSTDQ, the reductions in the additional frozen phase range from 47.0% to 49.8% for diffusion and from 36.8% to 40.5% for diffusion–advection. The gains are smaller for diffusion–advection than for diffusion, but the frozen-phase reductions exceed the full online-sequence reductions at every grid size. This pattern suggests that the policy learned over the first 5,000 problems remains effective on new instances.

5.3. Runtime decomposition and online behavior. Figure 2 shows how setup, solve, and learner costs contribute to total runtime on the 60³ diffusion problems. The online bars summarize the full sequence, problems 1–5000. Setup-only

LinUCB reduces mean setup time by 63.9% per problem, but increases mean solve time by 53.5% relative to the default. Thus, a hierarchy that is cheaper to construct may not yield a more efficient solve phase. Standalone LSTDQ reduces mean solve time by 26.9% on the default hierarchy (88.4 to 64.6 ms). Across the independently trained branches, LinUCB-LSTDQ has 35.2% lower mean solve time than setup-only LinUCB (87.9 versus 135.7 ms), with similar setup costs (70.7 versus 73.6 ms per problem). The joint method therefore preserves the setup savings while reducing the solve-cost penalty observed with setup-only learning. The frozen bars, which report problems 5001–6000, show the same qualitative pattern on new instances after the learners have accumulated experience. Together, the paired bars show that setup selection and cycle-level relaxation control address complementary components of the total runtime.

Figure

FIG. 2. Runtime decomposition on 60³ diffusion across six seeds. Paired stacks show setup execution, setup-learner overhead, solve execution, and solve-learner overhead. Labels report total runtime as mean ± sample standard deviation of seed-level means (ms/problem), for the online phase (problems 1–5000) and the frozen phase (problems 5001–6000).

Across all three grid sizes and learned methods, the cumulative runtime reduction increases over the 5,000-problem sequence. To illustrate how the performance difference develops during online learning across problem families and grid sizes, we show the first problem index from which LinUCB-LSTDQ overcomes its initial runtime disadvantage and maintains cumulative savings over the default for the remainder of the sequence as shown in Figure 3. Smaller PDE systems, such as those on a 40³ grid, have shorter runtimes, making learner overhead a larger fraction of the total cost and thus harder to amortize. Diffusion-advection problems generally reach payback later than pure diffusion problems. In particular, we show one 60³ diffusion trajectory to illustrate how the runtime advantage develops progressively over the sequence rather than arising from a small number of isolated problems. The selected seed, 3, has the largest full-sequence reduction among the completed diffusion runs and is used only for illustration; the aggregate comparisons above provide the primary performance results. For this run, LinUCB-LSTDQ reduces average total runtime from 293.4 to 160.4 ms per problem over the full sequence, a 45.3% reduction relative to the default. Over the 1000 frozen problems, the reduction is 50.6%.

5.4. Hierarchy and cycle-level parameter choices. In the selected 5000-problem online run, LinUCB-LSTDQ has 88 first-attempt failures, all of which are resolved by retries without using the default fallback. All failed attempts and subsequent recovery are included in the reported runtime. Figure 4 shows how first-attempt setup configurations and relaxation weights evolve as the learners train online from

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

Online runtime and break-even

(a) Joint break-even problem index (six seeds per case)

Figure

---- Default (1467.2 s) — LSTDQ (1358.1 s) — LinUCB (1046.1 s) — LinUCB-LSTDQ (802.1 s)

FIG. 3. Online runtime and break-even behavior. (a) Joint-method break-even problem indices across six seeds per case. The break-even problem index is the first index from which the joint method's cumulative total runtime remains below the default's through problem 5000. Open points show individual seeds; whiskers and labels give the minimum-maximum range. The red point identifies the run illustrated in (b,c). (b,c) Illustrative 60360^{3} diffusion run, seed 3: cumulative total runtime and percentage reduction relative to the default, over problems 1–5000 in (b) and 1–2500 in (c). All executed attempts and recurring learner computation are included. Curves are unsmoothed prefix sums; the inset enlarges problems 1–1000. The black vertical guide in (c) marks the break-even problem index, 357. Legend values give online-phase runtime in seconds.

scratch in this run. In Figure 4(a), the setup choices become increasingly concen-

LinUCB-LSTDQ (Diffusion 60360^{3}, seed 3)

(a) Setup configurations

Figure

FIG. 4. First-attempt setup choices and relaxation weights selected by LinUCB-LSTDQ in the illustrative 60360^{3} diffusion run, seed 3. Columns correspond to problems 1–2500. (a) Setup parameters a1,…,a8a_{1}, \ldots, a_{8}, defined in Table 3. (b) Rows correspond to zero-based cycle indices, increasing downward. White cells indicate that the first attempt has terminated. Cycles from retries and the default fallback are omitted.

trated as more problems are solved. Over problems 2001–2500, first attempts favor a strength threshold of 0.95 (in 99.6% of the problems), standard interpolation (97.4%), and a maximum of two nonzero entries per interpolation row (83.0%). The higher strength threshold restricts the strong-connection graph, while the smaller row limit restricts interpolation density. These choices can reduce construction cost, consistent with the benefits of limiting interpolation complexity reported for three-dimensional diffusion problems [7]. The learned relaxation policy also develops more prominent recurring high–low patterns as the hierarchy selections narrow. As shown in Figure 4(b), its choices vary across both problems and cycle indices. Table 5 gives a concrete example from problem 2275 in this run. Benefiting from both more efficient hierarchy construction and a nonstationary relaxation policy, the method achieves the largest recorded individual total-time reduction, 72.7%, relative to the default. Despite higher grid complexity, the operator and memory complexities are 15.4% and 18.2% lower, respectively, which helps explain the observed 81.0% reduction in setup time. The 51.7% reduction in native solve time results from both fewer V-cycles (13 to 8) and a 21.5% reduction in average time per V-cycle (7.71 to 6.05 ms).

TABLE 5

Setup configuration, hierarchy statistics, and runtime for the 60³ diffusion problem 2275, seed 3. Only setup parameters that differ from the default are shown. Both methods converge on their first attempt. Total time includes learner overhead; the per-problem total-time reduction is 72.7%. This selected best case is illustrative rather than an average performance result. Grid complexity is the ratio of total unknowns across levels to fine-grid unknowns. Operator and memory complexities are the ratios of total operator nonzeros and total operator-plus-interpolation nonzeros, respectively, to fine-grid operator nonzeros.

SymbolParameterDefaultLinUCB–LSTDQReduction
a1a_1strong_threshold0.250.95
a2a_2max_row_sum0.900.95
a4a_4P_max_elmts42
a7a_7interp_typeExtended+i (6)Standard (8)
Setup execution (ms)308.8458.5481.0%
Grid complexity1.6767591.971565−17.6%
Operator complexity4.4934223.80097715.4%
Memory complexity5.1660804.22449718.2%
Solve execution (ms)100.2048.4151.7%
V-cycles13838.5%
Average time per V-cycle (ms)7.716.0521.5%
Setup- and solve-learner overhead (ms)04.58—
Total time (ms)409.03111.5372.7%

The combination of the learned AMG hierarchy and solve policy is consistent with the complementary roles of hierarchy selection and relaxation control. Coarse-grid correction and relaxation divide the work of reducing error. Accordingly, changing interpolation and coarse-grid operators during setup changes which error components coarse-grid correction handles effectively—and hence which components relaxation must reduce [25, 12]. Section 5.6 provides a numerical rationale for the recurring high–low relaxation weights observed in Figure 4(b) and compares fixed, prescribed periodic, and learned policies on identical hierarchies. Over the full displayed sequence, problems 1–2500, mean setup time decreases from 203.1 to 76.1 ms per problem, while mean solve time remains close to that of the default (92.3 versus 90.0 ms). Including all attempts and learner overhead, total runtime decreases by 40.1%.

To examine this behavior at the level of individual solves, Figure 5 shows three

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

Learned relaxation schedules (Diffusion 80380^{3}, seed 5, LinUCB + LSTDQ)

Figure

FIG. 5. Adaptive relaxation on 80380^{3} diffusion, seed 5, for consecutive problems A, B, and C (1563, 1564, and 1565). (a) Recorded LinUCB–LSTDQ weights; crosses mark random exploratory actions, and the horizontal black line marks w = 1. (b–d) Residual histories for problems A–C, respectively, comparing LinUCB–LSTDQ (colored) with the paired default (black). The three residual panels share axis scales. Dotted lines mark the convergence tolerance. Legend percentages give total-time reductions relative to the default on the same problem, including learner overhead. All three joint-method solves succeed on their first attempt and are shown through convergence.

consecutive problems A, B, and C (1563, 1564, and 1565) from the joint method on 80380^{3} diffusion, seed 5. Under the online-selected setup configurations, the three problems reach tolerance in 11, 12, and 16 cycles with different relaxation trajectories. Their initial relaxation weights are 2.05, 2.35, and 3.00, respectively, and only the initial choice for problem B is a random exploratory action. The corresponding residual histories in panels (b)–(d) show how the solves progress. For reference, Figure 5 also shows the default on the same problem inputs, using the default hierarchy and fixed weight w = 1. In particular, problem C exhibits temporary residual increases during several high-weight cycles, followed by substantial decreases under lower weights. Despite this nonmonotone behavior, the solve reaches tolerance in 16 cycles, compared with 19 for the default; the joint method reduces total runtime by 55.9% on that problem. These examples illustrate the cycle-level behavior produced by the online learner, but they do not by themselves isolate the effect of relaxation control because the joint method and the default use different hierarchies. The matched-hierarchy experiment in Section 5.6 provides that controlled comparison.

5.5. Variable-flow diffusion–advection. Next, we evaluate the online methods on a more challenging diffusion–advection family with a spatially varying flow field. This experiment complements the preceding constant-coefficient tests by introducing stronger variation in the linear systems encountered along the online sequence. We use hypre's generator 2^{2} to discretize the following problem:

(5.9)

−ϵtΔu+v(x,y,z)⋅∇u=fin(0,1)3,u∣∂(0,1)3=0,v(x,y,z)=((2y−1)(1−x2),2xy(y−1),2xy(y−1)).\begin{align*}-\epsilon_{t}\Delta u+\mathbf{v}(x,y,z)\cdot\nabla u&=f\quad in(0,1)^{3},\qquad u|_{\partial(0,1)^{3}}=0,\\\mathbf{v}(x,y,z)=\left((2y-1)(1-x^{2}),2xy(y-1),2xy(y-1)\right).\end{align*}

The flow field is fixed, while log⁡10ϵt\log_{10}\epsilon_t is sampled uniformly for each problem from [−4,−1][-4,-1], so the diffusion strength varies over three orders of magnitude. We use a 60360^3 interior grid, seeded random right-hand sides, and zero initial iterates. The learner context is

(5.10)

χt=(1,2(log⁡10ϵt+4)3−1)⊤.\chi_{t}=\left(1,\frac{2(\log_{10}\epsilon_{t}+4)}{3}-1\right)^{\top}.

2^{2}https://github.com/hypre-space/hypre/blob/v3.0.0/src/parcrs_ls/par_vardifconv_rs.c

As in the constant-coefficient experiments, the learned methods begin without pre-training and learn online from the first problem in each sequence. We use six paired 5000-problem sequences. The setup search space, smoother, stopping tolerance, cycle limit, and method-specific attempt budgets are unchanged from Section 5.1. Because the methods have different recovery budgets, we report both first-attempt failures and failures that remain after each permitted attempt.

TABLE 6

Variable-flow diffusion-advection on the 60³ grid, over 30,000 problems across six seeds. Failure columns give the numbers of problems remaining unsolved after each attempt; italicized counts mark final failures. The last permitted attempt uses the default recovery for LSTDQ, LinUCB, and LinUCB-LSTDQ. The final column gives total-time reductions relative to the paired default as mean ± sample standard deviation across six seeds, including all executed attempts and recurring learner overhead.

MethodFailures after attemptTotal-time reduction
j = 1j = 2j = 3j = 4
Default (Jmax = 1)1677————
LSTDQ (Jmax = 2)77726——9.8 ± 5.6%
LinUCB (Jmax = 4)81062442850.8 ± 2.9%
LinUCB-LSTDQ (Jmax = 4)115213869254.1 ± 2.1%

The differences between the methods are substantially larger on this variable-flow family. LinUCB-LSTDQ reduces the number of final failures from 1677 for the default to only 2, while reducing total time by 54.1 ± 2.1% over the full sequence. Over the final 1000 problems of each sequence, the joint method has one final failure among 6000 problems and achieves a 59.2 ± 2.4% total-time reduction. The stronger late-sequence result is consistent with the online learners becoming more effective as additional problems are observed.

The runtime reduction is not explained simply by the methods succeeding on different sets of problems. Restricting the comparison to the 28,323 problems completed by all four methods gives a similar full-sequence total-time reduction of 53.4 ± 2.2% for LinUCB-LSTDQ. The fixed-setup comparison isolates the contribution of cycle-level relaxation control. With the reference hierarchy held fixed, the learned LSTDQ attempt succeeds without fallback on 1,651 of the 1,677 problems on which Default fails, within the same 50-cycle limit. Including recovery attempts, its mean solve time decreases from 304.3 ms per problem for the default to 230.3 ms. Thus, adaptive relaxation alone provides both a substantial robustness improvement and a reduction in solve cost on this problem family. The joint method obtains additional gains by adapting the setup configuration. Including recovery attempts, its mean setup time is 129.8 ms per problem, compared with 324.6 ms for the default, while its mean solve time decreases further to 150.3 ms. These phase-level timings show that the overall improvement comes from both components: Standalone LSTDQ improves solve performance on a fixed hierarchy, while the joint method uses LinUCB to reduce setup cost and select hierarchies that further benefit adaptive relaxation.

5.6. Matched-hierarchy comparison of relaxation policies. We then perform matched-hierarchy experiments in which the hierarchy is held fixed and only the relaxation policy is changed. The experiments ask two questions:

  1. whether varying relaxation weights across cycles improves over the fixed-weight strategy;

  2. whether the learned LSTDQ policy improves over a prescribed varying-weight

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

schedule derived from classical smoothing analysis.

We use the final learner states from the six 60360^{3} diffusion and six 60360^{3} variable-flow diffusion-advection online runs and freeze them for this controlled evaluation. Each frozen learner is evaluated on the same 100 additional problems that were not part of its original 5000-problem sequence. For each learner state and evaluation problem, the setup configuration selected by the frozen setup learner is held fixed across all relaxation policies. Thus, the compared policies use the same matrix, right-hand side, zero initial iterate, hierarchy, tolerance, and cycle limit. No evaluation observation updates either learner. Results are then aggregated over the 100 problems, and variability is reported across the six independent online runs. For each frozen learner state, we compare five policies:

  1. Fixed w: the reference relaxation weight used by the default.

  2. Global best: a single best fixed weight chosen from the 41 admissible weights to minimize total first-attempt native solve time over the 100 evaluation problems.

  3. Per-problem best: the best fixed weight chosen separately from the 41 admissible weights to minimize first-attempt native solve time for each evaluation problem.

  4. Period two: a prescribed alternating two-weight schedule derived from an SPD smoothing surrogate, without using measured PDE runtimes.

  5. Frozen LSTDQ: the cycle-level policy from the corresponding completed online run, with its model parameters fixed during evaluation.

The global and per-problem best fixed policies are comparison references rather than deployable online methods, since their selection requires evaluating all 41 candidate weights on the evaluation problems. The weight-selection scan averages three timings per problem-weight pair. After selection, the chosen policies are retimed independently; the weight-selection scan itself is excluded from the reported cost.

The period-two policy provides a prescribed nonlearning reference based on the weighted two-level smoothing criterion of Lottes [18]. Its construction exploits the SPD structure of the diffusion problems rather than measured runtimes. For an SPD matrix A=(aij)\mathbf{A} = (a_{ij}), let D=diag(∑j∣aij∣)D = \mathrm{diag}(\sum_j |a_{ij}|). Then A⪯D\mathbf{A} \preceq D. The eigenvalues of D−1AD^{-1}\mathbf{A} lie in (0,1](0,1]. For weighted Jacobi, the error update is e′=(I−wD−1A)ee' = (I - wD^{-1}\mathbf{A})e. For an eigenmode with eigenvalue ξ\xi, one step multiplies its error by 1−wξ1 - w\xi. For the smoothing surrogate, we consider two successive weighted-Jacobi steps with weights aa and bb. These steps multiply the mode's error by

(5.11)

pa,b(ξ)=(1−aξ)(1−bξ),p_{a,b}(\xi)=(1-a\xi)(1-b\xi),

where a small ∣pa,b(ξ)∣|p_{a,b}(\xi)| means that the mode is strongly reduced. The quantity

(5.12)

η(a,b)=max⁡0≤ξ≤1ξpa,b(ξ)2\eta(a,b)=\max_{0\leq\xi\leq1}\xi p_{a,b}(\xi)^{2}

weights the squared error amplification by ξ\xi and takes the worst case over the spectral interval. This emphasizes modes with larger eigenvalues, which relaxation is intended to damp. Modes near ξ=0\xi = 0 receive less weight because coarse-grid correction is expected to handle them. Minimizing η(a,b)\eta(a, b) gives a prescribed alternating pair for comparison with learned weights. Note here that this is a smoothing surrogate, rather than a prediction of full AMG convergence or runtime. The unconstrained optimum is 2±2/52 \pm 2/\sqrt{5}. Because the solve learner only permits weights in the discrete action set W\mathcal{W}, we evaluate the surrogate over all pairs a,b∈Wa, b \in \mathcal{W}:

(5.13)

(aW,bW)=(2.85,1.10)∈argmin⁡a,b∈Wη(a,b).(a_{\mathcal{W}},b_{\mathcal{W}})=(2.85,1.10)\in\operatorname*{a r g m i n}_{a,b\in\mathcal{W}}\eta(a,b).

We apply the resulting pair in high-low order between complete AMG cycles,

(5.14)

2.85, 1.10, 2.85, 1.10,…,2.85,\ 1.10,\ 2.85,\ 1.10,\ldots,

with the sequence restarted at the beginning of each problem.

This construction should be interpreted as a strong structured baseline for the present SPD diffusion test. In particular, the same derivation does not directly apply to the nonsymmetric diffusion–advection problems considered elsewhere in this paper. All five policies are timed under the same evaluation protocol. We compare the native solver execution time in the first attempt on the matched hierarchy. Hierarchy-construction time, learner computation, and all subsequent recovery or fallback work are excluded. Elapsed times from all 100 problems are retained regardless of convergence; these timings do not measure time to successful completion. Failure rates are reported alongside them and refer to the prescribed Kmax=50K_{max} = 50 stopping rule.

Figure 6 compares the four alternatives with fixed w = 1. On diffusion, the global best and per-problem best fixed policies reduce mean first-attempt native solve time by 34.0% and 35.8%, respectively. The period-two and frozen-LSTDQ policies give reductions of 41.2% and 39.6%. On variable-flow diffusion-advection, the corresponding reductions are 23.2%, 30.9%, -3.2%, and 23.6%, respectively. Thus, on these matched SPD diffusion hierarchies, both varying-weight policies outperform the tested fixed-weight references on average in first-attempt native solve time. Together with the runtime decomposition in Figure 2, this supports the benefit of the joint strategy: low-cost hierarchy construction is paired with relaxation control that improves the subsequent solve time.

(a) Diffusion 60360^{3}

Figure

(b) Variable-flow diffusion-advection 60360^{3}

FIG. 6. First-attempt native solve-time reduction relative to fixed w = 1 on matched joint-selected hierarchies. (a) 60360^{3} diffusion. (b) 60360^{3} variable-flow diffusion-advection. Open points show results from the six final learner states; diamonds and whiskers give their mean and sample standard deviation. Each value is computed from summed costs on 100 problems. Both panels use the same horizontal scale; all first-attempt times are included regardless of convergence.

On diffusion, Table 7 shows that frozen LSTDQ reduces mean first-attempt native solve time by 8.5% relative to the global best fixed weight and by 5.9% relative to the per-problem best fixed weight. Frozen LSTDQ has 2.8% higher mean first-attempt native solve time than the prescribed period-two schedule. Thus, varying weights improves on the tested fixed-weight references, while a simple SPD-derived schedule captures much of this benefit without learning.

On variable-flow diffusion-advection, the period-two schedule fails to converge within the prescribed cycle limit on 43.0% of the test problems (258 of 600), predominantly at small diffusion coefficients ( ϵ<0.005\epsilon < 0.005). In contrast to the SPD diffusion results, frozen LSTDQ achieves a 25.8% reduction in native solve time relative to the

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

TABLE 7

Frozen-LSTDQ first-attempt native solve-time reduction relative to matched-hierarchy references (%). Reductions are mean ± sample standard deviation across the six final learner states for each 60³ problem family. Positive values favor LSTDQ. Failure rates are computed over 600 first attempts per policy and family.

Policy/referenceDiffusionVariable flow
Time reductionFailure rateTime reductionFailure rate
Fixed w=1w=139.6±1.5%39.6 \pm 1.5\%0.5%23.6±5.8%23.6 \pm 5.8\%5.2%
Global best fixed8.5±2.1%8.5 \pm 2.1\%0.2%0.4±6.1%0.4 \pm 6.1\%1.0%
Per-problem best fixed5.9±2.0%5.9 \pm 2.0\%0.0%−10.6±7.0%-10.6 \pm 7.0\%0.2%
Periodic (2.85, 1.10)−2.8±3.8%-2.8 \pm 3.8\%0.3%25.8±6.0%25.8 \pm 6.0\%43.0%
Frozen LSTDQ—0.2%—0.3%

period-two schedule, with a first-attempt failure rate of 0.3%. It achieves a slight mean solve-time reduction of 0.4% relative to the global best fixed reference, but a reduction of -10.6% relative to the per-problem best fixed reference. The failure rates of these two fixed references are 1.0% and 0.2%, respectively. The robustness advantage therefore holds relative to fixed w=1w=1 and the prescribed period-two schedule; the results do not establish consistent superiority over the optimized per-problem fixed-weight references across different PDE families.

Matched-hierarchy relaxation weights (Variable-flow 60360^{3}, seed 1)

Figure

(c) Periodic (2.85, 1.10)

(d) Frozen RL

FIG. 7. Recorded weights for fixed w = 1, the per-problem best fixed weight, period-two (2.85,1.10), and frozen LSTDQ on identical joint-selected hierarchies. The illustration uses seed 1. All panels contain the same 100 problems, ordered by decreasing first-attempt cycle count for w = 1, with case ID breaking ties. Cycle zero is at the top; white cells follow primary-attempt termination. Recovery cycles are omitted.

Figure 7 shows the different forms of relaxation control in one illustrative run on variable-flow diffusion–advection. Columns are ordered by the fixed-w = 1 first-attempt cycle count, so their left-to-right progression does not represent continued learning. The per-problem best fixed weight in (b) changes between problems but remains constant within each solve. The period-two policy in (c) follows the same prescribed alternating sequence on every problem, with limited transferability to this variable-flow family. In panel (d), frozen LSTDQ often maintains weights near w =

1 for several consecutive cycles before switching to alternating choices whose onset and duration vary. Among the 37 problems on which the period-two schedule fails to converge in this illustrative run, frozen LSTDQ converges on 36. On many of these nonsymmetric problems, it adopts a substantially different relaxation strategy, maintaining relatively constant low weights over extended portions of the solve rather than using strict high-low alternation. These weights are similar to the per-problem best fixed weights. For example, at displayed problem index 50, frozen LSTDQ holds w=1.30w = 1.30 for 15 consecutive cycles, close to the per-problem best fixed weight of w=1.35w = 1.35 for that problem. The displayed run illustrates these qualitative differences and highlights the adaptive nature of our hierarchy-aware LSTDQ policy across different problems.

  1. Conclusion. We developed an online autotuner for hypre's BoomerAMG that combines LinUCB-based AMG setup selection with LSTDQ-based cycle-level relaxation control, without offline pretraining. Across the tested problem sequences, jointly adapting the AMG hierarchy and relaxation weights reduces total recorded runtime relative to the default, with generally larger gains later in each sequence. The experiments show the separate benefits of bandit-based setup tuning and RL-based solve control, as well as their coordinated adaptation during online learning. The hierarchy-aware nonstationary relaxation policy improves solve performance, while setup learning adapts hierarchy selection to the evolving solve policy.

Overall, the results suggest that online autotuning is most useful when effective solver choices cannot be prescribed reliably in advance. Our reliance on measured AMG runtime also makes the learning process sensitive to timing variability and execution conditions. Future work will consider broader problem families, improved exploration, and large-scale parallel settings.

Acknowledgment. The authors used GPT 6.1 to assist with manuscript drafting and editing, literature review, and theoretical development, and Codex to assist with coding. The authors take full responsibility for the accuracy and integrity of the work.

REFERENCES

[1] P. F. ANTONIETTI, M. CALDANA, L. B. D. GENTILE, AND M. VERANI, Deep learning accelerated algebraic multigrid methods for polytopal discretizations of second-order differential problems, Mathematical Models and Methods in Applied Sciences, 36 (2026), pp. 1649–1677, https://doi.org/10.1142/S0218202526420029. [2] A. H. BAKER, R. D. FALGOUT, T. V. KOLEV, AND U. M. YANG, Multigrid smoothers for ultraparallel computing, SIAM Journal on Scientific Computing, 33 (2011), pp. 2864–2887. [3] J. A. BOYAN, Technical update: Least-squares temporal difference learning, Machine Learning, 49 (2002), pp. 233–246, https://doi.org/10.1023/A:1017936530646. [4] M. CALDANA, P. F. ANTONIETTI, AND L. DEDE, A deep learning algorithm to accelerate algebraic multigrid methods in finite element solvers of 3D elliptic PDEs, Computers & Mathematics with Applications, 167 (2024), pp. 217–231. [5] W. CHU, L. LI, L. REYZIN, AND R. E. SCHAPIRE, Contextual bandits with linear payoff functions, in Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics, vol. 15 of Proceedings of Machine Learning Research, 2011, pp. 208–214. [6] P. D'AMBRA, F. DURASTANTE, AND S. FILIPPONE, AMG preconditioners for linear solvers towards extreme scale, SIAM Journal on Scientific Computing, 43 (2021), pp. S339–S358. [7] H. DE STERCK, R. D. FALGOUT, J. W. NOLTING, AND U. M. YANG, Distance-two interpolation for parallel algebraic multigrid, Numerical Linear Algebra with Applications, 15 (2008), pp. 115–139, https://doi.org/10.1002/nla.559. [8] H. DE STERCK, U. M. YANG, AND J. J. HEYS, Reducing complexity in parallel algebraic multigrid preconditioners, SIAM Journal on Matrix Analysis and Applications, 27 (2006),

X. HE, R. WANG, Y. DING, R. LI, AND Y. XI

pp. 1019–1039.

[9] H. GAHVARI, A. H. BAKER, M. SCHULZ, U. M. YANG, K. E. JORDAN, AND W. GROPP, Modeling the performance of an algebraic multigrid cycle on HPC platforms, in Proceedings of the 25th International Conference on Supercomputing, 2011, pp. 172–181.

[10] V. E. HENSON AND U. M. YANG, BoomerAMG: a parallel algebraic multigrid solver and preconditioner, Applied Numerical Mathematics, 41 (2002), pp. 155–177.

[11] R. HUANG, K. CHANG, H. HE, R. LI, AND Y. XI, Reducing operator complexity of Galerkin coarse-grid operators with machine learning, SIAM Journal on Scientific Computing, 46 (2024), pp. S296–S316, https://doi.org/10.1137/23M1583533.

[12] R. HUANG, R. LI, AND Y. XI, Learning optimal multigrid smoothers via neural networks, SIAM Journal on Scientific Computing, 45 (2023), pp. S199–S225, https://doi.org/10.1137/21M1430030.

[13] D. HUERGO, L. ALONSO, S. JOSHI, A. JUANICOTENA, G. RUBIO, AND E. FERRER, A reinforcement learning strategy to automate and accelerate h/p-multigrid solvers, Results in Engineering, 24 (2024), p. 102949, https://doi.org/10.1016/j.rineng.2024.102949.

[14] M. KHODAK, E. CHOW, M.-F. BALCAN, AND A. TAIWALKAR, Learning to relax: Setting solver parameters across a sequence of linear system instances, in The Twelfth International Conference on Learning Representations (ICLR 2024), OpenReview.net, 2024, https://openreview.net/forum?id=5t57omGVMw.

[15] M. G. LAGOUDAKIS AND R. PARR, Least-squares policy iteration, Journal of Machine Learning Research, 4 (2003), pp. 1107–1149.

[16] L. Li, W. CHU, J. LANGFORD, AND R. E. SCHAPIRE, A contextual-bandit approach to personalized news article recommendation, in Proceedings of the 19th International Conference on World Wide Web, 2010, pp. 661–670, https://doi.org/10.1145/1772690.1772758.

[17] Y. LIU, W. M. SID-LAKHDAR, O. MARQUES, X. ZHU, C. MENG, J. W. DEMMEL, AND X. S. LI, GPTune: Multitask learning for autotuning exascale applications, in Proceedings of the 26th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, 2021, pp. 234–246, https://doi.org/10.1145/3437801.3441621.

[18] J. LOTTES, Optimal polynomial smoothers for multigrid V-cycles, Numerical Linear Algebra with Applications, 30 (2023), p. e2518, https://doi.org/10.1002/nla.2518.

[19] I. LUZ, M. GALUN, H. MARON, R. BASRI, AND I. YAVNEH, Learning algebraic multigrid using graph neural networks, in Proceedings of the 37th International Conference on Machine Learning, vol. 119 of Proceedings of Machine Learning Research, 2020, pp. 6489–6499, https://proceedings.mlr.press/v119/luz20a.html.

[20] S. P. MACLACHLAN AND L. N. OLSON, Theoretical bounds for algebraic multigrid performance: Review and analysis, Numerical Linear Algebra with Applications, 21 (2014), pp. 194–220, https://doi.org/10.1002/nla.1930.

[21] S. MISHRA, W. TROJAK, AND F. D. WITHERDEN, Online Bayesian optimization of polynomial-multigrid cycles for flux reconstruction, AIAA Journal, 62 (2024), pp. 2692–2707, https://doi.org/10.2514/1.J063607.

[22] A. B. OWEN, Randomly permuted (t,m,s)(t, m, s)-nets and (t,s)(t, s)-sequences, in Monte Carlo and Quasi-Monte Carlo Methods in Scientific Computing, H. Niederreiter and P. J.-S. Shiue, eds., vol. 106 of Lecture Notes in Statistics, Springer, 1995, pp. 299–317, https://doi.org/10.1007/978-1-4612-2552-2_19.

[23] J. W. RUGE AND K. STÜBEN, Algebraic multigrid, in Multigrid Methods, SIAM, 1987, pp. 73–130.

[24] I. M. SOBOL', On the distribution of points in a cube and the approximate evaluation of integrals, USSR Computational Mathematics and Mathematical Physics, 7 (1967), pp. 86–112, https://doi.org/10.1016/0041-5553(67)90144-9.

[25] J. XU AND L. ZIKATANOV, Algebraic multigrid methods, Acta Numerica, 26 (2017), pp. 591–721.

[26] X. XU, Z. MO, X. YUE, H. AN, AND S. SHU, α\alphaSetup-AMG: an adaptive-setup-based parallel AMG solver for sequence of sparse linear systems, CCF Transactions on High Performance Computing, 2 (2020), pp. 98–110.

[27] U. M. YANG, On long-range interpolation operators for aggressive coarsening, Numerical Linear Algebra with Applications, 17 (2010), pp. 453–472, https://doi.org/10.1002/nla.689.

[28] X. ZHU, Y. LIU, P. GHYSELS, D. BINDEL, AND X. S. LI, GPTuneBand: Multi-task and multi-fidelity autotuning for large-scale high performance computing applications, in Proceedings of the 2022 SIAM Conference on Parallel Processing for Scientific Computing, SIAM, 2022, pp. 1–13, https://doi.org/10.1137/1.9781611977141.1.

References (17)