Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Ruiz, Tomas, Qin, Zhen, Zhang, Yifan, Shen, Xuyang, Zhong, Yiran, Wang, Mengdi
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:https://arxiv.org/abs/2603.15854
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866911676665692160
author Ruiz, Tomas
Qin, Zhen
Zhang, Yifan
Shen, Xuyang
Zhong, Yiran
Wang, Mengdi
author_facet Ruiz, Tomas
Qin, Zhen
Zhang, Yifan
Shen, Xuyang
Zhong, Yiran
Wang, Mengdi
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2603_15854
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle FlashSampling: Fast and Memory-Efficient Exact Sampling
Ruiz, Tomas
Qin, Zhen
Zhang, Yifan
Shen, Xuyang
Zhong, Yiran
Wang, Mengdi
Machine Learning
Artificial Intelligence
Computation and Language
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.
title FlashSampling: Fast and Memory-Efficient Exact Sampling
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2603.15854