Elamur Research

Hierarchical Matrix Operations on GPUs: Matrix-Vector Multiplication and Compression

Paper · 2019 · Wajih Halim Boukaram, George Turkiyyah and David E. Keyes

Summary

A covariance matrix describes how observations vary together. With many observations, it can be too large to store on a graphics processor, even when much of it can be reconstructed from a compact description. Boukaram and colleagues study a representation called an H² matrix. It divides a dense matrix into blocks at different scales, keeps some small blocks in full, and approximates others using a few shared directions. The paper shows how to multiply a matrix in this form by a vector and how to recompress it when its current representation uses more directions than its accuracy requires.

The two operations have different jobs. Multiplication translates the input vector into coordinates suited to each scale, applies the corresponding matrix blocks, and combines the partial answers. Compression uses the information in the blocks to decide which directions the matrix needs, including directions inherited from larger blocks. Both operations have dependencies that follow trees. The authors lay out each tree level in contiguous memory and use small GPU routines to gather the addresses for batches of operations. The batches can then run without having to navigate the trees themselves.

The benchmarks use covariance matrices from 2D and 3D spatial statistics. For a 3D problem with over a million observations, multiplication on a Pascal P100 takes under 29 ms and reaches 78% of the GPU’s theoretical peak bandwidth. Recompressing the million-sized 3D example takes under 1.7 s, at a rate the conclusion describes as almost 850 GFLOPS/s. Multiplication is primarily limited by how fast the GPU can read the representation. Compression does more arithmetic for each block and spends much of its time on factorizations.

The accuracy tests compare the original and recompressed hierarchical matrices with a covariance defined by an analytical kernel. With truncation thresholds chosen for the accuracy already present in each problem family, recompression substantially reduces storage for the low-rank blocks and speeds up subsequent multiplication. The tested products generally retain about the same accuracy. The paper demonstrates these effects for the two operations on their own, leaving open how ranks and errors behave through longer chains of hierarchical arithmetic.

Deep dive: Hierarchical Matrix Operations on GPUs: Matrix-Vector Multiplication and Compression

The paper shows how GPUs multiply hierarchical matrices by vectors and recompress them, with speed and accuracy tests on spatial covariances. · about 36 minutes to read

The problem and its context

Why a dense matrix can have a compact description

In spatial statistics, an observation at one location can have a non-zero covariance with an observation elsewhere. The covariance matrix therefore looks dense: a row can contain information about every location. Adding observations makes each row longer and adds rows at the same time. A program that stores every entry faces the cost of the full square array. Applying that array to a vector also requires accessing all its entries. The paper identifies similar difficulties in discretized integral equations, reduced systems from partial differential equations, and Hessians used in inverse problems and data assimilation.

Density describes the locations of non-zero entries. It says little about how much independent information those entries contain. A rectangular block can have values throughout it while its columns are well approximated by combinations of a small set of vectors. The size of that set is the approximation rank. Storing the vectors and their coefficients can use much less space than storing all the entries. The approximation is made over blocks, so it can use a large rectangle wherever the data support it and finer subdivisions where a single compact description would work poorly.

A hierarchy records those choices of scale. Start with groups that each cover a large set of rows or columns. Split them into smaller groups where finer detail is needed. The resulting partition can contain large low-rank blocks, small low-rank blocks, and small blocks kept in full. This mixture matters because a single global low-rank approximation would have to account for every part of the matrix with the same set of directions. The hierarchical format allows different groups and scales to have different bases, the collections of vectors from which the blocks are built.

The H² representation adds another way to save space. Many blocks use the same basis for a particular row or column group. In addition, a basis at a coarse scale can be expressed through the bases of its smaller groups. This property is called nestedness. It means that an implementation can store the bases explicitly at the finest scale and store small transfer matrices for moving between scales. Those transfers reduce storage and give algorithms a way to reuse work already done at another level of the tree.

The paper relates the storage requirement to matrix size and representative rank. Linear growth in the matrix dimension is possible when ranks and the number of interactions in each block row and column stay bounded as the problems grow. A useful workload can meet those conditions even though every entry of the underlying matrix matters. On a GPU, the immediate consequence is that a problem whose dense array exceeds device memory may fit in hierarchical form. Multiplication can then work with the resident representation without fetching blocks of a dense matrix from the host.

What earlier formats and implementations offered

The authors trace H and H² matrices to work by Hackbusch that generalized ideas from fast multipole methods. That line of research supplied ways to approximate integral operators and operators associated with elliptic partial differential equations. The paper also describes uses in integral-equation solvers, finite-element preconditioning, and related problems. Its starting point is an established mathematical representation. The implementation problem is how to organize its existing operations for a processor that depends on many pieces of work running at once.

Several of the formats discussed in the paper exploit low-rank blocks with different restrictions. Hierarchically semiseparable matrices use nested bases for a partition in which off-diagonal blocks have low rank. The authors connect that partition to weak admissibility, a rule about which blocks are eligible for approximation. They describe applications to integral equations in the plane and to certain matrices obtained from sparse systems on 2D grids. A hierarchically block-separable representation uses a related structure and emphasizes a factorization assembled across successive scales. The paper also discusses hierarchically off-diagonal low-rank matrices, whose separate, nonnested bases simplify the representation used in some fast factorizations.

H and H² allow a more general choice over where to stop subdividing blocks. A large block can be approximated at a coarse level wherever the geometry and the matrix support it. A difficult part of the matrix can be partitioned more finely, down to dense blocks at the finest level. H² combines this flexibility with nested bases. The result is well suited to the paper’s covariance examples, where the arrangement of coarse and fine blocks differs between spatial dimensions. The same flexibility leaves the implementation with an irregular pattern of interactions to process.

The authors report that CPU software for hierarchical matrices already existed and that a task-based implementation had been demonstrated on Intel Phi. Earlier GPU work had accelerated parts that were readily vectorized, such as forming an initial stiffness matrix. The paper also describes a parallel work-queue approach to H-matrix multiplication by a vector. The gap it identifies concerns efficient implementations of basic H² operations on GPUs, where the hierarchy introduces dependencies and the individual matrix operations are small.

