When serving a large language model (LLM), it is standard practice to quantize the model to improve speed and reduce memory use. Mixed precision assigns different precisions to different layers, because some layers are more sensitive to quantization than others, and is usually chosen to preserve accuracy within a memory budget. But quantizing a layer also changes how fast it runs, so every layer has both an "accuracy impact" and a "speed impact," and the goal is to choose, for each layer, the precision that best balances the two, often within a memory, speed, or accuracy budget. Many existing allocators estimate the accuracy impact of each layer well, but for the speed impact they rely on proxies such as the layer's size. We argue that the speed impact is more nuanced: it can be limited by compute, weight loading, or key-value (KV) cache access, depending on the phase, batch size, and context length, and it also depends on the hardware and on the kernel that runs each format. Across three hardware classes, we find that 375 of 1,242 measured pairs of configurations ran slower with fewer bytes. To address this, we build a cost model, calibrated once per model, device, and serving stack, that predicts the latency of any configuration across operating points and anticipates these slowdowns, which byte-based estimates cannot. We then use it in place of the byte-based time cost inside existing allocators, keeping their accuracy measurements unchanged. Where bytes misjudge speed, the allocators select configurations with up to 52% lower latency. Finally, because the cost model's latency estimates change with the operating point, the allocators choose different configurations at different operating points, and we measure how much is gained by changing precision as the device, batch size, phase, and context change.
翻译:暂无翻译