Elamur Research

Accelerating Sparse Matrix Operations in Neural Networks on Graphics Processing Units

Paper · 2019 · Arturo Argueta and David Chiang

Summary

A neural network can spend time on entries that its next step will never use. At the input, a word and its features may activate only a handful of positions in a very wide vector. At the output, a translation decoder may score a whole vocabulary and then keep only a small set of candidates. Argueta and Chiang develop GPU routines for these situations. Their first routine computes a dense representation by visiting only the active input features. Their second computes the normalization needed for output probabilities while keeping track of the candidates that beam search will carry forward. The paper studies these operations as problems in GPU and parallel computing.

The input routine generalizes an ordinary embedding lookup. With a single active feature, a lookup returns its row from an embedding matrix. With several active features, the required output combines several rows. The authors store the active features by input row and assign GPU threads to output entries, so each thread accumulates the contributions it needs. The output routine uses the fact that softmax preserves the ordering of scores within an example. Threads can select candidates using their original scores while computing the quantities needed to normalize them. The routine returns the probabilities and original vocabulary indices of the selected candidates.

The benchmarks time operations on randomly generated inputs on a Tesla V100 and a TITAN X. The authors report headline speedups of up to 7× for sparse input multiplication and 50× for fused softmax and selection against parallel GPU baselines. The lookup has its strongest advantage when very few features are active. The output routine is most competitive when the decoder keeps a short list, and its performance changes with both batch size and GPU architecture. The experiments establish speedups for the measured operations. They leave open how much time a complete machine translation system would save.

Deep dive: Accelerating Sparse Matrix Operations in Neural Networks on Graphics Processing Units

Argueta and Chiang speed up sparse input lookups and combine softmax with top-N selection on GPUs for faster beam-search decoding. · about 31 minutes to read

The problem and its context

The cost of representing words and choosing continuations

A vocabulary gives a network a fixed set of positions from which to identify words. When a word is represented by a one-hot vector, the position associated with that word is active and the rest are zero. The vector can be as wide as the vocabulary even though its useful content is an index. Multiplying it by an embedding matrix produces the same result as reading the row associated with that index. The lookup is valuable precisely because the identity of the active position is already known.

An application may want the input to carry more than word identity. The examples in the paper include sub-word information and part-of-speech tags. The active positions now select several rows of the same matrix, each of which contributes to the output. The operation still has a simple structure. Entries outside the active positions multiply their corresponding rows by zero, so those rows do not contribute. But a direct lookup of a single row can no longer produce the complete result.

The authors point to two existing ways to handle related computations. Toolkits such as DyNet and Caffe provide specialized operations for ordinary embedding lookups. A general sparse matrix library can express the operation for several active features. The question is whether an implementation designed for a very short list of active positions can exploit that case more directly than a routine that handles a range of sparse inputs.

At the output, the network produces logits, the scores from which softmax computes a categorical distribution over possible next words. In beam search, a hypothesis is a partial output sequence. The decoder keeps a limited set of hypotheses at each timestep, expands them with possible continuations, and carries forward the strongest candidates. The paper describes this use of search in the context of earlier work including Sequence Transduction with Recurrent Neural Networks and Sequence to Sequence Learning.

A simple implementation performs softmax over the scores and then sorts the resulting probabilities. It takes the desired number of entries from the sorted list and also needs the vocabulary index for each entry it takes. An implementation that follows these operations literally spends work producing a complete array of probabilities and arranging entries that are about to be discarded. The interface to the next search step asks for the selected probabilities and their identities. It has no use for the order of rejected candidates, and it does not require the selected candidates to be returned in a particular order.

The authors motivate the output optimization using earlier measurements of a translation implementation. Hoang and colleagues attributed 5% of total decoding time to softmax and reported that selection could take up to 36.8%. These are figures from the earlier system, with total decoding time as the denominator. They explain the interest in selection as a target in its own right. The time spent choosing entries can matter even if the computation that assigns a probability to each entry has already received attention.

Earlier routes to faster execution

The paper describes earlier approaches that skipped normalization or approximated the softmax computation. It associates the first strategy with earlier work on neural network joint scoring for statistical translation and the second with work including Efficient softmax approximation for GPUs. It also points to GPU beam-search work that used hashing to avoid a complete sort. These approaches address expensive parts of the same decoding process, although the operations they change are different.

