A Dataflow Compiler for Efficient LLM Inference using Custom Microscaling Formats

Jianyi Cheng, Cheng Zhang, Zhewen Yu, Alexander Montgomerie-Corcoran, Can Xiao, Christos-Savvas BouganisarXiv 2023 · DOI

Abstract

Model quantization represents both parameters (weights) and intermediate values (activations) in a more compact format, thereby directly reducing both computational and memory cost in hardware. The quantization of recent large language models (LLMs) faces challenges to achieve competitive memory density compared to other models such as convolutional neural networks, since values in LLMs require larger dynamic ranges. Current hardware can expedite computation for LLMs using compact numerical formats such as low-bitwidth integers or floating-point numbers. Each has advantages: integer operations simplify circuit design, whereas floating-point calculations can enhance accuracy when a wider dynamic range is required. In this work, we seek an efficient data format that combines the best of both worlds: Microscaling (MX) formats. MX formats are efficient data formats that achieve both large dynamic ranges and high memory density. In this paper, we propose a compiler named MASE for exploring mixed-precision MX formats on dataflow hardware accelerators for LLM inference. Our main contributions are twofold. First, we propose a novel orchestration abstraction to explore both software and hardware optimizations with new data formats. Second, MASE achieves LLM inference at an average precision of 4-bits, with minimal to no accuracy degradation. To our knowledge, MASE represents the first effort to harness fine-grain multi-precision MX formats in the design of LLM hardware accelerators. Over a range of LLMs and datasets, MASE achieves an average improvement of 24% in $\Delta$ accuracy with an overhead of only 3% in energy efficiency compared to designs using 8-bit fixed-point numbers.

Introduction: The Quantization Challenge in LLMs

Deploying Large Language Models (LLMs) such as LLaMA or GPT-3 presents significant hardware challenges due to their immense parameter counts. While quantization—reducing the precision of weights and activations—is a standard technique to mitigate memory and power constraints, LLMs pose a unique difficulty. Their activations exhibit massive numerical variance across different layers, sometimes spanning up to four orders of magnitude (7600×).

Standard numerical formats often fail to capture this range efficiently. Fixed-point (Int8) formats are hardware-efficient but lack the dynamic range necessary to handle such variance, leading to significant accuracy degradation. Conversely, floating-point (FP8) formats provide the required range but necessitate complex, area-intensive hardware. Furthermore, existing tools often require manual, labor-intensive iterations to determine the optimal mixed-precision balance for specific hardware targets.

Microscaling (MX) Formats

To address these limitations, this work leverages Microscaling (MX) formats. Instead of each value possessing its own exponent (as in standard floating-point), MX formats share a single scaling factor (exponent) across a "block" of values (e.g., 32 elements). This approach provides the dynamic range of floating-point with the simplified arithmetic logic of integers.

Microscaling (MX) formats like MXInt and Block MiniFloat (BMF) share exponents across blocks of values to balance dynamic range and hardware efficiency.

The paper explores several variants, including MXInt (integer mantissas), Block MiniFloat (BMF), and Block Logarithm (BL). Among these, MXInt8 emerged as a particularly effective "sweet spot," matching the accuracy of FP32 models while remaining significantly more area-efficient by reusing shared exponent logic.

The MASE Compiler and Dataflow Acceleration

The proposed MASE compiler is an end-to-end tool designed to map PyTorch models onto dataflow accelerators. It introduces two key innovations:

  1. MASE Intermediate Representation (IR): A novel, hardware-aware IR that stores critical details such as streaming tile sizes, dataflow interfaces, and throughput rates. Crucially, it is "trainable," preserving the ability to perform Quantization-Aware Training (QAT).
  2. Automated Precision Search: MASE employs a Bayesian optimization algorithm (Tree-structured Parzen Estimator) to automatically explore the design space. It identifies the optimal bit-width for every tensor to maximize accuracy within defined hardware area and power budgets.
The MASE IR captures hardware-aware attributes like tiling, dataflow interface, and throughput rates to bridge the gap between high-level models and hardware implementation.

Unlike traditional CPUs or GPUs that execute tasks sequentially, the dataflow architecture generated by MASE exploits task-level parallelism. This allows different components of a transformer block to stream data simultaneously, significantly increasing throughput.

Experimental Results and Insights

The researchers evaluated MASE using the Wikitext2 dataset for perplexity and a suite of six downstream tasks (including boolq, mnli, and sst2) across BERT, OPT, and LLaMA model families.

Key findings include:

  • Extreme Compression: MASE achieved LLM inference at an average precision of 4-bits with minimal accuracy loss.
  • Superior Accuracy: Compared to standard 8-bit fixed-point (Int8) designs, MASE improved $\Delta$ accuracy by an average of 24%.
  • Hardware Efficiency: The use of custom MX formats resulted in only a 3% energy efficiency overhead while providing a 1.31× improvement in area efficiency compared to standard implementations.
  • Rapid Compilation: MASE reduces the time required for hardware code generation from weeks to mere seconds or minutes.

A critical insight from this work is that variance in LLMs is not only high but also highly inconsistent. Tensors within the same layer can exhibit a 7900-fold difference in variance, underscoring the necessity of the fine-grained, automated quantization approach provided by MASE.

Conclusion and Future Work

MASE represents a significant step forward in hardware-software co-design for LLM inference. By combining the flexibility of Microscaling formats with an automated, hardware-aware compiler, it enables high-performance, low-precision inference on dataflow hardware. Future research directions include integrating even more complex formats like Microscaling Floating Point (MXFP), extending support to systolic array architectures, and exploring dynamic block size adjustments across layers.

Summary updated

BibTeX
@misc{cheng2023dataflow,
  author = {Jianyi Cheng and Cheng Zhang and Zhewen Yu and Alexander Montgomerie-Corcoran and Can Xiao and Christos-Savvas Bouganis},
  title = {{A Dataflow Compiler for Efficient LLM Inference using Custom Microscaling Formats}},
  year = {2023},
  eprint = {2307.15517},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.15517},
}
Figure