TL;DR
This paper introduces "Hidet," a new programming paradigm called "task-mapping" for writing efficient deep learning tensor programs. By allowing developers to directly embed scheduling logic within tensor programs using task mappings, Hidet overcomes the limitations of existing loop-oriented scheduling, leading to significant performance improvements and drastically reduced tuning times for deep learning models on GPUs.
What Problem Does This Paper Address?
Deep learning models are increasingly deployed in various environments, making efficient inference crucial for reducing latency and maximizing throughput. Developing optimized tensor programs for deep learning operators is challenging due to the complexity of modern hardware accelerators (like GPUs) and the ever-growing number of operators. Existing deep learning compilers, such as TVM, use declarative scheduling primitives to simplify this process. However, these approaches are insufficient for expressing advanced optimizations like double buffering and require extensive tuning time. This paper addresses the limitations of current compiler techniques in terms of expressiveness, extensibility, and tuning efficiency.
Methods
The core contribution is the task-mapping programming paradigm. Instead of relying on declarative loop-oriented primitives, Hidet allows developers to define computations as "tasks" and explicitly map these tasks to processing units (like threads) and define their execution order directly within the tensor program. This is achieved through:
- Task Mappings: These are functions that map workers (e.g., threads) to a set of tasks, defining how computations are assigned and ordered.
- Task Mapping Composition: A mechanism to combine basic task mappings (like
repeatandspatial) to construct complex scheduling strategies. - Post-Scheduling Fusion: A technique that automatically fuses scheduled operators with their surrounding "prologue" and "epilogue" operators, simplifying the fusion process and allowing developers to focus on optimizing individual operators.
- Hardware-Centric Schedule Space: Hidet uses a schedule space that is independent of input sizes, leading to significantly smaller and more efficient search spaces compared to input-centric approaches.
Hidet also employs two scheduling mechanisms: rule-based scheduling for most operators and template-based scheduling for performance-critical operators like matrix multiplication.
Datasets
The paper does not introduce new datasets. It evaluates Hidet on standard deep learning models and benchmarks, including:
- Models: ResNet-50, Inception-V3, MobileNet-V2, BERT, GPT-2.
- Workloads: Convolutional neural networks (CNNs) and transformer-based natural language processing (NLP) models.
Key Insights and Ideas
- Expressiveness is Key: The limitations of loop-oriented scheduling stem from their inability to express fine-grained optimizations like double buffering, which are crucial for high performance. Task mapping directly addresses this by providing a more expressive way to define computation and scheduling.
- In-Program Scheduling Simplifies Development: Embedding scheduling logic directly into tensor programs, rather than through separate declarative primitives, makes the process more intuitive and less error-prone.
- Hardware-Centricity Reduces Tuning Time: Moving away from input-centric schedule spaces to hardware-centric ones drastically cuts down the time needed to find optimal schedules, making compilers more practical for rapid iteration and deployment.
- Post-Scheduling Fusion Automates Complexity: By decoupling the scheduling of an anchor operator from the fusion process, Hidet simplifies the optimization of complex sub-graphs, reducing engineering effort.
Key Results
Hidet demonstrates significant improvements over state-of-the-art frameworks and compilers:
- Performance: Achieves up to 1.48x speedup (1.22x on average) compared to ONNX Runtime, TVM (with AutoTVM and Ansor) on various deep learning models.
- Tuning Time: Reduces tuning time by 20x compared to AutoTVM and 11x compared to Ansor.
- Schedule Space: Hidet's hardware-centric schedule space is orders of magnitude smaller (e.g., ~180 schedules for matrix multiplication vs. ~10^8 for AutoTVM).
- Robustness: Hidet shows better performance consistency across different input sizes, unlike input-centric schedulers that can fail for prime number dimensions.
Limitations and Future Work
- Focus on GPUs: The current implementation and evaluation primarily focus on NVIDIA GPUs.
- Limited Schedule Templates: Hidet currently only implements two efficient schedule templates for matrix multiplication and reduction operators, relying on rule-based scheduling for most other operators.
- Future Work: The authors plan to extend Hidet to support CPUs and other accelerators (like Amazon Inferentia and Trainium). They also aim to support deep learning model training, which is currently hindered by long tuning times in existing systems but is made feasible by Hidet's reduced tuning overhead.
Summary updated