[Paper Review] Deep Learning with Dynamic Computation Graphs
Introduces dynamic batching to enable efficient training and inference for neural networks with dynamic computation graphs, and presents TensorFlow Fold, a combinator library to build such models concisely.
Neural networks that compute over graph structures are a natural fit for problems in a variety of domains, including natural language (parse trees) and cheminformatics (molecular graphs). However, since the computation graph has a different shape and size for every input, such networks do not directly support batched training or inference. They are also difficult to implement in popular deep learning libraries, which are based on static data-flow graphs. We introduce a technique called dynamic batching, which not only batches together operations between different input graphs of dissimilar shape, but also between different nodes within a single input graph. The technique allows us to create static graphs, using popular libraries, that emulate dynamic computation graphs of arbitrary shape and size. We further present a high-level library of compositional blocks that simplifies the creation of dynamic graph models. Using the library, we demonstrate concise and batch-wise parallel implementations for a variety of models from the literature.
Motivation & Objective
- Motivate and address inefficiencies of training DCGs with static data-flow graphs.
- Propose dynamic batching to batch operations across graphs of differing shapes and within a single graph.
- Show how to implement DCG models using a high-level combinator library for rapid prototyping and experimentation.
- Demonstrate empirical speedups and practical feasibility on CPU and GPU hardware.
Proposed method
- Define dynamic batching as a scheduling technique that groups same operations at the same depth across a batch of input graphs.
- Rewrite input DCGs into a static graph that uses gather and concat operations to emulate dynamic graphs.
- Implement DCGs in TensorFlow using a while_loop to iterate over graph depths, enabling backpropagation through the static graph.
- Develop TensorFlow Fold, a combinator library with blocks, maps, folds, reduces, and other constructs to compose DCG models at a high level.
- Present examples including TreeRNNs, Tree-LSTMs, feed-forward attention, and molecular graph convolutions to illustrate expressiveness and batching benefits.
Experimental results
Research questions
- RQ1Can dynamic batching compensate for the inability to batch across varying graph topologies in standard static-graph libraries?
- RQ2What are the performance trade-offs (speed and overhead) when batching DCGs using the proposed static graph emulation?
- RQ3How effective is the TensorFlow Fold combinator library in enabling concise and scalable DCG model development?
- RQ4To what extent can DCG models, implemented via dynamic batching, achieve state-of-the-art or competitive results on tasks like sentiment analysis and molecular graph processing?
Key findings
- Dynamic batching yields substantial speedups over naive single-tree processing, with up to 160x faster results on GPUs for large trees when fully batched.
- Dynamic batching reduces kernel invocation overhead by instantiating each operation once and executing per-depth batches, leading to fewer and larger GPU kernels.
- There is an overhead cost from extra concat and gather operations, but overall gains remain favorable, especially at larger batch sizes or when fully leveraging within-tree batching.
- The TensorFlow Fold combinator library enables concise implementations of DCG models and accelerates experimentation by reducing code size and enabling rapid model variants.
- Experiments include TreeRNNs, Tree-LSTMs for sentiment analysis, and a graph-convolution approach for molecules, illustrating breadth and practicality.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.