<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Performance of several Lanczos eigensolvers with HISQ fermions</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>01/01/2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10340513</idno>
					<idno type="doi">10.22323/1.396.0053</idno>
					<title level='j'>Pos proceedings of science</title>
<idno>1824-8039</idno>
<biblScope unit="volume">053</biblScope>
<biblScope unit="issue"></biblScope>					

					<author>H Jeong</author><author>C. DeTar</author><author>S. Gottlieb</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[We investigate the state-of-the-art Lanczos eigensolvers available in the Grid and QUDA libraries. They include Implicitly Restarted Lanczos, Thick-Restart Lanczos, and Block Lanczos. We measure and analyze their performance for the Highly Improved Staggered Quark (HISQ) Dirac operator. We also discuss optimization of Chebyshev acceleration.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Introduction</head><p>Recent improvements in lattice QCD calculations have been achieved by making use of the eigenvalue spectrum of lattice operators, such as the lattice Dirac operator and the lattice Laplacian operator. The Lanczos iteration method is an eigensolver algorithm employed for that purpose <ref type="bibr">[1]</ref>. It enables calculation of both eigenvalues and eigenvectors of a Hermitian matrix. It is most useful when a partial eigenvalue spectrum is required. Additional iterations provide more eigenmodes with higher accuracy.</p><p>There are several improvement methods for the Lanczos algorithm: <ref type="bibr">(1)</ref> Polynomial acceleration applies a polynomial to the matrix of interest so that the Lanczos iteration converges faster with a transformed eigenvalue spectrum. Chebyshev polynomials are a popular choice <ref type="bibr">[2]</ref>. <ref type="bibr">(2)</ref> There are two kinds of restarted Lanczos algorithms that take advantage of information learned from the previous run. The Implicitly Restarted Lanczos (IRL) algorithm suppresses unwanted eigenvalues at the restart <ref type="bibr">[3]</ref>. Alternatively, the Thick-Restart Lanczos (TRL) algorithm suppresses or explicitly deflates converged wanted eigenvalues <ref type="bibr">[4]</ref>. <ref type="bibr">(3)</ref> There are approaches that utilize blocking to improve the computational e ciency of the Lanczos algorithm. The Block Lanczos (BL) algorithm can enhance the compute-to-communication ratio with the Split Grid method <ref type="bibr">[5]</ref>.</p><p>Grid <ref type="bibr">[6,</ref><ref type="bibr">7]</ref> and QUDA <ref type="bibr">[8]</ref><ref type="bibr">[9]</ref><ref type="bibr">[10]</ref> are very popular and highly performing lattice QCD libraries, especially for modern parallel computing systems. For the Lanczos eigensolver, Grid has IRL and BL eigensolvers. QUDA has a TRL eigensolver and its block variant. All of them utilize Chebyshev polynomials to enhance the convergence.</p><p>We investigate these Lanczos eigensolver algorithms in the Grid and the QUDA libraries measuring and analyzing their performance for the Highly Improved Staggered Quark (HISQ) Dirac operator. In Section 2, we describe our simulation details. In Section 3, we describe some basics of the Lanczos iteration method. Section 4 describes the general strategy of utilizing Chebyshev polynomials and studies its optimization. In Sections 5 and 6, we illustrate ideas of IRL and TRL, respectively, and discuss their optimizations. In Section 7, we examine the performance of BL with the Split-Grid method. We conclude in Section 8.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Simulation details</head><p>We calculate eigenvalues and eigenvectors of the low modes of the massless HISQ Dirac operator &#8673;. The Lanczos eigensolvers are run using a Hermitian variation &#8673; &#8224; &#8673;, which is (semi)-positive definite that allows even-odd splitting. The eigensolver performance is measured in elapsed time taken by the eigensolver routine itself. We use an # 5 = 2 + 1 + 1 MILC HISQ gauge configuration, with lattice size 24 3 &#8677; 64, lattice spacing 0 &#8673; 0.12 fm, and 0&lt; ; /0&lt; B = 0.00507/0.0507 <ref type="bibr">[11]</ref>.</p><p>We run Grid on Intel CPUs and QUDA on NVIDIA GPUs, where they perform their best so that we can focus on algorithmic performance. All Grid runs are done on a single node of dual Intel Xeon E5-2650v2 system that has 2 &#8677; 8 = 16 CPU cores, where we use only half, i.e., eight, of them for performance stability. We apply OpenMP for their parallelization, except for the BL eigensolver in Section 7, where we apply MPI. QUDA runs are done on the same system but with two NVIDIA K80 GPUs.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Lanczos algorithm and Lanczos iteration method</head><p>Let us consider an &lt; &#8677; &lt; Hermitian matrix , and an &lt;-dimensional vector 1. The Gram-Schmidt process on a set of vectors {1, 1, 2 1, &#8226; &#8226; &#8226; , = 1 1} for = &#63743; &lt;, which spans a Krylov subspace K = ( , 1), gives a three term recurrence relation</p><p>where @ 8 are orthonormal basis vectors of K = ( , 1), and C 8 9 = &#8998; @ 8 @ 9 &#8629;</p><p>. Combining recurrences of 8 = 1, &#8226; &#8226; &#8226; , =, we have</p><p>where</p><p>) is an = &#8677; = Hermitian tridiagonal matrix. The Lanczos algorithm is to construct ) = and &amp; = by iterating the Lanczos recurrence relation Eq. ( <ref type="formula">1</ref>) <ref type="bibr">[1]</ref>. When = = &lt;, &amp; &lt; is a unitary transformation, so ) &lt; has the same eigenvalue spectrum as . Even for = &lt; &lt;, eigenvalues of ) = are approximate to some = eigenvalues of <ref type="bibr">[12]</ref>. They converge to true eigenvalues of as = increases. The largest, the smallest, or the most isolated (the least dense) extreme eigenvalues appear first and converge first. When : (&lt; &lt;) eigenvalues are wanted, we need to perform = (: &#63743; = &#63743; &lt;) iterations of the Lanczos recurrence (Eq. ( <ref type="formula">1</ref>)) with the result that ) = has eigenvalues approximate to : eigenvalues of of interest within the target precision.</p><p>A QR iteration is usually employed to diagonalize a tridiagonal matrix ) = <ref type="bibr">[13,</ref><ref type="bibr">14]</ref>. Then its eigenvalue decomposition gives</p><p>where &#8676; is a diagonal matrix with eigenvalues _ 8 of ) = , and + = is composed of their corresponding eigenvectors E 8 . With this, we calculate eigenvector estimates (called Ritz vectors) F 8 and eigenvalue estimates (called Ritz values) _8 by</p><p>The convergence of each eigenvector is measured by a residual</p><p>or dividing it by some normalization factors. Note that _8 can be di erent from _ 8 since we usually apply a polynomial to , as will be discussed in Section 4.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Chebyshev acceleration</head><p>The convergence of a Lanczos iteration depends on the eigenvalue density. Less dense (including the largest and the smallest) eigenvalues appear early and converge fast. One can control the density of eigenvalues, and, thus, the convergence of Lanczos iteration, by applying a polynomial P to the matrix . It maps eigenvalues _ 8 of into P (_ 8 ) but preserves their eigenvectors.</p><p>Chebyshev polynomials &#8672; ? (G) of degree ? are bounded within <ref type="bibr">[ 1,</ref><ref type="bibr">1]</ref> for |G| &#63743; 1, while diverging rapidly for a high ? as |G| increases for |G| &gt; 1 <ref type="bibr">[15]</ref>. We can transform it to map unwanted eigenvalues into the bounded region and wanted eigenvalues into the diverging region. This Chebyshev acceleration can boost the convergence of Lanczos iteration. With suitable choices of the location of the bounded region and the polynomial degree, its benefit more than compensates for the cost of applying the polynomial.</p><p>Eigenvalues of &#8673; &#8224; &#8673; are non-negative, and our usual interests lie in its low modes. We transform the domain of &#8672; ? (G) so that [ 1, 1] becomes [U, V] that covers the unwanted eigenvalues. The value of U should be set to be greater than the largest desired eigenvalue, and V to be greater than the largest eigenvalue in the whole spectrum. A few power iterations can help to estimate the size of the largest eigenvalue. Choosing U needs some heuristics, but we may use the same value within a gauge ensemble.</p><p>In Fig. <ref type="figure">1</ref>, we show the convergence of Lanczos iterations with di erent Chebyshev acceleration parameters. Here, Grid's ImplictlyRestartedLanczos eigensolver is used with a little modification not to restart. We run 1000 Lanczos iterations, and the convergences are checked by Eq. ( <ref type="formula">4</ref>) in double precision. Figure <ref type="figure">1a</ref> presents the number of converged eigenvalues for di erent U and V values. The same Chebyshev polynomial degree ? = 100 is used here, which means all the runs take the same time in principle. On this gauge configuration, the largest eigenvalue of &#8673; &#8224; &#8673; is around 21, and the 1000th eigenvalue is around 0.046. The result indicates that we get the best convergence when both U and V are the closest to the 1000th eigenvalue and the largest eigenvalue, respectively. The 800th eigenvalue is around 0.034. Hence, U = 0.04 might give a better convergence on this gauge configuration. However, a tight choice may not work for other gauge configurations in the same ensemble.</p><p>In Fig. <ref type="figure">1b</ref>, we present the results for di erent polynomial degrees ?. Here, we used (U, V) = (0.05, 25), the best pair found in Fig. <ref type="figure">1a</ref>. Although higher ? makes more eigenvalues converge, it demands more computations. In this example, ? = 100 gives the best e ciency. In general, the most e cient ? depends on the number of eigenvalues we want. We need heuristics to find an optimized ?.</p><p>Every improved Lanczos algorithm discussed in this paper utilizes Chebyshev acceleration. We use (U, V) = (0.05, 25), and ? = 50 or 100.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.">Implicitly Restarted Lanczos</head><p>A basic Lanczos algorithm must carry on its iteration by increasing the Krylov subspace dimension = until eigenvalues of the desired number converge. As = increases, it takes more memory to store the eigenvectors as well as more computing time for the iteration1 and for the diagonalization of a larger ) = . Moreover, it is di cult to anticipate an optimized (or the smallest) = without monitoring the convergence, which includes diagonalizing ) 8 (8 &lt; =) and computing eigenvectors and their residuals.</p><p>Suppose we have performed = Lanczos iterations for Hermitian matrix (= &#8672; ? (&#8673; &#8224; &#8673;)) with a starting vector 1. The Implicitly Restarted Lanczos (IRL) algorithm allows us to restart from the (= :)-th step of the Lanczos algorithm for with a new starting vector 1 = ( `:) &#8226; &#8226; &#8226; ( `1)1, where the {`8, 8 = 1, . . . :} are some eigenvalues <ref type="bibr">[3]</ref>. The Krylov subspace K = ( , 1) for the restarted run does not contain eigenvectors corresponding to the eigenvalues `8. It not only excludes unwanted eigenvalues and eigenvalues near them, but it also improves the convergence of the remaining wanted eigenvalues far from the {`8 }.</p><p>When we are interested in only the C lowest eigenmodes, a typical implementation of IRL runs the Lanczos iteration to the =-th step, does the implicit restart that excludes the : largest eigenvalues found in the previous run, and repeats them until the C smallest eigenvalues converge. In this way, we can constrain the Krylov subspace dimension to any = &gt; C, as much as the system memory allows. However, since : is usually set to make = : slightly larger than C, = determines how many restarts we need to do. Each restart must perform the QR decomposition : times and do the basis rotations using them. This cost can be comparable to that of many Lanczos iterations. Hence, we need to find an optimized = that maximizes the restarting e ciency.</p><p>The Grid library has an IRL eigensolver named ImplicitlyRestartedLanczos. In Fig. <ref type="figure">2</ref>, we present its performance profiles for various Krylov subspace dimensions = with Chebyshev acceleration of ? = 50, 100. For non-restarted cases, a modified version mentioned in Section 4 is used. Note that in the Lanczos iteration, eigenvalues converge simultaneously, not one by one in order. Hence, it could be less e cient for calculating a small number of eigenvalues. In Fig. <ref type="figure">2a</ref>, where we calculate 100 eigenvalues, the non-restarted Lanczos converges at = = 400 and = = 700 for ? = 50 and ? = 100, respectively. In a (relatively) slowly converging case like this, IRL can perform better than the basic non-restarted Lanczos. For both ? = 50 and 100, we obtain the best performance by restarting once.</p><p>On the other hand, in Fig. <ref type="figure">2b</ref>, where we calculate 500 eigenvalues, the non-restarted Lanczos takes the least time. Here, = = 800, 1050 are only about twice 500, so the restarting costs for = = 600, 700, 800 are comparable to or more expensive than running Lanczos on a bigger Krylov subspace. However, the di erences between = = 700, 800, 1050 are not huge for ? = 50, so one may choose = = 700 to save memory. In addition, unlike the non-restarted Lanczos where the convergence is not guaranteed for a given =, IRL assures its convergence when the same = is used for other gauge configurations, even though it may need more restarts.</p><p>1In practice, Lanczos vectors @ 8 's orthogonality gets inexact as iteration continues due to the accumulation of numerical errors. One can correct it by re-orthogonalizing all @ 8 's per some period of iterations. This is expensive for a large =.  One last remark is that we should optimize the Chebyshev acceleration parameters together with =. In Fig. <ref type="figure">2a</ref>, the non-restarted Lanczos converges faster with ? = 100 than ? = 50, while the IRL's best performance comes with ? = 50.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.">Thick-Restart Lanczos</head><p>In this section, we investigate another restarted Lanczos algorithm called Thick-Restart Lanczos (TRL) <ref type="bibr">[4]</ref>. Unlike IRL, which suppresses unwanted eigenvectors to improve convergence, TRL suppresses (nearly) converged wanted eigenvectors from the Krylov subspace for the restarted run.</p><p>One can rewrite Eq. ( <ref type="formula">2</ref>) as</p><p>where + : is composed of some : (&lt; =) eigenvectors of ) = , and</p><p>) is composed of the corresponding : eigenvector estimates (Ritz vectors) of . &#8676; : is a diagonal matrix of : eigenvalues of ) = that are eigenvalue estimates (Ritz values) of . Note that F 8 's are basis vectors of the same Krylov subspace K = ( , 1). Hence, we can replace &amp; = with , : , and ) = with &#8676; : in Eq. ( <ref type="formula">2</ref>). The TRL algorithm restarts the Lanczos iteration upon , : and &#8676; : , but by appending the vector @ =+1 .2 One problem is that F 8 's are not orthogonal to @ =+1 , so h @ =+1 |F 8 i terms survive in the  Gram-Schmidt process generating @ =+2 . This results in a arrow-like matrix ) =+1 . However, thanks to the symmetry of , the generation of @ =+2+8 (8 1) returns to the normal three-term Lanczos recurrence. Hence, we need to deal only with diagonalizing the arrow-like matrix, which can be done in several ways including the general matrix diagonalization. Now that @ =+2 is orthogonal to F 1 , &#8226; &#8226; &#8226; , F : , approximate eigenvectors of , the restarted run searches on the Krylov subspace orthogonal to them. It focuses on finding other eigenvectors rather than F 8 's, though it still slowly improves F 8 's convergences as well. With a proper choice of :, it can balance the convergence of eigenvalues e ciently.</p><p>The QUDA library has a TRL eigensolver named TRLM. This eigensolver determines : as the number of converged eigenvalues in the desired precision plus the half of the remaining eigenvalues that are still converging. It also implements the locking method, which explicitly deflates some converged eigenvectors from the restarted run. TRLM locks eigenvectors converged to the machine precision. It reduces memory usage and computing cost.</p><p>In Fig. <ref type="figure">3</ref>, we present QUDA TRLM's performance for various Krylov subspace dimensions = with Chebyshev acceleration of ? = 50, 100. In both Fig. <ref type="figure">3a</ref> and Fig. <ref type="figure">3b</ref>, we find TRL can perform better than the non-restarted Lanczos with optimization. One benefit of TRL, compared with IRL, is that its restarting cost can be absorbed into the Ritz vector calculation. That might be why TRL takes the least time for = = 600 with six restarts in Fig. <ref type="figure">3b</ref>.</p><p>Restarted Lanczos algorithms (both TRL and IRL) allow us to use less memory. It is especially useful for GPU systems, where memory is usually lacking. Figure <ref type="figure">3b</ref> does not include the nonrestarted Lanczos result for ? = 50 because it does not converge within the given GPU memory size.  </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.">Block Lanczos with Split Grid</head><p>The Block Lanczos (BL) algorithm runs the Lanczos iteration with multiple (D) starting vectors {1 1 , 1 2 , &#8226; &#8226; &#8226; , 1 D }, where 1 8 's are orthogonal to each other <ref type="bibr">[5]</ref>. At each 9-th iteration of BL, a block version of the Lanczos recurrence Eq. ( <ref type="formula">1</ref>) constructs D basis vectors @</p><p>The convergence of a BL iteration is usually slower than that of the basic Lanczos for the same subspace dimension = = =D, because the Krylov subspace dimension = per starting vector 1 8 is smaller than =. However, on a parallel computing system, BL may outperform the basic Lanczos by parallelizing the multiplications @ 8 9 1 for 8 = 1, &#8226; &#8226; &#8226; , D. The Split Grid method is one way of doing it <ref type="bibr">[5]</ref>. It splits a communication grid such as MPI and distributes parallel jobs into the split grids, so that each job runs with a lower surface-to-volume ratio.</p><p>The Grid library has a BL eigensolver implementing the Split Grid method, named Implic-itlyRestartedBlockLanczos.3 In Fig. <ref type="figure">4</ref>, we compare its performance with the unblocked basic Lanczos and BL without the Split Grid method. The block size for BL is set to D = 8. In this measurement, we run 8 MPI processes connected by an intra-node network. We calculate 500 eigenvalues, for which the unblocked Lanczos converges at = = 800, while the BL converges at = = 904. Hence, without the Split-Grid method, the BL algorithm itself is slower than the basic Lanczos algorithm, as the results show.</p><p>However, the Split Grid method can enhance the BL's performance. In Fig. <ref type="figure">4</ref>, BL's performance is improved by 12% with the Split Grid method, even on the intra-node network. Although it is still a little slower than the unblocked Lanczos, its advantage could become significant on a slow inter-node network.4</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.">Conclusion</head><p>We have discussed improved Lanczos algorithms and their optimizations. A well-tuned Chebyshev polynomial improves the Lanczos iteration's convergence significantly. All other improved 3Although it provides both non-restarted and implicitly restarted versions of BL, the latter is not pursued. 4It is under investigation. A preliminary result shows that with 8 MPI inter-nodes, BL with Split Grid gives around 200% better performance than the unblocked Lanczos.</p><p>Lanczos algorithms utilize it. Restarted Lanczos algorithms, such as Implicitly Restarted Lanczos and Thick-Restart Lanczos, do not always perform better than the non-restarted Lanczos algorithm. Still, we can optimize them to perform better than or comparable to non-restarted Lanczos. It is advantageous for small memory systems such as GPUs. The performance of Block Lanczos utilizing the Split Grid method is comparable to that of the unblocked Lanczos on an intra-node network. It may perform better on inter-node networks.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0"><p>2One cannot start the Lanczos algorithm with an eigenvector, because it generates a rank-1 Krylov subspace.</p></note>
		</body>
		</text>
</TEI>