Fusion was already part of the field's response. The paper cites Hoang and colleagues and Online normalizer calculation for softmax as recent work combining normalization and selection in GPU execution. Argueta and Chiang change the mechanism used to select candidates and design it for the small retained lists common in translation. They characterize the existing GPU selection pattern in terms of tree-based reductions. A reduction combines values from many threads into fewer results. It can serve as a building block for finding or ordering candidates, but the relative cost of that machinery depends on how much of the output must be retained.

The paper situates both proposals within a broader tradeoff in neural-network software. A toolkit such as TensorFlow offers abstractions that let users run computations across GPU platforms without designing each operation for a particular device. Work such as cuDNN supplies efficient primitives for common operations. The authors focus on cases where the application can promise more about the work than a general interface normally assumes. For the lookup, the promise concerns the number of active entries. For selection, it concerns the size of the result.

The input and output are sparse in different senses. At the input, the inactive coefficients really are zero, and the active indices tell the routine which embedding entries to read. At the output, a rejected score can still contribute to the probability assigned to a retained candidate. The sparsity lies in the result that must be kept. That distinction fixes the scope of the two optimizations. The input routine can avoid processing inactive coefficients. The output routine can avoid constructing a full probability array, while still accounting for the full set of scores in the normalizer.

Why the GPU layout matters

The paper uses CUDA's organization of parallel work to explain why knowing the sizes of these operations is useful. A kernel is a function launched on the GPU by the host processor. Threads in a kernel are grouped into blocks. Each block is assigned to a streaming multiprocessor, or SM, and threads in a block can cooperate through shared memory. CUDA schedules threads in groups called warps, which the paper describes as groups of 32. The number of blocks available and the resources each block needs determine how the work can be distributed across the device.

The authors distinguish registers, shared memory and global memory. Registers hold values private to a thread, such as a running result. Shared memory is accessible to threads in the same block and gives them a place to cooperate, for instance by keeping common intermediate values. Global memory holds the larger arrays. Its capacity allows it to serve the entire computation, but frequent accesses are costly in the authors' account. A small intermediate result is especially useful when it fits in shared memory and can be reused without repeated traffic to global memory.

There is also a difference between having many independent jobs and having many threads update the same value. The lookup offers independent jobs because separate output entries can be accumulated separately. The selection routine has a shared result for each example. Several threads can have a candidate for the same slot at the same time, so the algorithm needs a rule for coordinating updates. The authors use atomic operations, which make the read, comparison and update of a location happen as an indivisible transaction. The selection algorithm is designed around what such a transaction can do to a candidate and its index together.

The method, step by step

From a list of active features to a dense result

The input calculation starts with a minibatch of words or feature vectors and a dense matrix of embeddings. An embedding is a vector of learned values associated with a word or feature. In the simplest input, choosing a word chooses a row from this matrix. In the more general version, the input names several active positions. Each position names a row too, and the value at that input position determines the weight with which the row contributes. For a few-hot vector with unit active coefficients, the result is the sum of the indicated rows.

The paper writes the minibatch operation as a matrix product.

C = AB

Here A is the sparse input matrix, B is the dense embedding matrix, and C is the dense output matrix. Juxtaposition means matrix multiplication. The paper uses L for the number of examples in the minibatch, K for the input width, and M for the number of columns in B. Thus A has shape L × K, B has shape K × M, and C has shape L × M. A row of C contains the representation of one example. The dimensions K and M have different jobs. K determines how many possible embedding rows can be requested, and M determines how many values will be written for each result.

Consider the computation from the perspective of a single output value. Its row tells the algorithm which example to read. Its column tells the algorithm which component of each selected embedding to read. The thread assigned to that value works through the active features of the example, reading the same component from each relevant embedding row and accumulating the weighted contributions. Other threads can compute other components of the same result or work on other examples. No thread is assigned to carry out a multiplication solely because an inactive position lies between two active ones.

This layout still writes a dense output. Sparsity in the input tells the routine which terms to visit, while each selected row of B can contribute across the full embedding width. The authors use a row-major layout for B, meaning that adjacent components of an embedding row occupy consecutive positions. Output threads assigned to neighboring components of an example therefore have corresponding neighboring entries to read when they consult the same active feature.

Finding the active positions

The representation of A is compressed sparse row, or CSR. It has a list of stored values, a parallel list of their column indices, and a row pointer list. The value list and the column list run through the active entries in row order. The row pointer separates these lists into consecutive ranges, with the start of the next range also serving as the end of the current range. A thread can find the entries for its example from the pointers without scanning the examples that precede it.

Aᵣ[ℓ + 1] − Aᵣ[ℓ]