Why the GPU changes the algorithm

In a recursive tree algorithm, a routine can descend into a child as soon as it encounters one. That arrangement makes the mathematical dependencies easy to express. On a GPU, turning each small operation into its own kernel launch can make scheduling expensive relative to the computation. A kernel is a routine launched on the device for a grid of threads. The paper puts the launch stall at as much as 10 microseconds. That time can be small beside a large computation and appreciable beside the multiplication of a single short matrix by a vector.

A tree level exposes many operations whose inputs are ready together. For instance, once all children have been evaluated, every parent at the next level can receive its children’s results. The positions and connections of the nodes can be irregular, yet those parents can still perform the same kind of small matrix operation. The authors build their implementation around this distinction. Level-by-level traversal handles dependency order, while batched linear algebra gives the GPU enough independent operations to run. This is the central connection to GPU & parallel computing.

A further difficulty is that levels differ in width. At the bottom there can be many leaves or small blocks, while near the root there are few. Large batches give the processor work to distribute among its execution units. A small batch near the root may leave some units idle, even though the work it performs is needed before the computation can continue. Flattening and batching address the overhead of issuing individual operations. The multiplication implementation also uses the independence of the dense portion to fill some of the time when the tree work leaves resources available.

The method, step by step

How the matrix is stored

The format organizes rows and columns separately. The basis tree named U groups rows and supplies vectors that give the column space of a block. The V tree groups columns and supplies vectors that give its row space. The terminology follows the factorization of the block: columns of U describe the block’s behavior over its row indices, while columns of V describe its behavior over its column indices. The paper uses binary basis trees. Row and column trees may differ in the general representation, and the symmetric covariances in the experiments share a tree.

Aᵢⱼ⁽ˡ⁾ ≈ Uᵢ⁽ˡ⁾ Sᵢⱼ⁽ˡ⁾ (Vⱼ⁽ˡ⁾)ᵀ

Here Aᵢⱼ⁽ˡ⁾ is a block of the underlying matrix with row group i and column group j at level l. The basis matrices are Uᵢ⁽ˡ⁾ and Vⱼ⁽ˡ⁾. The small matrix Sᵢⱼ⁽ˡ⁾ is the coupling matrix, whose entries specify how directions from the two bases interact. The superscript ᵀ means transpose. The approximation sign refers to representing the underlying block in low-rank form. Within the stored representation, the product on the right defines the block.

A block’s extent and the dimensions of its coupling matrix are different quantities. A coarse block covers many rows and columns, but its coupling matrix uses only the numbers of basis vectors retained for the two groups. At the finest level of the tree, the explicitly stored basis has dimensions m by k, where m denotes the size of the group and k its rank. Coarser bases are generally larger when written out. The implementation represents them through the children and a small transfer for each connection.

Uᵢ₊⁽ˡ⁻¹⁾ = diag(Uᵢ₁⁽ˡ⁾, Uᵢ₂⁽ˡ⁾) [Eᵢ₁⁽ˡ⁾; Eᵢ₂⁽ˡ⁾]

The index i₊ identifies the parent, at level l minus one. The indices i₁ and i₂ identify its two children at level l, and U is the row-group basis tree. The operator diag places the child bases on the diagonal of a block matrix with zeros elsewhere. The brackets stack the two transfer matrices E vertically, as indicated by the separator. Each E maps a parent coefficient vector into coordinates for its child. If the child and parent ranks are k꜀ and kₚ, the transfer has k꜀ rows and kₚ columns. The column-group tree V uses the same relationship with transfers named F.

The nesting formula gives a practical interpretation of a parent basis. Its restriction to each child’s rows lies in that child’s basis. To apply the parent basis to a coefficient vector, the algorithm can transform the vector with E and hand the result to the child. It can repeat this down the tree to where the actual basis vectors are stored. In the opposite direction, if the algorithm has already collected coordinates for the children, it can apply transposed transfers and add the results to obtain coordinates for the parent.

The coupling matrices occupy a separate tree named S. With binary row and column trees, subdividing a matrix block generates a quadtree structure. Each low-rank block is a leaf of that quadtree, including blocks whose approximation is accepted at a coarse level. Within a level, S looks like a sparse matrix of small blocks. A slot in that level contains a coupling matrix only when the partition stops there for that row and column pair. The leaves distributed across the levels together describe the full low-rank portion of the representation.

The remaining leaves are stored in full at the finest scale. They form a separate sparse matrix of dense blocks. Its sparse part is the index of occupied block positions. Its dense part is the data within each occupied position. In the examples the authors use m = 64 for the dense block size, with the choice tuned to the P100. Keeping this portion separate lets the implementation use a direct block-sparse multiplication for it while applying the multilevel procedure to the rest.

How the GPU sees a tree

The representation places each level’s data in contiguous memory. Matrix blocks are laid out consecutively and entries inside each block are stored column by column. Three index arrays describe the basis tree. An entry in head gives the first child of a node, next leads to a sibling, and parent leads back to the node above. A node index can thus identify the relevant basis, transfer, or temporary vector in the level arrays. The same indexing scheme serves computations whose intermediate quantities have the shape of the basis tree.

Before a batch runs, a small device kernel reads these indices and the dimensions for the level. It works out the memory address of each operand and the address where the result belongs. The authors call this preparation marshaling. The batch receives arrays of addresses and the dimensions of the operations it is to perform. Preparing those addresses leaves the matrix blocks in place. Some later arithmetic stages explicitly write temporary stacks or copy newly computed transfers into the representation, which is a separate part of the algorithms.

