MPS解码中的非单调延迟:KV缓存交互与执行模式
Non-Monotonic Latency in Apple MPS Decoding: KV Cache Interactions and Execution Regimes
AI总结:
研究发现Apple MPS后端在解码过程中出现非单调延迟现象,通过多个模型验证延迟突增与缓存交互的关系,揭示硬件执行模式对长上下文推理的影响。
摘要:
自回归推理通常假设解码长度与延迟呈可预测的线性关系,但本文发现Apple MPS后端中存在非单调延迟行为,即在接近的解码配置中延迟会突然变化。通过GPT-2、BLOOM和OPT等模型,观察到特定解码预算区间内延迟可达21倍,随后在邻近配置中恢复。受控实验表明,这些异常主要发生在解码阶段而非预填充阶段,且不单纯由内存压力导致,且在CPU和NVIDIA CUDA后端上未出现。进一步研究显示,键值(KV)缓存与这些病理执行模式有强交互:总体上KV缓存仍有益,但在异常配置中速度提升急剧下降,而禁用缓存的解码仍表现出残余的非单调行为。这些发现表明,MPS上的自回归解码进入未被粗粒度基准测试捕捉的离散执行模式,强调了对长上下文推理的硬件感知评估的重要性。
英文摘要:
Autoregressive inference is typically assumed to scale predictably with decoding length, with latency increasing smoothly as generated sequence length grows. In this work, we identify unexpected non-monotonic latency behavior in the Apple MPS backend, where latency changes abruptly across nearby decoding configurations during transformer decoding. Using multiple model families (GPT-2, BLOOM, and OPT), we observe latency spikes of up to 21x within specific decoding-budget intervals, followed by recovery at neighboring configurations. Controlled experiments show that these anomalies originate primarily during the decode phase rather than prefill, are not explained by memory pressure alone, and remain absent on CPU and NVIDIA CUDA backends under identical conditions. We further show that key-value (KV) cache interacts strongly with these pathological execution regimes: KV caching remains beneficial overall, but its practical speedup collapses sharply within anomalous configurations, while cache-disabled decoding still exhibits residual non-monotonic behavior. These findings suggest that autoregressive decoding on MPS enters discrete execution regimes that are not captured by coarse-grained benchmarking, highlighting the importance of hardware-aware evaluation for long-context inference.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。