Abstract
Constituency parsing with rich grammars remains a computational challenge. Graphics Processing Units (GPUs) have previously been used to accelerate CKY chart evaluation, but gains over CPU parsers were modest. In this paper, we describe a collection of new techniques that enable chart evaluation at close to the GPU’s practical maximum speed (a Teraflop), or around a half-trillion rule evaluations per second. Net parser performance on a 4-GPU system is over 1 thousand length-30 sentences/second (1 trillion rules/sec), and 400 general sentences/second for the Berkeley Parser Grammar. The techniques we introduce include grammar compilation, recursive symbol blocking, and cache-sharing.
Introduction
Constituency parsing—the process of breaking a sentence into its nested syntactic constituents—is a cornerstone of NLP but is notoriously slow. The standard CKY algorithm has a complexity of $O(Gs^3)$, where $G$ is the number of grammar rules and $s$ is the sentence length. High-accuracy grammars like the Berkeley Parser can contain millions of rules, requiring billions of operations per sentence.
While GPUs offer massive parallelism, previous attempts to port parsers saw only modest gains. The primary bottleneck is data movement: irregular memory access patterns often leave the GPU's high-speed processors idling. This paper treats parsing as a high-performance computing (HPC) challenge, aiming to saturate the GPU's processing power.
Technical Innovations
The authors introduced three key technical innovations to overcome the data movement bottleneck.
1. Grammar Compilation
Instead of treating the grammar as a data structure read at runtime, the authors "open-code" it into C++ kernels. This allows the GPU to perform register-to-register operations, which are roughly 20x faster than using shared memory. By compiling the grammar into instructions, the system leverages the GPU's hardware instruction scheduler to optimize rule application.
2. Spectral Symbol and Rule Blocking
GPU register space is limited, making it impossible to load a large grammar entirely. The authors used a spectral clustering algorithm to group symbols that frequently appear together in rules. This ensures that when a block of rules is loaded, the necessary symbols fit into registers, minimizing expensive reloads from main memory.
3. Sub-block Partitioning
To maximize the use of the L2 cache and distribute work across the GPU’s stream processors (SMXs), the rule blocks are further divided into sub-blocks. This 3D partitioning (Left, Right, Parent) allows for fine-grained parallelism.
4. Iterative Viterbi Search
Since GPUs lack a hardware stack for recursion, a non-recursive, iterative version of the Viterbi algorithm was developed to extract final parse trees efficiently.
Evaluation and Results
The system was evaluated using the Berkeley Latent Variable Grammar (~1.7 million rules) on the Penn Treebank (Section 22).
- Throughput: The system achieved a peak of 900 Gflops per GPU.
- Speed: On a 4-GPU system, the parser processed over 1,000 length-30 sentences per second.
- Efficiency: This is a 50x improvement over previous GPU parsers and several orders of magnitude faster than CPU-based CKY evaluation.
The "aha moment" is the realization that parsing is primarily a data movement problem. By exploiting grammar sparsity (only ~0.2% of possible rules exist) via spectral partitioning, the authors achieved a symbol reload rate 500x better than naive methods.
Conclusion and Future Work
While the parser is incredibly fast, the grammar compilation process is slow, taking over an hour for the Berkeley grammar. Future work could involve generating GPU assembly (PTX) directly to bypass the C++ compiler. Additionally, the current implementation performs full CKY evaluation; incorporating "coarse-to-fine" pruning could potentially yield another 1-2 orders of magnitude in speedup.
Summary updated