Flattening makes it possible for threads to read neighboring entries of the index and level arrays in a pattern that the device can serve efficiently. It also means that the routines implementing multiplication, QR factorization, and singular value decomposition need only solve ordinary small matrix problems. A dependency belongs in the traversal schedule and an address belongs in the marshaled batch. The linear algebra kernel can use the same interface whether its operands come from a leaf, an interior level, or a temporary array.

The batch routines use a common problem size within a launch. The implementation therefore uses one rank for all basis nodes at a given level, while ranks can differ between levels after compression. It can use existing batched multiplication routines, including routines from cuBLAS and MAGMA, and specialized batched QR and singular value decomposition routines. The authors treat support for varying operation sizes within a batch as future work. The constraint also affects the truncation procedure, which must reconcile different rank requests from different nodes on a level.

Multiplication through the hierarchy

For a single low-rank block, there is a natural order of operations. Apply the transpose of the column-group basis to the appropriate part of the input vector. The result is a short vector, which the coupling matrix transforms into coefficients for the output basis. The output basis turns those coefficients back into a vector over the block’s rows. Applying the full hierarchical matrix amounts to carrying out the same steps over all blocks, with work shared whenever multiple blocks use the same basis.

How the hierarchical matrix acts on a vector

The steps in order.

How the hierarchical matrix acts on a vectorStep 1: Project input segments onto the leaf bases1. Project input segments onto the leaf basesStep 2: Transfer input coefficients up the column tree2. Transfer input coefficients up the column treeStep 3: Apply coupling blocks at each level3. Apply coupling blocks at each levelStep 4: Transfer output coefficients down the row tree4. Transfer output coefficients down the row treeStep 5: Expand output coefficients at the leaves5. Expand output coefficients at the leavesStep 6: Add the dense block product6. Add the dense block product

The first stage is the upsweep. It starts at the leaves of V. Here the basis matrices exist explicitly, so a batch can multiply their transposes by corresponding segments of the input. Each result records how the input on that group interacts with the stored basis vectors. The group can participate in more than one low-rank interaction, and those interactions can share the result. The sweep then repeats the aggregation at each coarser level, using transfers to express what a parent basis would obtain from the full segment of the input.

x̂ⱼ⁽ˡ⁾ = (Vⱼ⁽ˡ⁾)ᵀ x(j)

The vector x is the input, and x(j) is the part associated with column group j. The matrix Vⱼ⁽ˡ⁾ is the basis for that group at level l, and ᵀ transposes it. The vector x̂ⱼ⁽ˡ⁾ holds the resulting coefficients. This expression defines those coefficients even for levels where V is available only through transfers.

x̂ⱼ₊⁽ˡ⁻¹⁾ = (Fⱼ₁⁽ˡ⁾)ᵀ x̂ⱼ₁⁽ˡ⁾ + (Fⱼ₂⁽ˡ⁾)ᵀ x̂ⱼ₂⁽ˡ⁾

The index j₊ labels the parent at level l minus one, and j₁ and j₂ label its children at level l. The two F matrices connect the parent basis to the children’s bases. Applying their transposes moves the child coefficients into the parent’s coordinates, where they can be added. This yields x̂ⱼ₊⁽ˡ⁻¹⁾ without explicitly constructing the parent’s basis.

In the binary implementation, marshaling groups work according to the child’s position under its parent. Each resulting batch applies the appropriate transfers and updates the parent vectors. The process advances when the coefficients at the next level are ready. The total number of dependency steps follows the height of the tree rather than the number of nodes. Near the leaves, a step may have enough independent work to occupy the GPU. Near the root, batches get smaller and overhead becomes more visible.

The next stage multiplies by the couplings. Each occupied block in S acts on the input coefficients belonging to its column group. For each block row, the algorithm adds the results of the interactions listed at that level. Some groups have more interactions than others, so the authors store the coupling indices in block sparse row format. This format records where the list for each block row begins and which column group each stored block uses. Those lists are built with the matrix and reused in subsequent products.

ŷᵢ⁽ˡ⁾ = Σⱼ∈ℬᵢ⁽ˡ⁾ Sᵢⱼ⁽ˡ⁾ x̂ⱼ⁽ˡ⁾

Here ŷᵢ⁽ˡ⁾ is the contribution to row group i from the low-rank blocks at level l. It is expressed in that group’s basis coordinates. The set ℬᵢ⁽ˡ⁾ contains the column-group indices j of the stored coupling blocks in this block row. The sum Σ adds each coupling Sᵢⱼ⁽ˡ⁾ applied to its input coefficients x̂ⱼ⁽ˡ⁾. With input coefficients ready, the coupling operations at different levels can be computed independently. Their outputs still need to be combined across levels.

That combination is the downsweep. A group receives contributions from couplings at its own level and from coarser blocks whose rows cover the group. The parent already holds the partial answer from the coarser scales when the sweep reaches it. Its transfer maps that answer into the child’s coordinate system. The child adds the incoming part to what its own couplings contributed. Advancing from the root towards the leaves makes the same procedure work for any chain of ancestors.

ŷᵢ⁽ˡ⁾ ← ŷᵢ⁽ˡ⁾ + Eᵢ⁽ˡ⁾ ŷᵢ₊⁽ˡ⁻¹⁾

The arrow indicates replacement of the child’s coefficient vector by the updated result. The index i identifies the child at level l, and i₊ its parent at level l minus one. The transfer Eᵢ⁽ˡ⁾ maps the parent vector ŷᵢ₊⁽ˡ⁻¹⁾ into the child coordinates. The ŷᵢ⁽ˡ⁾ on the right contains the contributions already assigned to that child. It acquires the coarser contributions on the left.

y(i) ← y(i) + Uᵢ⁽ᑫ⁾ ŷᵢ⁽ᑫ⁾

The symbol q denotes the finest level, and i identifies a leaf group there. The basis Uᵢ⁽ᑫ⁾ expands its completed coefficient vector ŷᵢ⁽ᑫ⁾ into ordinary vector entries. The arrow updates the segment y(i) of the output by adding that expansion to the dense contribution. At this point every level’s low-rank contribution is represented in the leaf vectors, so the algorithm only needs to apply explicitly stored output bases.

