TL;DR
This paper introduces FlashFuser, a novel compiler framework that leverages the NVIDIA H100's Distributed Shared Memory (DSM) to enable kernel fusion for previously unmanageable large-scale operator chains. By introducing a new DSM communication abstraction and a sophisticated dataflow analyzer, FlashFuser significantly reduces memory access and achieves substantial speedups for compute-intensive deep learning workloads.
What Problem Does This Paper Address?
Modern deep learning models, especially Large Language Models (LLMs), are increasingly compute-intensive, but their performance is often bottlenecked by memory bandwidth. Kernel fusion, a technique to combine multiple operations into a single kernel to reduce memory traffic, has been a key optimization. However, existing fusion strategies are limited to using the small, local scratchpad memory (SMEM) of a single Streaming Multiprocessor (SM). When intermediate results exceed this capacity, fusion fails, forcing inefficient round trips to global memory. NVIDIA's H100 GPU introduces Distributed Shared Memory (DSM), a larger, high-bandwidth on-chip memory pool connecting multiple SMs, but software frameworks haven't effectively utilized this capability for kernel fusion. This paper addresses the gap of exploiting DSM for large-scale kernel fusion.
Methods
FlashFuser tackles this problem with three core contributions:
- DSM-based Communication Abstraction (
dsm_commprimitive): This new abstraction formalizes complex data exchange patterns (like reduce, shuffle, multiply) required for inter-SM communication within DSM. It provides primitives likedsm_all_exchange,dsm_shuffle, anddsm_reduce_scatterto manage data movement across SM clusters. - Dataflow Analyzer: This component generalizes existing techniques to the DSM hierarchy. It analyzes loop scheduling, resource mapping, and tiling strategies to quantify data movement across all memory levels (registers, SMEM, DSM, L2, global memory). It determines optimal execution orders and tile sizes by modeling how data spills progressively to slower memory tiers.
- Fusion Search Engine: To navigate the vastly expanded search space introduced by DSM, FlashFuser employs an analytical cost model and DSM-aware pruning strategies. This engine efficiently discovers the optimal fusion plan by exploring combinations of loop schedules, tiling sizes, and resource mappings.
The implementation leverages NVIDIA's CUTLASS library for code generation and utilizes hardware features like the Tensor Memory Accelerator (TMA) for efficient inter-cluster reductions.
Datasets
The paper does not explicitly mention training datasets. For evaluation, they use:
- GEMM chains: Configurations derived from models like DLRM, GPT-2, GPT-6.7B, and OPT-1.3B.
- Convolutional chains: Extracted from real-world ResNet models.
- Gated FFNs: Configurations from LLMs like Llama, Qwen, and BERT.
- Real-world LLMs: Llama3-70B, Qwen2.5-14B, and Qwen2.5-32B for end-to-end inference evaluation using the SGLang framework.
Key Insights and Ideas
- DSM is the next frontier for kernel fusion: The paper convincingly argues that exploiting DSM is crucial for scaling kernel fusion beyond the limitations of single-SM scratchpad memory.
- Bridging hardware potential with software reality: FlashFuser demonstrates a practical approach to harness the complex inter-core communication capabilities of modern GPUs, which were previously underutilized for fusion.
- A unified approach to memory hierarchy: The dataflow analyzer's ability to model and optimize data movement across registers, SMEM, DSM, and global memory is a significant step towards holistic memory optimization.
- The search space explosion is manageable: By combining a sophisticated cost model with DSM-aware pruning, FlashFuser effectively navigates the exponentially larger search space introduced by DSM.
Key Results
- Kernel Speedups: FlashFuser achieves speedups of 3.3x against highly-tuned libraries and 4.1x against state-of-the-art compilers on an NVIDIA H100 GPU.
- Memory Access Reduction: Memory access is reduced by 58%.
- End-to-End Speedup: An overall end-to-end speedup of 1.24x is achieved.
- Performance across workloads: Significant speedups are observed for GEMM chains (up to 5.4x over baselines), convolutional chains (up to 6.4x), and gated FFNs.
- LLM Inference: An average end-to-end speedup of 1.32x is achieved on real-world LLMs using the SGLang framework.
- Search Efficiency: The search engine accelerates compilation by 12-864x compared to brute-force search.
Limitations and Future Work
- Hardware Specificity: While the
dsm_commabstraction is topology-agnostic, the current implementation and evaluation are focused on NVIDIA H100 GPUs. Adapting to other architectures with different DSM configurations might require further work. - Search Overhead: Although significantly faster than brute-force, the search process is still an offline compilation step. The paper mentions that the overhead primarily consists of cost model prediction and compilation for top-K kernels, highlighting the importance of selecting an appropriate K.
- Future Work: The paper suggests that the DSM communication primitives can be extended to support more complex collective operations. Additionally, exploring the application of FlashFuser to other domains beyond deep learning, such as high-performance computing, could be a promising direction. The authors also note that the proposed fusion strategy is not limited to a specific architecture and could be applicable to other hardware with inter-core connections.
Summary updated