This expression gives the number of stored entries for row ℓ. Aᵣ is the row pointer list, square brackets access a list position, and ℓ + 1 denotes the next row pointer. Subtraction gives the length of the range between the pointers. The same starting pointer Aᵣ[ℓ] locates the first entry in A꜀, the list of active column indices, and Aᵥ, the corresponding list of values. The range ends before the position at Aᵣ[ℓ + 1]. To use that rule on the final row, the end pointer must be available as well.

The example in the paper's CSR illustration gives the second row a range length of 2. It locates the range using Aᵣ[2] and Aᵣ[3], with the row's entries stored at positions 4 and 5 of the parallel lists. The position in a sparse list and the original column of A are separate coordinates. A position tells the thread where in the compressed arrays to read. The column index recovered from that position tells it which row of B to use. This extra level of indexing is the cost paid for storing only the active entries.

The accumulation can be written directly from the meaning of CSR.

C[ℓ, m] = ∑_{q ∈ Iℓ} Aᵥ[q] × B[A꜀[q], m]

Here C is the output and C[ℓ, m] is the value in its example row ℓ and component column m. The symbol q indexes a stored entry, and Iℓ denotes the range of stored positions for row ℓ bounded by the two row pointers. The symbol ∈ indicates that the sum, written ∑, visits q in that range. Aᵥ[q] is the input coefficient and A꜀[q] is its original column index. B[A꜀[q], m] reads component m of the embedding row for that index. The multiplication sign × combines the coefficient and component before addition into the result.

Read in terms of the output coordinates, the row pointer is indexed by the example and each embedding read is indexed by the output component. The pseudocode for the lookup prints the two loop indices inconsistently with those roles. The matrix dimensions and the authors' explanation of the CSR range identify the intended calculation. Interchanging the example and component in the pointer access would make the list of active features depend on which component was being written, even though all components of an example use the same list.

The authors describe processing rows and columns in groups of 32 for their experiments. The choice matches the warp size and gives a two-dimensional block layout for the output. They point out that some of the targeted GPU architectures limit a block to 32 × 32 in this layout or 1024 threads in total. Increasing the tile in both directions would run into that constraint. The computation is parallel over output entries, while the short traversal of an entry's active features determines the work left inside its thread. As that traversal grows longer, each thread has more embedding values to fetch and more contributions to add.

What selection can do before normalization

Softmax converts logits into probabilities. Each logit is exponentiated to obtain a positive weight, and the weight is divided by the sum of those weights. Here is the ordinary form used to define the operation.

softmax(z)ⱼ = exp(zⱼ) / ∑ⱼ′ exp(zⱼ′)

Here z is the vector of logits for an example. The index j specifies the candidate whose probability is being calculated. The subscript j′ ranges over every candidate in the same example. The function exp is the exponential, ∑ denotes summation, and the slash denotes division. The expression softmax(z)ⱼ is the probability for candidate j. Every term in the denominator contributes to it, including the terms for candidates that will be discarded.

The authors also give the numerically stable form.

softmax(z)ⱼ = exp(zⱼ − max(z)) / ∑ⱼ′ exp(zⱼ′ − max(z))

The symbols z, j and j′ have the same meanings as in the preceding formula, and exp, ∑ and division serve the same roles. The operation max(z) finds the largest logit in the example. The subtraction shifts every logit by that same value before exponentiation. This rescales the numerator and denominator together, leaving the mathematical probabilities unchanged. It also ensures that no shifted exponent argument is positive, which is the numerical reason for using this form.

Subtracting the same value from every logit preserves their order. Exponentiation is increasing, and the positive denominator is common to every candidate within the example. Consequently the strongest logits identify the strongest probabilities. The algorithm can select candidates using logits, then compute the normalized probabilities for the selected candidates after their shared denominator becomes available. That is a dependency the authors can remove from selection. A candidate need not wait for normalization to compete for a place in the output.

The output probabilities still depend on the rejected candidates. If many scores outside the selected set have substantial weight, they increase the denominator and decrease the probabilities assigned to the selected entries. This is why the algorithm sums contributions across the whole row even though it only returns the short list. For the same reason, it normalizes each example with its own maximum and its own sum. The ranking equivalence is a statement about candidates with a common denominator.

How a small buffer retains the strongest candidates

The authors start from insertion sort because the retained set in translation is frequently small. The typical beam sizes they cite range from 1 to 75, a range motivated by earlier work including Six Challenges for Neural Machine Translation. Ordinary insertion sort grows a sorted section by taking a new element and finding its place within that section. The paper gives its time bound as follows.

O(K²)