The dense product uses a separate block-sparse matrix-vector routine. The dense computation and the tree computation both read the input, and the tree stages hold their intermediate results in temporary workspace. They can therefore run in separate streams, GPU queues that can overlap when resources permit. The authors give the tree stream higher priority and let the lower-priority dense work use otherwise available execution resources. The final expansion waits until it can safely add to the dense result. The design needs a single synchronization between the streams at that point.

Compression starts with the blocks that share a basis

Compression has a different purpose from building a hierarchy from the original covariance kernel. Its input already contains basis and transfer matrices and a set of couplings. It seeks a more economical basis within that hierarchy. When operations add low-rank contributions to a block, its representation can grow even if many of the added directions carry similar information. The paper’s method takes the represented matrix as its starting point and uses the data from all relevant low-rank blocks to determine which directions to keep.

A block row here means the rows covered by a basis node, considered across the columns of the matrix. At the finest level, it may include several complete low-rank blocks from that level. It can also contain a piece of a larger block whose row extent includes the group. The paper illustrates this with a leaf block row containing 5 blocks stored at the leaf level, alongside pieces of blocks stored above it. Those inherited pieces matter because a direction absent from the leaf’s own couplings can still be needed by a coarser interaction.

Aᵢ⁽ᑫ⁾ = Uᵢ⁽ᑫ⁾ (Bᵢ⁽ᑫ⁾)ᵀ

The notation Aᵢ⁽ᑫ⁾ now refers to the low-rank portion of the entire block row associated with leaf i at the finest level q. The matrix Uᵢ⁽ᑫ⁾ is its original basis. The transpose of Bᵢ⁽ᑫ⁾ collects the coefficients of the separate matrix pieces in that basis, including the pieces inherited from above. The dense blocks keep their own storage and are excluded from this factorization.

A singular value decomposition, or SVD, identifies directions in order of the size of their contribution. Taking it directly on a full block row would make the calculations depend on a dimension spanning much of the original matrix. The authors instead use a QR factorization to isolate a much smaller factor. In a QR factorization, the columns of Q are orthonormal, meaning that they each have unit length and are mutually perpendicular, and R is triangular. The orthonormal factor preserves the lengths and inner products relevant to choosing new left basis vectors.

Aᵢ⁽ᑫ⁾ = Uᵢ⁽ᑫ⁾ (Rᵢ⁽ᑫ⁾)ᵀ (Qᵢ⁽ᑫ⁾)ᵀ

Here Qᵢ⁽ᑫ⁾ and Rᵢ⁽ᑫ⁾ come from factoring Bᵢ⁽ᑫ⁾ into Q times R. The index i is the leaf group and q is its level. Transposing the QR product reverses the order of its factors. Because Q has orthonormal columns, the small weighted basis formed by Uᵢ⁽ᑫ⁾ and the transpose of Rᵢ⁽ᑫ⁾ has the left singular directions required for the block row. The implementation obtains R through a tree traversal that avoids constructing the full B.

First sweep upward to orthogonalize

The method first makes the nested bases orthonormal so that subsequent QR factorizations can work on small coefficient stacks. At a leaf, a batch factors the stored basis by QR. The Q factor becomes the new basis and R records how to express the old basis in it. The latter is stored in a tree of basis transformations denoted T. The rest of the matrix can retain its meaning through this change of coordinates as long as the couplings are transformed as well.

Vⱼ⁽ˡ⁾ = Qⱼ⁽ˡ⁾ Tⱼ⁽ˡ⁾

The matrix Vⱼ⁽ˡ⁾ is the original basis for column group j at level l. The matrix Qⱼ⁽ˡ⁾ is its new orthonormal basis, and Tⱼ⁽ˡ⁾ translates the old basis vectors into the new coordinates. For a leaf T comes directly from QR. For an internal node the algorithm computes T using the already processed children and the transfers that originally linked them to the parent.

(Vⱼ⁽ˡ⁾)ᵀ Vⱼ⁽ˡ⁾ = I

In this condition Vⱼ⁽ˡ⁾ denotes a basis after orthogonalization, at node j and level l. The symbol I is the identity matrix of the basis rank, and ᵀ denotes transpose. The equation says that inner products of different basis columns vanish and that each column has unit length. For an inner node, the same condition follows if the children’s bases are orthonormal and the vertically stacked transfers have orthonormal columns.

At an internal node, each old transfer must first be expressed in the new child coordinates. The implementation multiplies each original transfer by the child’s T matrix. Stacking the resulting matrices creates a compact description of the parent in the orthonormal bases of its children. A QR factorization of that stack makes the parent orthonormal. Its Q factor has one row group for each child, and those groups become new transfers. Its triangular factor goes into T at the parent for use in the next upsweep step.

Z = [Tⱼ₁⁽ˡ⁾ Fⱼ₁⁽ˡ⁾; Tⱼ₂⁽ˡ⁾ Fⱼ₂⁽ˡ⁾]

The array Z is the stack submitted to QR for the parent at level l minus one. The indices j₁ and j₂ denote its children at level l. Each T maps the corresponding old child basis into its orthonormal basis, and each F is that child’s original transfer. The separator indicates vertical stacking. The two products can be prepared through batched matrix multiplication. After the factorization, a batched copy places the appropriate pieces of its orthonormal factor back in the transfer arrays.

The coupling update is independent for each low-rank block. Multiplication on the left changes its row-group coordinates and multiplication on the right changes its column-group coordinates. This step is algebraically a change of basis. The actual rank reduction begins later. Because the spatial covariance examples are symmetric, the paper describes much of the work with a shared basis tree. When the bases differ, each side has its own transformations.

S̃ᵢⱼ⁽ˡ⁾ = Tᵤ,ᵢ⁽ˡ⁾ Sᵢⱼ⁽ˡ⁾ (Tᵥ,ⱼ⁽ˡ⁾)ᵀ

