QMoE: Bringing Trillion-Parameter Models to Commodity Hardware

Know Early AI Trends!

Sign-up to get Trends and Tools related to AI directly to your inbox

We don’t spam!

Large language models (LLMs) have revolutionized AI, but their massive size and high computational cost hinder their widespread deployment. Mixture-of-Experts (MoE) architectures offer a solution by enabling sparse routing, achieving faster and more accurate models with significantly more parameters. However, this benefit comes at the cost of immense memory requirements. For instance, the SwitchTransformer-c2048 model boasts 1.6 trillion parameters, demanding 3.2TB of accelerator memory for efficient operation. This presents a significant challenge for practical deployment and research.

This blog post delves into QMoE, a novel compression and execution framework that tackles the memory bottleneck of massive MoEs. QMoE introduces a scalable algorithm that compresses trillion-parameter MoEs to less than 1 bit per parameter, utilizing a custom format and bespoke GPU decoding kernels for efficient end-to-end compressed inference. This breakthrough enables the execution of trillion-parameter models on affordable commodity hardware, opening doors for wider adoption and further research.

Challenges of Compressing Massive MoEs

Compressing MoEs to practical sizes requires overcoming several hurdles:

  1. Sub-1-bit Compression: Existing post-training compression methods struggle to achieve the necessary 10-20x compression rates without significant accuracy loss. Most methods can only reach 3-4 bits per parameter or around 50% sparsity before accuracy suffers.
  2. Scaling Issues: Applying existing compression methods designed for large dense models to even larger MoEs presents memory, performance, and reliability challenges.
  3. Custom Compression Format: Achieving sub-1-bit compression necessitates a custom format and efficient decoding algorithms for accelerators like GPUs to ensure fast inference.

QMoE: A Scalable and Efficient Solution

QMoE addresses these challenges by introducing:

  • Scalable Compression Algorithm: QMoE leverages data-dependent quantization, specifically the GPTQ method, and optimizes it for MoEs. This includes efficient activation offloading, list buffer data structures, lazy weight fetching, expert grouping, and robustness modifications.
  • Custom Compression Format: QMoE exploits the natural sparsity of quantized weights and utilizes a dictionary-based code with fixed-length codewords mapping to a variable number of symbols. This design enables fast GPU decoding while achieving high compression rates.
  • Bespoke GPU Decoding Kernels: QMoE co-designs the compression scheme with specialized GPU kernels for fast on-the-fly decoding. This minimizes the runtime overhead associated with compressed inference.

QMoE in Action: Compressing SwitchTransformer-c2048

QMoE achieves impressive results on the SwitchTransformer-c2048 model:

  • Compression: The model size is reduced from 3.2TB in bfloat16 to less than 160GB in QMoE’s compressed format, achieving a 20x compression rate and 0.8 bits per parameter. This is accomplished with only a minor increase in loss on pretraining validation and zero-shot data.
  • Runtime: The compressed model can be efficiently run on commodity hardware like a single server with 4x NVIDIA A6000 or 8x NVIDIA 3090 GPUs. The runtime overhead compared to idealized uncompressed inference is less than 5%.

These results showcase QMoE’s ability to make trillion-parameter models accessible on affordable hardware, paving the way for broader adoption and further research on MoE architectures.

Technical Details: Optimizations and Kernel Design

QMoE incorporates several key optimizations for efficient compression:

  • Optimized Activation Offloading: Carefully orchestrates model execution to minimize memory consumption and transfer costs by offloading main storage from GPU to CPU memory.
  • List Buffer: Employs a list buffer data structure to efficiently support per-sample access and fully-vectorized querying of expert tokens.
  • Lazy Weight Fetching: Fetches weights directly from disk storage only when needed, minimizing memory usage.
  • Expert Grouping: Groups multiple experts together and applies a batched variant of the GPTQ algorithm for improved GPU utilization.

The GPU decoding kernel in QMoE is designed for fast and efficient decompression fused with a matrix-vector product:

  • Parallelization: Each thread block handles multiple rows, with each row processed by a single warp, ensuring good GPU utilization.
  • Execution: The kernel loads the input vector to shared memory for fast access, then processes each row by fetching codewords, extracting weights, and performing product-sum accumulations. Warp-reduction yields the final output.
  • Ternary Decoding: Utilizes a shared memory lookup table to efficiently dequantize ternary weights for multiplication with inputs.

Impact and Future Directions

QMoE represents a significant step forward in making massive MoE models practical for real-world applications. By enabling efficient compression and execution on commodity hardware, QMoE opens doors for:

  • Wider Adoption of MoEs: MoE models can now be deployed in resource-constrained environments, expanding their reach and potential impact.
  • Further Research on MoEs: Easier access to trillion-parameter models facilitates research on understanding and improving MoE architectures.

Future work could explore applying QMoE to other MoE models and variants, finetuning compressed models for downstream tasks, and further optimizing the compression and decoding processes. QMoE’s open-source nature and integration with HuggingFace provide a solid foundation for continued development and exploration in this exciting field.

To read other paper summary, check this page