Here K is the number of entries to sort, the superscript ² indicates squaring, and O denotes an asymptotic upper bound on how the work grows. The bound describes the full insertion sort that motivates the design. The proposed routine keeps a separate buffer whose length is the requested output size, so an arrival only has that much of the list to traverse.

The retained slots start at negative infinity, below any ordinary input score. A candidate enters a slot comparison carrying its current value. If the value is greater than what the slot holds, it takes the slot and continues with the displaced entry. If the slot already holds the greater value, it keeps its contents and the candidate continues as before. After visiting the last slot, the candidate in flight is discarded. Repeated swaps replace the movement of a whole run of array entries that one might use when inserting into a conventional sorted array.

For instance, a relatively strong new score may take an early slot that previously held a weaker score. The weaker score then gets a chance to take a later slot, where it competes on the same terms as the entry already there. A strong arrival thus does not discard the first entry it encounters. It displaces that entry and lets it compete for the remaining places. The same procedure can admit the new score, move several current entries, and release the weakest one that survives all the comparisons only as a carried value.

O(KN)

Here K is the number of candidates, N is the number of retained slots, and O again denotes an asymptotic upper bound. The adjacent symbols KN mean the product of the candidate count and buffer length. The bound describes the comparisons in the selection algorithm, since each candidate can visit each slot. It does not give a GPU elapsed time. Threads process candidates in parallel, and updates that encounter the same slot are coordinated by atomic operations. The bound explains why a short retained list matters even with parallel execution.

Doing the comparisons concurrently

The candidate loop is the part the authors parallelize. Multiple threads can arrive at a slot with values that would improve it. A sequence of independent reads and writes would risk losing a better update. The CUDA primitive atomicMax instead keeps the larger of the slot value and the supplied value as one transaction and returns the previous slot value. The thread uses that returned value to decide what to carry forward. If it installed its own candidate, it carries the old one. Otherwise, its current candidate is already the smaller value and proceeds to the next comparison.

There are two useful properties of this update. The first is that the value in a slot can only increase. The second is that the value a thread carries can only decrease as it makes comparisons. Immediately after a comparison, the carried value is at most the value left in that slot. For slots visited earlier, that comparison continues to hold because the earlier slots can only improve and the carried value can only become weaker. When a carried value reaches the end and is discarded, it is no greater than the value in any retained slot. The slots can continue to increase after the discard. This is the basis of the authors' argument that the final buffer contains the top values even when threads interleave their steps.

A numerical value alone is insufficient for decoding. A partial translation can only be expanded correctly if the decoder knows which word produced each selected score. The authors keep the index attached by packing score and index into a single 64-bit integer. The part for the score occupies the upper 32 bits, and the part holding the vocabulary index occupies the lower 32 bits. The paper describes the score representation as preserving score order. A comparison of these packed entries then keeps the better score and its associated index in the same atomic update. An evicted entry also carries its index onward, so the selection routine never has to recover a word identity by searching the input for a matching score.

The packed representation has to support the order assumed by atomicMax. In particular, the assertion that the packing preserves score order matters for signed logits, and the index must come after the score in that comparison so that it cannot outweigh a difference in score. The method gives the layout and the purpose of the packing. Its mathematical argument is about the order represented by the packed values. At the end, unpacking yields both pieces of information needed to return a selected logit as a probability and identify its source column.

Putting selection and softmax in the same operation

For the fused routine, the letter C denotes a minibatch of logits, a separate use of the letter from the matrix product in the lookup. C has L rows of K candidate scores. Each row gets a selection buffer initialized with sentinel values, a running maximum initialized at negative infinity, and a sum for normalization. During the pass in which threads read logits, the row's maximum and the competing entries in the short list are both updated. This ties finding the maximum to the pass needed to select the candidates.

Fused softmax and top-N selection for a minibatch

The steps in order.

Fused softmax and top-N selection for a minibatchStep 1: Assign a thread block to each logit row1. Assign a thread block to each logit rowStep 2: Initialize the retained slots and row accumulators2. Initialize the retained slots and row accumulatorsStep 3: Pack candidate scores with their vocabulary indices3. Pack candidate scores with their vocabulary indicesStep 4: Track the row maximum while selecting candidates4. Track the row maximum while selecting candidatesStep 5: Synchronize and sum shifted exponential weights5. Synchronize and sum shifted exponential weightsStep 6: Unpack the retained scores and indices6. Unpack the retained scores and indicesStep 7: Normalize the retained scores and return their indices7. Normalize the retained scores and return their indices