Here S̃ᵢⱼ⁽ˡ⁾ is the coupling for row group i and column group j at level l after a basis update. Sᵢⱼ⁽ˡ⁾ is the coupling before it. The matrices Tᵤ,ᵢ⁽ˡ⁾ and Tᵥ,ⱼ⁽ˡ⁾ act on the row and column sides respectively. In orthogonalization they express the old basis in new coordinates. The compression procedure later uses the same form with projections onto the retained bases. The GPU marshals the two products for each block and stores an intermediate product in temporary workspace.

Then sweep downward to collect the weighting factors

Once the bases are orthonormal, the algorithm computes a small triangular factor for every block row. At a given node, couplings at that level describe the local interactions. The triangular factor from the parent summarizes the interactions from coarser scales. The old parent basis restricted to the child’s rows can already be described by the child basis and a transfer. Multiplying the parent factor by the transposed transfer therefore converts the inherited information into a form that can be stacked with the local couplings.

S̄ᵢ⁽ˡ⁾ = [Rᵢ₊⁽ˡ⁻¹⁾ (Eᵢ⁽ˡ⁾)ᵀ; (Sᵢⱼ₁⁽ˡ⁾)ᵀ; …; (Sᵢⱼᵦ⁽ˡ⁾)ᵀ]

The matrix S̄ᵢ⁽ˡ⁾ is the stack for row group i at level l. The index i₊ denotes its parent at level l minus one, with triangular weight Rᵢ₊⁽ˡ⁻¹⁾. The transfer Eᵢ⁽ˡ⁾ describes the parent basis on the child’s rows. The indices j₁ through jᵦ identify the b occupied block columns of group i at level l. Each S is their corresponding coupling after orthogonalization. The transposes put the pieces in the orientation required for QR, and the separators indicate a vertical stack. The ellipsis covers the other stored couplings for that group.

The QR factorization of the full block row’s coefficient matrix would also contain the outer basis vectors from the column groups and the orthonormal part of the inherited QR factorization. The paper’s derivation groups those factors into a block-diagonal matrix. Its columns are orthonormal. Multiplication by that matrix preserves the inner products of the columns of the small stack, so the triangular information can be obtained from the stack alone. This is the algebraic step that avoids revisiting the full set of columns for every row group.

The calculation starts at the root, where there is no inherited information, and proceeds towards the leaves. Each level uses the block sparse row indices to locate couplings and the parent index to look up the appropriate R. The GPU builds the inherited terms with batched matrix multiplication and places transposed couplings in the stacks. The QR kernel for this phase returns the triangular factors without producing Q. That choice saves arithmetic and storage because the next tree step and the truncation procedure use the triangular factors.

Finally sweep upward to truncate the bases

At a leaf, multiplication by the triangular weight creates a small weighted basis. Its SVD measures the importance of the leaf directions for the matrix data represented there. Which directions the procedure keeps depends on a cutoff set relative to the largest singular value. The new basis is formed from the retained left singular vectors. The GPU can determine a requested rank for each leaf, then reduce those requests to the maximum for the level. The common rank allows the implementation to keep using fixed-size batches.

Wᵢ⁽ᑫ⁾ = Uᵢ⁽ᑫ⁾ (Rᵢ⁽ᑫ⁾)ᵀ

Here Wᵢ⁽ᑫ⁾ is the weighted basis for leaf group i at the finest level q. The matrix Uᵢ⁽ᑫ⁾ is its orthonormal basis before truncation, and Rᵢ⁽ᑫ⁾ is the triangular factor from the downward sweep. The transpose follows from factoring the transposed coefficients in the expression for the block row. The tolerance, denoted ε in the algorithm, is relative to the largest singular value of the weighted problem. It controls the local directions considered for retention.

An interior node uses the same idea after accounting for the directions already discarded below it. The old parent transfers are mapped through the projections for the processed children and stacked. This places the parent’s basis in the retained child spaces. Applying its weight and taking an SVD of the resulting small matrix selects the directions to preserve there. The corresponding left singular vectors are divided into pieces that become new transfers. Constructing the transfers in those child spaces preserves nestedness in the compressed tree.

Tᵢ⁽ᑫ⁾ = (Qᵢ⁽ᑫ⁾)ᵀ Uᵢ⁽ᑫ⁾

In this step Qᵢ⁽ᑫ⁾ denotes the retained left singular vectors at leaf i and level q. It is the compact basis output by truncation. The matrix Uᵢ⁽ᑫ⁾ denotes the basis entering truncation, and Tᵢ⁽ᑫ⁾ expresses its projection onto the compact basis. At an interior node, the analogous projection uses the stacked transfers expressed in the compact child coordinates. These projection matrices are the ones used in the final coupling update.

The last pass applies the coupling transformation to all stored low-rank blocks. The positions of those blocks and of the dense leaves carry over. The compact bases and smaller couplings reduce how much low-rank data subsequent operations read and process. There is a practical difference between this pass and the earlier orthogonalizing update. Both perform two matrix multiplications per coupling, but the earlier pass represents a change of coordinates and the last one incorporates the effect of discarding directions.

How the initial matrices are generated

The experiments start from an analytical covariance kernel evaluated for observations on randomly perturbed grids. The authors partition the points into clusters with a k-d tree. A mean split divides a group and yields the index sets used for the basis tree. Chebyshev interpolation provides the initial bases and transfers. An interpolation grid supplies representative locations at which the kernel can be evaluated, so that a block can be described by those values and the interpolation bases.

A traversal over pairs of clusters constructs the matrix block tree and determines which interactions are represented at each level. When a block is stored in low-rank form, its initial coupling comes from evaluating the covariance kernel at interpolation points. This procedure builds the hierarchy directly. The dense covariance is needed conceptually as a reference, with entries available from the same kernel. Recompression then starts with the generic interpolation bases and uses their couplings to adapt those bases to the represented matrix.

