FlexGen is a high-throughput inference engine for running large language models when GPU memory is limited. It pools GPU, CPU, and disk memory and compute, then uses linear programming to place and access model tensors efficiently. section 9.1
FlexGen manages the main inference constraints as follows:
- Offloads weights, activations, and the attention KV cache across GPU, CPU, and disk according to an optimized placement policy. section 9.1
- Compresses weights and the attention cache to 4 bits, increasing throughput with negligible accuracy loss. section 9.1 section 9.5
- Trades latency and single-request speed for throughput, making it better suited to batch processing than latency-sensitive serving. section 9.1 section 9.5
Configuring an OPT model
A command such as `python -m flexgen.flex_opt --model facebook/opt-6.7b --percent 50 50 50 50 50 50` configures distributed storage percentages. A Python policy can additionally enable overlapping execution, weight and cache compression, and 4-bit compression settings.
Figure 9.2 Loading a 175 billion–parameter language model with FlexGen across GPU, CPU, and disk
Shows how FlexGen loads a very large model across GPU, CPU, and disk. section 9.1