A synchronization point lets the threads wait until the row maximum is ready before they use it to shift their exponentials. The row sum then has to be ready before the selected probabilities are produced. The normalizer includes all K scores. The final write places the requested probabilities in D and their original column indices in E, each with L rows and N output entries per row. Since only the selected candidates need their probabilities written, the routine can avoid storing a matrix of normalized probabilities over the whole vocabulary for the selection stage to read back.

The stable formula also resolves an inconsistency in how the final step is written in the algorithm. The displayed summation uses scores shifted by the row maximum. The final assignment prints an unshifted exponential of the unpacked score. Under the stated packing of original logits, the final numerator must use the same shift as the denominator to implement the paper's stable softmax equation. The equation specifies the intended probabilities. The two lines as printed do not show matching shifts.

This fusion should be understood in terms of work that can share a pass, work that still has to happen in sequence, and results that can stay local. The ranking can proceed while the maximum is found. The exponential sum has to wait for the maximum in the displayed method. Returning the probabilities has to wait for the sum. The short buffer can live in block-local memory during this work, and only its selected contents are needed as final outputs. Fusion therefore retains the data dependencies of softmax while changing when selection takes place and which arrays must be written out.

Choosing the launch configuration and preparing the inputs

The selection design maps each minibatch row to a CUDA block. Its rows are independent, while threads assigned to a row need access to the same retained buffer. The paper expects especially efficient execution when the number of rows can be accommodated without scheduling multiple blocks on every SM. It gives the Tesla V100 80 SMs and the Pascal TITAN X 30 SMs. That difference provides one reason the authors expect the two devices to respond differently when the batch gets larger.

The experiments use a block size of 256 threads for the fused operation. The authors suggest that a smaller block can be used when the expected number of candidates is smaller than 256, with the thread count kept divisible by 32. Increasing the number of retained entries has a different effect from increasing the number of threads. The auxiliary storage grows with N, and the paper describes a performance penalty when that storage has to extend beyond shared memory. The design therefore has both a computational reason and a storage reason for favoring a short retained list.

Neither routine introduces a training procedure. The lookup takes an existing embedding matrix and the feature indices and values for its input. The output routine takes already computed logits. For measurements, the authors generate random floating-point data for the dense arrays and assume these arrays have no zero entries. They also describe randomly generated sparse minibatches with a specified number of non-zero values per example, assigning their active indices at random. This gives them control of input density for the benchmark. The paper points to a code repository for the operations.

Experiments and results

What the timing measures

The benchmark compares operation times on two GPU setups, one with a Tesla V100 and one with a GeForce GTX TITAN X. The main tables report mean execution time in milliseconds over ten runs. The inputs are generated for the timing experiments. There is no language corpus or train, development or test split for these results. The matrices and batches provide controlled sizes and active-entry counts, and the metric is how long the specified operation takes under those conditions.

The input comparisons use NVIDIA's cuBLAS for the dense computation and cuSPARSE for the general sparse computation. cuBLAS gives a baseline that handles the input as a full matrix. cuSPARSE gives a baseline that has access to the input's sparse structure. Their comparison with the proposed routine tests different questions. An advantage over the dense computation can come from working on fewer entries. An advantage over the sparse computation shows that exploiting sparsity by itself does not account for the measured timing difference in the few-hot case. The specialized way of processing the active entries matters in the tested setting.

The lookup table states L = 100 and K = 10,240. It also prints N = 512 in its caption while using N for the varied count of active values in its column label. The method uses M for the output width. The caption therefore gives the fixed setting as printed but does not use the same symbols consistently for the fixed dimension and the sparsity sweep. It is clearer to describe the sweep in terms of active entries per input row and to reserve the vocabulary size and batch size for the dimensions they unambiguously denote.

For output selection, the baseline is the NVIDIA method of Milakov and Gimelshein. The score width is fixed at K = 10,240 in the table. The authors vary the requested list length and report results at batch sizes L = 1, L = 512 and L = 1024, on both devices. This arrangement distinguishes the number of candidates considered for one example, the number retained for that example, and the number of examples being processed in a batch. Those quantities place different demands on the implementation.

Sparse lookup is strongest with very few active entries

On the V100, several of the low-density cases put the proposed lookup at 0.02 ms and cuBLAS at 0.16 ms. The cuSPARSE time in the comparison shown below is 0.15 ms. The dense routine's timing changes little across the table, which is consistent with its continuing to work over the same matrix dimensions as the active count changes. The proposed routine takes longer as there are more active entries to read. Its early advantage is largest where the CSR ranges are shortest.

V100 lookup time for a low-density synthetic input

The specialized lookup completes the sparse input multiplication faster than either NVIDIA baseline.

