Skip to main content
QUICK REVIEW

[Paper Review] Cortex: A Compiler for Recursive Deep Learning Models

Pratik Fegade, Tianqi Chen|arXiv (Cornell University)|Nov 2, 2020
Advanced Neural Network ApplicationsComputer Science45 references10 citations
TL;DR

Cortex is a compiler that optimizes recursive deep learning models for low-latency inference by enabling end-to-end optimizations such as kernel fusion and model persistence, achieving up to 14X lower inference latency than prior work across CPUs and GPUs without relying on vendor libraries.

ABSTRACT

Optimizing deep learning models is generally performed in two steps: (i) high-level graph optimizations such as kernel fusion and (ii) low level kernel optimizations such as those found in vendor libraries. This approach often leaves significant performance on the table, especially for the case of recursive deep learning models. In this paper, we present Cortex, a compiler-based approach to generate highly-efficient code for recursive models for low latency inference. Our compiler approach and low reliance on vendor libraries enables us to perform end-to-end optimizations, leading to up to 14X lower inference latencies over past work, across different backends.

Motivation & Objective

  • Address the performance gap in inference latency for recursive and dynamic deep learning models, especially on CPUs and GPUs.
  • Overcome limitations of vendor libraries like cuDNN and MKL, which lack support for less common models such as TreeLSTM and MV-RNN.
  • Enable aggressive optimizations such as kernel fusion and model persistence by avoiding black-box kernel abstractions.
  • Support efficient execution of recursive models with dynamic control flow through static, compiler-based optimizations.
  • Provide a portable, backend-agnostic compilation stack that enables high performance across diverse hardware substrates.

Proposed method

  • Lower recursive control flow into efficient loop-based representations by observing that control depends solely on input data structures.
  • Use scheduling primitives to perform static optimizations including specialization and dynamic batching prior to tensor computation.
  • Apply computation hoisting to move repeated computations outside recursive loops, reducing redundant work.
  • Employ an intermediate representation (IR) that unifies recursive control flow and tensor algebra, enabling end-to-end optimization.
  • Leverage techniques from the sparse polyhedral framework and inspector-executor model to represent and optimize indirect memory accesses and data structure layouts.
  • Formalize optimizations like model persistence and kernel fusion as first-class transformation primitives within the compiler pipeline.

Experimental results

Research questions

  • RQ1Can a compiler-based approach outperform vendor library–based frameworks in optimizing recursive deep learning models for inference?
  • RQ2How can recursive control flow be effectively represented and optimized in a compiler IR without runtime overhead?
  • RQ3To what extent can end-to-end optimizations like kernel fusion and model persistence be applied to recursive models when avoiding vendor library abstractions?
  • RQ4Can static optimizations such as dynamic batching and computation hoisting be effectively applied to recursive models at compile time?
  • RQ5How does the performance of a custom compiler stack compare to existing frameworks in terms of inference latency across diverse hardware backends?

Key findings

  • Cortex achieves up to 14X lower inference latency compared to prior work across multiple backends, including CPUs and GPUs.
  • By avoiding vendor libraries, Cortex enables aggressive kernel fusion, reducing kernel launch overhead and improving memory access patterns.
  • Model persistence is effectively applied to recursive models, keeping frequently reused parameters in fast on-chip memory and reducing off-chip memory access.
  • The compiler-based approach supports static dynamic batching and specialization, eliminating runtime overheads seen in frameworks like DyNet and PyTorch.
  • The IR design successfully represents recursive control flow and tensor computations together, enabling unified optimization across both domains.
  • Cortex’s optimizations are generalizable and could serve as a low-level backend for higher-level frameworks, improving their performance on dynamic models.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.