Experiments and results

Covariance families and comparison conditions

The authors generate 2D and 3D covariance families for a spatial Gaussian process. The problem sizes span 2¹⁴ through 2²⁰ observation points. The points lie on randomly perturbed regular grids in [0, 1]² and [0, 1]³ respectively. Both families use an isotropic exponential kernel, which means that the covariance depends on separation distance without a preferred direction. The correlation length is 0.1 in the 2D family and 0.2 in the 3D family. The two families therefore present different geometries and kernel settings to the same implementation.

The initial rank is 64 at every level. The authors use 8 × 8 Chebyshev grids in 2D and 4 × 4 × 4 grids in 3D to obtain those bases. The dense leaf size is 64 in both cases. The matching values of rank and leaf size are compatible with the paper’s interest in recompression. A compact representation can temporarily carry large ranks during arithmetic, and a generic interpolation construction can start with more directions than the matrix eventually needs. The basis generation and truncation stages test how much of that representation can be reduced.

The block patterns help explain the difference between these families. At the illustrated size 2¹⁴, the 3D covariance has more dense blocks and fewer opportunities to represent large blocks at coarse scales. More interactions persist to finer levels, where they occupy more blocks. That raises memory demand. It also changes the mix of work for multiplication and compression. The paper reports the two families separately so that their timing and error results can be interpreted against their respective structures.

The GPU multiplication measurements include single and double precision. The comparisons include the same algorithm with and without overlapping its dense and low-rank work, and implementations that use different underlying batched matrix-vector and block-sparse kernels. For the latter comparison, the paper contrasts optimized kernels with routines from cuBLAS and cuSPARSE. These are comparisons within the hierarchical algorithm. The exact dense covariance is used as a numerical reference in the accuracy checks rather than as the primary timing baseline for large sizes.

Matrix-vector multiplication

The runtime curves on the P100 show roughly linear growth as matrix dimension increases over the tested sizes. The authors see this behavior across the versions they compare. For the large 3D covariance, the conclusion reports that multiplying the hierarchical representation by a vector takes under 29 ms for a problem with over a million observations. The authors also report more than 550 GB/s for the bandwidth-limited operation and say the achieved rate exceeds their STREAM benchmark. The streamed implementation reaches up to 78% of the P100’s theoretical peak memory bandwidth.

The reported bandwidth is an effective rate. The authors divide the bytes attributed to the represented matrix by the total elapsed time. The count includes the dense leaves, low-rank couplings, leaf bases, and transfer matrices. It therefore gives a measure of how fast the entire operation consumes the representation, including the cost of organizing the traversals. It is distinct from a device measurement that directly counts every read and write, including transactions for address tables and intermediate vectors.

The streamed variant improves performance by up to 27% for smaller problems. For larger problems its advantage recedes. The paper attributes this to the larger batches near the bottom of the trees, which already put the GPU’s available bandwidth to work. The largest acceleration from streaming should therefore be read in light of the small problems where the original schedule leaves more resources available. The peak effective bandwidth describes a different regime and answers a different question about the implementation.

Using optimized batched matrix-vector products and block-sparse kernels improves performance over the versions using the vendor routines. The comparison holds the hierarchical computation fixed while changing the kernels doing much of its work. It locates some of the advantage in the underlying operations, in addition to the layout and the traversal schedule. The authors describe performance across runs as stable. The runtime and bandwidth curves supply most of the evidence for these comparisons, while the prose gives headline values for the strongest observations.

Compression time and the work it saves

The authors apply algebraic compression to both covariance families, using the initial Chebyshev representation as the starting point. The conclusion reports under 1.7 s for compression of the million-sized 3D example, describing throughput as almost 850 GFLOPS/s. The abstract reports over 850 GFLOPS/s for sustained compression performance on the P100. For individual stages, the conclusion reports more than 2,000 GFLOPS/s for basis orthogonalization and rates over 600 GFLOPS for basis generation and truncation. The stage rates and the overall rate describe different amounts of work over different elapsed times.

For compression, the stated throughput uses the operation counts of the batched kernels and their execution time as part of the overall procedure. QR and SVD perform considerably more arithmetic on each local matrix than a matrix-vector multiply does. The paper treats compression as compute-bound and uses floating-point throughput to describe it. Its plots also show approximately linear runtime growth for both covariance families under the settings tested. The authors report that orthogonalization accounts for 10–15% of total compression time, with basis generation and truncation taking the larger shares.

After compression, the authors measure the low-rank representation’s memory use and the elapsed time of hierarchical multiplication again. The figures show substantial savings in storage for the low-rank portion and faster application of the matrix in both spatial dimensions. The initial construction and the compressed result share a block partition. The differences in these comparisons come from the basis, transfer, and coupling data stored for low-rank blocks. The dense blocks continue to contribute to both the memory footprint and the product.

Accuracy before and after compression

The experiments answer two accuracy questions. One is how far compression moves the hierarchical matrix from the representation it receives. The other is how well each hierarchical matrix approximates the action of the original covariance on a test vector. A matrix-level error can increase even while a particular product changes little, since that product only probes the directions present in its input. Reporting both quantities helps distinguish the effect of compression from the interpolation error already in the input.

δ = ‖A₂ᴴ − A₁ᴴ‖ꜰ / ‖A₁ᴴ‖ꜰ

The quantity δ is the relative change in the hierarchical matrix under compression. A₁ᴴ is the initial covariance approximation built with Chebyshev bases and A₂ᴴ is the recompressed version. The bars marked F denote the Frobenius norm, which measures the square root of the sum of squared entries. The denominator measures the size of the initial hierarchical matrix, so δ compares the compression change with the scale of the representation being compressed.

η = ‖Ax − Aᴴx‖₂ / ‖Ax‖₂