V100 lookup time for a low-density synthetic inputcuBLAS: 0.16cuBLAS0.16cuSPARSE: 0.15cuSPARSE0.15Argueta and Chiang sparse lookup (this paper): 0.02Argueta and Chiang sparse lookup (thispaper)0.02
The numbers
System or settingms
cuBLAS0.16
cuSPARSE0.15
Argueta and Chiang sparse lookup (this paper)0.02

On the TITAN X, the relative positions of the baselines are different. A low-density comparison gives the proposed method 0.03 ms, cuSPARSE 0.12 ms and cuBLAS 1.79 ms. The sparse library has a substantial advantage over the dense library in that comparison. It is therefore the more informative baseline for judging the usefulness of a specialized sparse method on this GPU. As the input gets denser, cuSPARSE catches up. The paper describes its own routine as losing to cuSPARSE beyond 10 active entries on the TITAN X. It reports a later crossover against cuBLAS on the V100, beyond 100 active entries per input example.

The comparison across devices is thus partly a comparison of what the libraries do on each device. The same specialized method can look particularly strong against a dense baseline when that baseline is much slower on the TITAN X. A baseline-relative speedup gives the advantage against the named comparator on that hardware. It does not on its own describe the absolute time a lookup will take on another GPU. The paper's 7× headline for the sparse multiplication summarizes the favorable regime. The density sweep shows where the same strategy becomes less competitive.

The authors also time the special case N = 1 with DyNet. They report an average of 0.06ms on the TITAN X and 0.08ms on the V100 for the same lookup dimensions. Those times are below the times of the NVIDIA library baselines in the one-hot comparison, and the authors report that their sparse implementation is faster still. They qualify the comparison because the DyNet measurements include time for building a computation graph. The other timings cover the matrix operation itself. This makes the DyNet figures useful as measurements of the reported execution paths, with a difference in scope between them.

Fused selection gains most when the result is short

With the smallest retained list reported for the V100 and a batch of L = 1, the proposed fused operation takes 0.07 ms and the baseline takes 3.56 ms. The table gives a speedup of 50.85 for that comparison. With the same device and the smallest retained setting at L = 512, the corresponding times are 0.14 ms and 7.99 ms, with a reported speedup of 54.79. For L = 1024 they are 0.25 ms and 12.54 ms, and the table gives 50.08. These comparisons help explain the paper's headline of up to 50× for the fused routine. The individual entries show how the reported advantage depends on the setting.

V100 fused softmax and selection time for the shortest list at L = 1 on synthetic logits

The fused routine has a large timing advantage when the batch and retained list are small.

V100 fused softmax and selection time for the shortest list at L = 1 on synthetic logitsMilakov and Gimelshein baseline: 3.56Milakov and Gimelshein baseline3.56Argueta and Chiang fused routine (this paper): 0.07Argueta and Chiang fused routine (thispaper)0.07
The numbers
System or settingms
Milakov and Gimelshein baseline3.56
Argueta and Chiang fused routine (this paper)0.07

The TITAN X shows a strong relative advantage in its smallest-batch, shortlist comparison too. The table reports 0.09 ms for the proposed routine and 7.65 ms for the baseline at that device's smallest retained setting with L = 1. Its speedup entry is 84.10. This exceeds the paper's headline figure, so the headline is best read alongside the reported measurements rather than as the largest number printed in the experiment table. The absolute time of the proposed routine in that comparison is lower on the V100. The larger relative gain on the TITAN X comes with a slower baseline there.

As the retained list grows, the timing pattern changes. For the V100 at L = 1, the baseline remains near its small-list time across the sweep, whereas the proposed method ends at 4.49 ms for N = 400. The corresponding baseline time is 3.44 ms, with a reported speedup of 0.76 for the proposed routine. At L = 1024 and the same N, the proposed routine takes 19.65 ms and the baseline takes 12.58 ms, with 0.64 in the speedup column. The reversal illustrates the cost of traversing and maintaining more retained slots, even though the vocabulary dimension has stayed fixed.

At N = 400 on the TITAN X, the timing comparison also changes with batch size. With L = 1, the fused routine runs in 6.37 ms and the baseline in 7.59 ms. The speedup entry is 1.19. At L = 512, the fused routine takes 56.70 ms and the baseline takes 18.31 ms, corresponding to a reported speedup of 0.32. The authors point to this change as an example of the TITAN X's sensitivity to the batch size at a large retained setting. At L = 1024 and N = 400 its fused time is 101.10 ms, compared with a baseline time of 28.49 ms.

TITAN X softmax and selection time for synthetic logits at L = 512 and N = 400

