Matrix multiplication accounts for 84--94% of prompt-processing (prefill) runtime in local large language model (LLM) serving on Apple Silicon. Unified-memory Apple M1--M4 systems are designed with a relatively balanced compute/memory bandwidth ratio that makes using Strassen-Winograd-style sub-cubic matrix multiplication algorithms worthwhile: These algorithms reduce total computation at the expense of extra memory traffic. DropKS is a lightweight wrapper around system GEMM libraries that speeds large (roughly 2,048 x 2,048 and larger) matrix multiplies. It combines an optimized Strassen-Winograd implementation with LLM-specific folding of dequantization into adjacent operators, and corrects an important source of numerical error to which SW algorithms are vulnerable at low precision by selectively peeling rows with large values (<bos> peeling). End to end in mlx-lm, DropKS reduces time-to-first token, or TTFT, in Llama-3 by 5.5--12.3%. On 4-bit and 8-bit quantized 8B (Llama-3) and 27B (Qwen 3.8) models, the combination of techniques it provides reduces TTFT by 8.5--20% while preserving corpus perplexity and token agreement.
翻译:暂无翻译