arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2603.15854cs.LGcs.AIcs.CL
收藏

FlashSampling:快速且内存高效的精确采样

FlashSampling: Fast and Memory-Efficient Exact Sampling

LMU Munich(慕尼黑大学);Princeton University(普林斯顿大学)

Tomas Ruiz, Zhen Qin, Yifan Zhang, Xuyang Shen, Yiran Zhong, Mengdi Wang

AI总结:

本文提出FlashSampling,一种将采样融合到LM-head矩阵乘法中的精确采样方法,通过芯片内计算和减少内存访问,提升解码效率并降低内存带宽压力。

摘要:

从分类分布中采样在数学上简单,但在大词汇量解码中常引发额外内存交通和内核调用。我们提出了FlashSampling,一种精确采样原语,将采样融合到LM-head矩阵乘法中,从不将logits张量存储在HBM中。方法简单:在芯片内按瓷砖计算logits,添加Gumbel噪声,每行和每个词汇瓷砖保留一个最大值,最后通过小的瓷砖减少完成。在张量并行解码中,FlashSampling用流式peer-to-peer写入替代logits的all-gather,使GPU到GPU通信与计算和HBM加载重叠,最多支持8个GPU,大批次大小时具有接近理想的扩展性。我们的内核是精确的,因为argmax分解在分区中;在线和张量并行设置的变体通过层次化因子分解分类分布而精确。FlashSampling在四种不同的数据中心GPU(H100、H200、B200、B300)上解码工作负载中展示了内核级别的加速,并在端到端vLLM实验中,将模型测试中的每个输出令牌时间减少高达10%。这些结果表明,精确采样(无近似)可以整合到矩阵乘法本身,将带宽受限的采样步骤合并到高效的epilogue中。

英文摘要:

Sampling from a categorical distribution is mathematically simple, but in large-vocabulary decoding, it often triggers extra memory traffic and extra kernels after the LM head. We present FlashSampling, an exact sampling primitive that fuses sampling into the LM-head matmul and never materializes the logits tensor in HBM. The method is simple: compute logits tile-by-tile on chip, add Gumbel noise, keep only one maximizer per row and per vocabulary tile, and finish with a small reduction over tiles. In tensor-parallel decoding, FlashSampling replaces the all-gather of logits with streaming peer-to-peer writes: This overlaps GPU-to-GPU communication with computation and HBM loads across up to 8 GPUs, with near-ideal scaling at large batch sizes. Our kernel is exact because argmax decomposes over partitions; grouped variants for online and tensor-parallel settings are exact by hierarchical factorization of the categorical distribution. FlashSampling demonstrates kernel-level speedups on decode workloads across 4 different datacenter GPUs (H100, H200, B200, B300), and in end-to-end vLLM experiments, it reduces time per output token by up to $10%$ on the models we test. These results show that exact sampling, with no approximation, can be integrated into the matmul itself, consolidating the bandwidth-bound sampling step in an efficient epilogue.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