The quantity η is the relative error in a test product. The matrix A is the analytical covariance, Aᴴ is whichever hierarchical representation is under test, and x is a random vector with entries sampled uniformly from [0, 1]. The bars marked ₂ are the Euclidean norm of the vector. The denominator uses the reference product Ax. For larger problems, the authors use analytical entries to evaluate the comparison on 10% of the rows. In the compression tests they describe randomly sampling those rows and scaling the resulting error.

The accuracy tables cover problem sizes from 2¹⁴ through 2¹⁹. The truncation threshold is 10⁻⁷ for the 2D family and 10⁻³ for the 3D family. The authors choose these thresholds with the initial interpolation errors in mind. This sets up a comparison at roughly the accuracy of the original representation. It also means the memory savings and runtime gains are specific to settings where there is room to choose more efficient bases without demanding a different level of accuracy from the matrix.

At size 2¹⁹, the 2D family has a relative Frobenius change of 2.19 × 10⁻⁷ after recompression. Its relative product error is 3.52 × 10⁻⁷ before compression and 3.48 × 10⁻⁷ afterward. The chart shows the latter comparison on the scale used in the error table. These are errors against the same analytical covariance at the same problem size, with the matrix-vector product providing the test.

Relative matrix-vector error before and after compression, 2D covariance at size 2¹⁹

Recompression leaves the tested product error close to its original value.

Relative matrix-vector error before and after compression, 2D covariance at size 2¹⁹Initial Chebyshev representation: 3.52Initial Chebyshev representation3.52Algebraically recompressed representation (this paper): 3.48Algebraically recompressedrepresentation (this paper)3.48
The numbers
System or settingrelative 2-norm error (× 10⁻⁷)
Initial Chebyshev representation3.52
Algebraically recompressed representation (this paper)3.48

At size 2¹⁹ in the 3D family, the relative Frobenius change is 2.83 × 10⁻³. Its product error is 9.76 × 10⁻⁴ before recompression and 9.68 × 10⁻⁴ after it. This dataset has a larger initial product error than the 2D family, and the perturbation introduced by truncation should be interpreted in the context of that starting accuracy and its own chosen threshold.

Relative matrix-vector error before and after compression, 3D covariance at size 2¹⁹

The tested product retains approximately the same accuracy with the smaller representation.

Relative matrix-vector error before and after compression, 3D covariance at size 2¹⁹Initial Chebyshev representation: 9.76Initial Chebyshev representation9.76Algebraically recompressed representation (this paper): 9.68Algebraically recompressedrepresentation (this paper)9.68
The numbers
System or settingrelative 2-norm error (× 10⁻⁴)
Initial Chebyshev representation9.76
Algebraically recompressed representation (this paper)9.68

The small decreases at 2¹⁹ are particular observations, instead of a consistent improvement in the covariance approximation. In 2D at size 2¹⁷, for instance, the product error moves from 3.50 × 10⁻⁷ to 3.58 × 10⁻⁷. At size 2¹⁵ in 3D it moves from 9.49 × 10⁻⁴ to 1.03 × 10⁻³. The authors’ interpretation is that the chosen thresholds generally preserve the scale of the original error. The gain they seek is a smaller representation with faster operations at that level of accuracy.

The paper’s initial multiplication discussion and its compression tables describe the 2D product error differently. The multiplication discussion says that the interpolated representation has an error below 10⁻⁷ across sizes. The compression table lists precompression 2D product errors such as 3.33 × 10⁻⁷ at size 2¹⁴. The tabulated values are the ones for the paired comparisons in the compression experiment. The distinction matters when reporting the magnitude of the error. It does not change what those pairs show about precompression and postcompression products within that experiment.

The Frobenius changes are on the scale of the chosen thresholds, with some values larger than the threshold itself. The authors obtain this error measure during truncation, so evaluating the change does not require another pass over a dense covariance matrix. That is practical when compression is one operation within a larger computation and accuracy needs to be checked along the way. It also gives a measure on the representation itself, whereas comparison to the exact covariance is possible in these experiments because its entries can be evaluated from the kernel.

What the ablations show

Overlap helps when the tree leaves resources idle

The streamed and nonstreamed variants keep the matrix, the hierarchical algorithm, and the mathematical product fixed. The change is the scheduling of the dense and low-rank portions. The phase breakdown shows that for small 3D examples the sweeps take a relatively large share of the time. Small upper-level batches leave execution resources available. Scheduling dense work on another stream can occupy some of those resources while the tree phases run, which is consistent with the timing advantage of the streamed variant.

As matrix size increases, more work occurs at the broad lower levels. For that part of the computation, the low-rank data already draw heavily on the same memory bandwidth that the dense multiplication needs. The difference between the streamed and the nonstreamed curves narrows. This comparison explains where the scheduling change pays off. It does so without changing the rank, the representation, or which couplings contribute to the result. It also shows why better utilization near the root can matter little to the total runtime of a much larger problem.

The authors discuss which stages make practical sense to overlap. Launching a new kernel depends on available device resources. A block-sparse multiplication kernel may hold those resources until it approaches completion. The separate dense product provides a place to use priorities without adding more data dependencies inside the tree traversals. The result is an implementation whose benefit depends both on the geometry of the workload and on whether the schedule creates opportunities for simultaneous execution.

The phase profiles locate the expensive operations

A second comparison changes the standard small-matrix kernels while preserving the hierarchical traversal. The optimized matrix-vector and block-sparse versions are faster than the versions built on the vendor routines. This helps distinguish two contributors to runtime. The tree layout makes it possible to issue batches and manage dependencies. The kernels must still make good use of the GPU on the dimensions these batches supply. Flattening can expose the available parallel work while leaving room to improve how the hardware performs each local operation.

The paper examines the same issue inside orthogonalization. At larger sizes, coupling projection takes the dominant share of orthogonalization time. That step uses batched matrix-matrix multiplication on small operands. The authors observe that the cuBLAS routine they use runs at fairly similar speeds in single and double precision at those sizes. As a consequence, the orthogonalization timings for the two precisions are closer than the authors expected. The phase profile identifies the relevant kernel and workload, so a comparison of total time by precision can be read in context.