The baseline finishes first when this large batch also requires a long retained list.

TITAN X softmax and selection time for synthetic logits at L = 512 and N = 400Argueta and Chiang fused routine: 56.70Argueta and Chiang fused routine56.70Milakov and Gimelshein baseline (this paper): 18.31Milakov and Gimelshein baseline (thispaper)18.31
The numbers
System or settingms
Argueta and Chiang fused routine56.70
Milakov and Gimelshein baseline (this paper)18.31

The authors describe the proposed routine as favorable at N up to 300 and advise using a different method for larger selections. The throughput of the compared routines depends on the batch and GPU, so this is an operating range drawn from the benchmark instead of a uniform crossover. The table includes a speedup entry of 1.00 on the TITAN X at L = 512, and the next, longer retained setting is slower than the baseline. At L = 1024 the TITAN X table also includes a speedup of 0.87 before the final setting. The broad result is strongest at retained sizes typical of the translation use case cited by the authors. The performance gap narrows as the output list grows, and it can reverse before or after the same list length depending on the device and batch.

What the ablations show

The paper has no component-by-component ablation of either routine. It offers controlled timing sweeps over density, retained list length and batch size, comparisons across GPUs, and a separate one-hot lookup comparison. These experiments show how the complete implementations behave when the amount or shape of work changes.

The density sweep tests the lookup's premise

The useful control in the lookup experiment is a fixed matrix shape while the number of active entries changes. The dense implementation continues to operate across the full shape. The specialized implementation has more terms to visit with each increase in active entries. The time therefore changes with the amount of work represented by the compressed ranges even though the size of the returned matrix stays fixed. The strong result at low density and the eventual loss of the advantage are both consistent with this design.

The general sparse baseline provides a further test of that interpretation. On the V100, the authors describe cuSPARSE as roughly on par with cuBLAS after the one-entry case. On the TITAN X, they describe it as faster than the dense baseline. That difference means the specialized method's gain cannot be characterized by counting skipped zero multiplications alone. The choice of baseline and the architecture matter to the cost of turning a sparse representation into a dense product. The authors suggest that the supported sparsity patterns, the available SMs and the memory on the devices contribute to the difference. They do not vary those causes independently.

The one-hot comparison provides a reference for a narrower operation that toolkits already handle directly. It measures how the general few-hot routine behaves when there is just one entry to read. The computation-graph overhead in the DyNet path prevents it from isolating a kernel difference. It still places the few-hot result next to an existing lookup path under the same dimensional setting, which helps distinguish a benchmark against matrix libraries from a benchmark against a toolkit's usual treatment of a single active feature.

The retained list sweep exposes the cost of insertion

For the output operation, fixing the vocabulary width lets the authors make the retained buffer longer without adding more input logits per row. The normalization still operates over the same score vector. What changes directly in the proposed routine is the number of positions candidates can visit and the amount of storage needed for those positions. The baseline's timing changes comparatively little over the list-length sweep at a fixed batch size. The paper attributes that behavior to using the same reduction operation across retained sizes.

The sweep supports the claim that the proposed selection strategy derives its advantage from the short-list requirement. Its elapsed time grows with the list length, whereas the baseline's relatively stable time gives it room to catch up. Because the proposed routine changes selection, intermediate storage and fusion together, the comparison does not quantify a speedup attributable to atomicMax alone. Nor does it isolate a saving from omitting the full probability array. It measures the combined consequences of those choices for complete operations with the same requested output.

The list-length sweep also separates a structural cost from a possible memory effect. A larger buffer gives every candidate more slots to compare against regardless of where the buffer lives. A sufficiently large buffer can additionally exceed shared-memory capacity in the authors' account. Both would make the fused method slower, and the timing curves are compatible with both. The experiment varies N rather than fixing the selection work and changing the location of the buffer, so its timings do not establish the share of the slowdown due to either factor.

The batch sweep tests a different source of scaling

Changing L increases the number of row jobs at the same candidate width and list length. The fused design assigns one block to a row, so this sweep changes the number of blocks that must be scheduled. The comparison across devices fits the authors' expectation that the GPU with more SMs handles larger batches better. The larger absolute times for the fused method on the TITAN X at high batch sizes also explain why its favorable relative result with a short list and a single row should be interpreted within that setting.

A batch sweep changes the amount of work in the baseline too. The baseline timings rise as there are more rows to process even where they move little with the retained size. This explains why looking at speedup alone can obscure the behavior of the proposed operation. For each device, the ratio depends on how the baseline responds to the larger batch as well as on how the new routine responds. Comparing the pairs of execution times makes it possible to see whether the specialized method is getting slower, the baseline is getting slower, or both are changing at different rates.

