Abstract
Inferflow is an open-source, modular inference engine designed to simplify the deployment of Large Language Models (LLMs) through a zero-code configuration approach. By treating model architectures as compositions of atomic building blocks, Inferflow allows users to serve new models without modifying source code. The engine introduces a novel 3.5-bit quantization scheme that bridges the performance gap between 3-bit and 4-bit methods, and a hybrid partitioning strategy to optimize multi-GPU inference in bandwidth-constrained environments.
Introduction
The rapid evolution of Large Language Model (LLM) architectures has created a significant engineering burden. Most existing inference engines require "hard-coding" support for new models, necessitating manual implementation of specific normalization functions or attention mechanisms. Inferflow addresses this by providing a modular framework where new architectures can be defined via simple configuration files.
Methodology
Modular Framework of Atomic Building Blocks
Inferflow moves away from model-specific scripts (e.g., modeling_llama.py) in favor of "atomic" modules. These include standardized implementations of normalization functions (e.g., RMSNorm), activation functions (e.g., SwiGLU), and position embeddings (e.g., RoPE). Serving a new model involves specifying which blocks it utilizes in a JSON-like configuration file, enabling "compositional generalizability."
3.5-bit Quantization
To balance memory efficiency and model accuracy, Inferflow introduces a 3.5-bit quantization scheme. While standard 3-bit quantization uses 8 levels ($2^3$), Inferflow uses a 7-bit integer to represent two adjacent weights. This allows for $11 \times 11 = 121$ states (fitting within the 128 states of 7 bits), effectively providing 11 quantization levels per weight, or approximately 3.46 bits. This mathematical compromise aims to avoid the significant accuracy degradation often seen when dropping from 4-bit to 3-bit quantization.
Hybrid Model Partitioning
Traditional multi-GPU strategies often force a choice between high-latency pipeline parallelism and high-bandwidth tensor parallelism. Inferflow implements a hybrid approach that assigns specific layers and attention heads across devices. This strategy is particularly effective for hardware setups with lower interconnect speeds, balancing decoding speed and overall throughput.
Evaluation and Results
The engine's performance was evaluated using the Wikitext-2 dataset to measure perplexity across several models, including Bloom-3B, LLAMA2-7B/13B, and Falcon-40B.
Key Findings
- Quantization Quality: Results on LLAMA2-13B demonstrate that the 3.5-bit (Q3H) scheme achieves a perplexity of 6.897. This is a marked improvement over the 7.278 recorded for 3-bit quantization and approaches the 4-bit baseline of 6.514.
- Inference Efficiency: On a 4x NVIDIA Tesla V100 setup, the Hybrid Partitioning strategy achieved a throughput of 24 tokens/s. This significantly outperformed standard tensor-wise partitioning (12 tokens/s) and provided a superior balance compared to layer-wise partitioning, which suffered from low decoding speeds (8 tokens/s).
- Security and Extensibility: Inferflow includes a custom C++ pickle parser to load PyTorch
.binfiles safely, avoiding the security risks of executing arbitrary Python code during model loading.
Conclusion
Inferflow demonstrates that LLM serving can be made both highly efficient and easily extensible through modular design and innovative quantization. By finding the "sweet spot" in bit-depth and optimizing multi-GPU communication, it provides a robust platform for deploying diverse model architectures. Future work will focus on integrating speculative decoding and automating the optimal assignment of layers in hybrid partitioning setups.
Summary updated