CoSA: Scheduling by Constrained Optimization for Spatial Accelerators

Qijing Huang, Minwoo Kang, Grace Dinh, Thomas Norell, Aravind Kalaiah, James Demmel, John Wawrzynek, Yakun Sophia Shao

Overview

CoSA (Constrained Optimization for Spatial Accelerators) transforms the complex task of scheduling Deep Neural Network (DNN) workloads onto specialized hardware into a mathematical optimization problem. By using Mixed-Integer Programming (MIP), CoSA generates highly efficient schedules in a single "one-shot" pass, outperforming state-of-the-art search-based tools by up to 2.5× in performance while being 90× faster at finding the solution.

The Scheduling Bottleneck in DNN Accelerators

Modern DNN accelerators, such as the TPU or Eyeriss, utilize hundreds of processing elements (PEs) and multi-level memory hierarchies to achieve high throughput. However, effectively utilizing this hardware is a significant challenge. To execute a single layer, a programmer or compiler must determine:

  1. Loop Tiling: Partitioning large data blocks into smaller chunks for local buffers.
  2. Loop Permutation: Ordering these chunks to maximize data reuse.
  3. Spatial Mapping: Assigning computations to run in parallel across PEs versus sequentially.

The scheduling space for a single ResNet-50 layer can contain billions of valid combinations, with a massive variance in performance.

Distribution of valid schedules for a single DNN layer, highlighting the vast performance gap between optimal and sub-optimal mappings.

Existing tools typically rely on brute-force search or feedback-driven machine learning, both of which are computationally expensive and slow. CoSA addresses this gap by navigating the space analytically without requiring thousands of simulations.

Methods: Scheduling as Constrained Optimization

CoSA introduces a novel formulation that treats scheduling as a prime-factor allocation problem.

The CoSA framework maps DNN layer dimensions to spatial accelerator resources using constrained optimization.

Mathematical Representation

The dimensions of a DNN layer (e.g., width, height, channels) are decomposed into their prime factors. A binary decision matrix represents the assignment of each factor to a specific memory level, PE, or temporal slot.

Mixed-Integer Programming (MIP)

Instead of searching, hardware limits—such as buffer capacities and available PEs—are expressed as linear constraints. To handle non-linear buffer utilization (products of factors), CoSA employs a "logarithm trick" to convert products into sums, making the problem solvable by standard mathematical solvers like Gurobi.

Objective Functions

CoSA optimizes for a weighted sum of three primary goals:

  • Maximizing buffer utilization.
  • Minimizing compute cycles.
  • Minimizing communication traffic (multicast, unicast, and reduction).

Evaluation and Key Results

The authors evaluated CoSA across prominent DNN workloads, including ResNet-50, AlexNet, and ResNeXt-50, targeting spatial-array architectures similar to NVIDIA’s Simba.

  • Performance: CoSA-generated schedules achieved a geometric mean speedup of 2.5× compared to state-of-the-art search-based mappers like Timeloop.
  • Efficiency: Schedules were 22% more energy-efficient than those found by traditional hybrid search methods.
  • Time-to-Solution: CoSA found superior schedules in approximately 4 seconds, a 90× improvement over existing tools that took over 6 minutes.
  • Generalization: On general-purpose GPUs, CoSA achieved a 1.10× speedup over the TVM compiler while being 2,500× faster at finding the schedule.

Insights and Future Directions

The core innovation of CoSA is the realization that the regularity of DNNs and spatial hardware allows for a deterministic, "one-shot" solution. By linearizing the search space and explicitly accounting for communication costs across the Network-on-Chip (NoC), CoSA bypasses the combinatorial explosion that plagues traditional methods.

Currently, CoSA focuses on dense workloads and assumes deterministic hardware with managed scratchpads. Future work may extend the framework to exploit data sparsity and adapt to the non-deterministic nature of general-purpose CPU caches. Additionally, automating the weighting of objective function parameters remains an area for further development.

Summary updated

BibTeX
@inproceedings{huang2021cosa,
  author = {Qijing Huang and Minwoo Kang and Grace Dinh and Thomas Norell and Aravind Kalaiah and James Demmel and John Wawrzynek and Yakun Sophia Shao},
  title = {{CoSA: Scheduling by Constrained Optimization for Spatial Accelerators}},
  booktitle = {ISCA},
  year = {2021},
  url = {https://openreview.net/forum?id=NQ8t3rxVu9},
}
Figure