The full compression profile has a different balance. Generating the weights factors stacks of couplings and inherited data by QR. Truncating the bases factors weighted matrices by SVD. Those phases account for much of the full runtime, and their more costly factorizations explain why projection can dominate orthogonalization while taking a smaller share of the whole compression procedure. This is a profile of the implemented algorithm at the tested ranks. It gives a more specific account of the bottleneck than the aggregate floating-point rate alone.

Recompression isolates the value of adapting the bases

The comparison before and after algebraic compression starts from the same covariance and keeps the same hierarchical partition. The dense leaves are retained, and the changed part is the low-rank representation. Paired memory and timing measurements therefore show what can be gained by replacing the generic interpolation bases and their associated coupling dimensions. The product error checks establish the accuracy conditions under which those savings were observed.

The 2D and 3D examples are informative for a related reason. If a matrix has more interactions at fine scales and more dense blocks, rearranging the low-rank representation acts on a different portion of its total memory and runtime. This comparison includes changes in geometry, correlation length, and tolerance, so it does not isolate any one of those factors. What the paired comparisons show within each family is that there was redundancy to remove even though the starting covariance had already been constructed in H² form.

These experiments supply controlled implementation comparisons and phase analyses rather than a complete component-removal study. For instance, the paper explains why weighting needs interactions inherited from coarser blocks, but gives no accuracy comparison against a compression variant that omits them. The nested-basis derivation explains how the method avoids factoring full block rows. The measurements show how its actual costs divide among traversals, projections, and factorizations. Those two kinds of evidence answer different questions about the method.

Limitations

Limits identified by the authors

The authors identify fixed-size batches as a constraint of the implementation. All nodes on a level use the same rank. During compression this means retaining enough directions for the node with the highest rank requirement and using that rank for the other nodes on the level. The procedure can still reduce the ranks across levels, but a level containing both easy and difficult blocks can carry extra directions for some nodes. The paper leaves variable-size batch operations to future work.

The authors also identify the limited amount of work near the roots of the trees. Batching lowers launch costs, yet a level with few nodes has few operations to offer. Stream overlap helps in the conditions shown by the benchmarks and depends on whether execution resources are free. The placement of the dense product in a separate stream provides one opportunity for overlap. A different mix of work between the dense and low-rank portions changes how much benefit is available.

The paper treats these routines as building blocks for hierarchical matrix arithmetic and calls attention to the numerical questions that arise when operations are chained. Rank can grow during arithmetic, and each recompression introduces a change whose effect can propagate through later operations. The tests measure one compression from an analytic-kernel construction and the product error of the resulting matrix. The authors leave full operations such as hierarchical matrix-matrix multiplication and inversion to future work, together with broader application experiments.

Limits of the experimental setup

The performance results characterize a Pascal P100 and two synthetic covariance families. The representation allows other block patterns and distinct row and column bases, while the measured examples are symmetric and use the same tree on both sides. The chosen dense leaf size is tuned to the device. The timings therefore establish the performance of the method for those layouts, ranks, and kernels. They give no direct measurement for nonsymmetric problems, other GPU architectures, or cases where matrices are too large to keep resident on the device.

Linear storage and work are properties of the hierarchical representation under its structural assumptions. The cost depends on the ranks and on how many interactions a level stores for its groups. A covariance family requiring increasing ranks to maintain accuracy, or many additional interactions as its size grows, can consume more resources than the cases benchmarked here. The observed runtime trends establish that the tested rank choices and patterns support linear scaling over the sizes reported. They leave scaling at substantially different ranks and accuracy requirements open.

The numerical tests have boundaries of their own. The vector-product error uses a random input drawn from a specified distribution. For the larger sizes it evaluates the product comparison on sampled rows. This measures typical behavior in that test and gives a practical way to compare against an analytical covariance without storing it. The setup does not estimate the largest relative error over possible input directions. The Frobenius change measures a matrix perturbation from recompression, with the existing hierarchical approximation as its reference.

The tolerance acts locally on singular values and the actual truncation ranks are made uniform by level. The accuracy tables show errors on the scale of the chosen tolerances. Treating the tolerance as a strict bound on the global relative product error would go beyond the experiment. The limited changes in the tested products likewise leave open the behavior of other quantities, such as the accuracy of a solve that repeatedly applies or recompresses hierarchical matrices. Such a solve can depend on directions that a random product samples weakly.

Finally, the multiplication and compression timings are for operations applied to matrices already in hierarchical form. Matrix construction uses the analytical covariance and is described as part of the data procedure. The reported speed of a product or recompression does not establish the end-to-end cost of obtaining that representation for another application. In a workflow that applies the same matrix repeatedly, the construction and compression costs are incurred differently from the cost of each multiplication. The paper reports the parts separately, leaving that workload-level comparison to the application.

What came after

The authors identify hierarchical matrix-matrix multiplication and inversion on GPUs as the next operations they intended to pursue. In the proposed arithmetic, a product or another block update can introduce more basis directions, after which recompression can reduce the representation again. That makes the compression stage relevant to the cost of an entire sequence of operations. The paper records this direction as planned work and leaves the performance and numerical behavior of those larger operations as open questions.

Cite

Cite as Wajih Halim Boukaram, George Turkiyyah and David E. Keyes. 2019. Hierarchical Matrix Operations on GPUs: Matrix-Vector Multiplication and Compression. arXiv:1902.01829.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.1902.01829 · arXiv 1902.01829

@misc{boukaram2019hierarchical,
  title = {{Hierarchical Matrix Operations on GPUs: Matrix-Vector Multiplication and Compression}},
  author = {Wajih Halim Boukaram, George Turkiyyah and David E. Keyes},
  year = {2019},
  doi = {10.48550/arxiv.1902.01829},
  eprint = {1902.01829},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1902.01829}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/boukaram-2019-hierarchical-matrix-operations-gpus-matrix/