The hardware comparison supports an architecture-sensitive performance claim. It does not directly test a launch with the same device and different available SM counts or a configuration that varies only the shared-memory budget. The paper gives a plausible explanation through block scheduling and local storage. The controlled part of the evidence is the measured change in settings for the full operation on each GPU. The hardware explanation is an interpretation of that evidence, instead of the outcome of an isolated resource experiment.

Limitations

Limits identified by the authors

The authors present both methods as specialized for sparse cases. For the lookup, the advantage declines as more features are active. The reported crossovers also depend on which GPU and baseline are used. A task with a wide input vector can still be outside the favorable region if many positions contribute to each example. The method benefits from short active lists, rather than from width alone.

For selection, the authors identify the retained-list length and the available shared memory as constraints on performance. The short buffer is well suited to block-local storage in the cases they target. If the working set grows enough to require global memory as well, some of that benefit is lost. The authors also caution that multiple blocks scheduled per SM can reduce the efficiency of their batch layout. They recommend a different approach when N exceeds 300 and report cases where a larger list favors the baseline. These limits concern speed and suitability to the workload.

The paper explicitly qualifies the comparison with DyNet because its timings include computation-graph construction. A slower number on that path cannot be assigned entirely to its one-hot lookup implementation. It also treats the fusion of the last affine transformation with softmax and selection as future work. The experiments start the fused output operation with logits already available. Their timings therefore cover normalization and selection, without measuring the computation that produced those logits.

Limits visible in the experimental setup

The timings use randomly generated data, a fixed vocabulary width in the fused comparison, and two GPU configurations. The experiments can show how the methods respond to the input dimensions and densities tested. They leave open what happens with sparsity patterns from a particular combination of word, sub-word and tag features. In CSR, the layout of active indices determines which rows of the embedding matrix are read. How often real inputs reuse those rows is a property of the workload that a random index assignment does not measure.

The output tests likewise time a specified number of candidate scores and selected entries. They do not measure how batches are formed dynamically in an operating decoder, how frequently a real system uses each batch size, or how much time is spent on other parts of search. The earlier measurements of softmax and selection give a motive for targeting these operations in translation. They cannot be combined with the present kernel timings to establish a speedup for a complete system, since the paper does not profile that same system with and without the new routines.

The reported experiments also leave numerical behavior less directly tested than execution time. The paper explains why the retained logits give the same ranking as softmax within a row and why the atomic comparisons keep the strongest entries. It does not report an experimental comparison of returned probabilities, tie behavior or translation output. The mismatch between the shift in the printed denominator and the final numerator makes the stable equation important when reading the claimed operation. The intended output is specified by that equation and the accompanying description. The timing tables are not a separate check of agreement with it.

The scope of the measurements matters on the input side as well. The lookup method begins with input in CSR and an embedding matrix ready to read. The comparison does not tell a reader what fraction of time a complete application would spend constructing its active features or storing them in that form. A pipeline that already holds its input as active indices is a natural fit for the routine. A pipeline that has to reorganize its input first would have additional work beyond the reported multiplication.

Finally, the two device results support a link between performance and the resources of a GPU, with block scheduling and shared-memory capacity as the authors' explanations. Larger vocabularies, different launch configurations and other devices could change the balance between candidate processing, atomic updates and memory traffic. The measurements establish the behavior of the tested implementations at the reported settings. They do not establish a general boundary where one strategy becomes fastest for every GPU workload.

What came after

No subsequent paper is identified that builds on these routines, so their later adoption remains unestablished here. The direction the authors name for extending the work is to fuse the final affine transformation that produces the logits with the softmax and top-N operation. In the implementation they evaluate, selection and normalization share work once the logits exist. The extension would bring the production of those logits inside the same computation. The authors point out that doing so would require a different matrix multiplication implementation and a different use of shared memory. That proposal remains distinct from the two operations whose performance they report.

Cite

Cite as Arturo Argueta and David Chiang. 2019. Accelerating Sparse Matrix Operations in Neural Networks on Graphics Processing Units. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/p19-1626

@inproceedings{argueta2019accelerating,
  title = {{Accelerating Sparse Matrix Operations in Neural Networks on Graphics Processing Units}},
  author = {Arturo Argueta and David Chiang},
  booktitle = {Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/p19-1626},
  url = {https://doi.org/10.18653/v1/p19-1626}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/argueta-2019-accelerating-sparse-matrix-operations-neural/