Abstract
Dynamic neural networks, which adapt their structure to individual data samples (e.g., trees for sentiment analysis or variable-length sequences), are increasingly common in modern AI. However, existing frameworks either struggle with the high overhead of dynamic graph construction or require complex, non-intuitive programming to achieve efficiency. We present Cavs, a vertex-centric programming interface that separates static computational logic from dynamic graph structures. By defining a static "vertex function" and managing dynamic tensors for efficient GPU batching, Cavs eliminates the "construction tax" of dynamic models. Our evaluation demonstrates that Cavs achieves up to a 10x speedup over state-of-the-art frameworks like DyNet and TensorFlow Fold, while remaining as efficient as static frameworks for standard models.
Introduction
Most deep learning frameworks, such as Caffe or the original TensorFlow, are optimized for static dataflow graphs. While highly efficient for fixed structures, they are ill-suited for dynamic models where the data structure—such as a linguistic parse tree or a social network graph—varies per sample.
Existing solutions generally fall into two categories:
- Dynamic Declaration (e.g., DyNet, PyTorch): These frameworks define a new graph for every sample. While flexible, the overhead of building and optimizing these graphs often exceeds the actual computation time.
- Static Unrolling (e.g., TensorFlow Fold): These attempt to map dynamic data onto static graphs. This approach is often non-intuitive and involves heavy preprocessing that negates performance gains.
Cavs addresses this by "thinking locally." It decomposes a dynamic model into a static vertex function ($\mathcal{F}$) representing the logic and a dynamic input graph ($\mathcal{G}$) representing the structure.
Methodology: The Vertex-Centric Approach
The core innovation of Cavs is the shift from global graph construction to local vertex logic. Instead of declaring a massive global dataflow graph for each sample, the user defines a symbolic Vertex Function ($\mathcal{F}$).
Core Components
- Decomposition: By separating logic ($\mathcal{F}$) from topology ($\mathcal{G}$), the logic can be pre-optimized (e.g., kernel fusion) while the topology is treated as simple input data.
- Symbolic APIs: Cavs provides four key operations—
gather,scatter,pull, andpush—to manage data flow between vertices and external sources/sinks. - Dynamic Tensor Management: To ensure high performance on GPUs, Cavs uses a specialized memory manager that coalesces vertex data into continuous memory blocks. This prevents fragmented memory access, which is a common bottleneck in dynamic batching.
System Optimizations
Cavs implements Lazy Batching, which defers non-immediate operations (like parameter updates) to be processed in large batches. Furthermore, because the vertex function is static, Cavs can apply standard compiler optimizations like Automatic Kernel Fusion, combining multiple small operations into a single fast GPU kernel.
Evaluation and Results
The authors evaluated Cavs using standard benchmarks including the Penn Tree Bank (PTB) for LSTMs and the Stanford Sentiment Treebank (SST) for Tree-LSTM models.
Key Findings
- Performance: Cavs achieved nearly a 10x speedup over TensorFlow Fold and DyNet on Tree-LSTM and Tree-FC models.
- Scalability: Cavs scales effectively with batch size. At a batch size of 128, its batching policy was 36x faster than serial execution.
- Efficiency: On standard static LSTMs, Cavs matched the performance of highly optimized static frameworks, proving that its dynamic flexibility does not compromise base performance.
Conclusion and Future Work
Cavs successfully bridges the gap between the flexibility of dynamic neural networks and the performance of static frameworks. By bypassing the "construction tax" through a vertex-centric design and efficient memory management, it offers a significant performance boost for complex models. Future work includes improving integration with high-level user APIs and extending the system to handle more irregular, non-recursive graph types.
Summary updated