TL;DR
Sparton is a custom, high-performance Triton kernel designed to eliminate the massive memory and I/O bottlenecks found in Learned Sparse Retrieval (LSR) models like SPLADE. By mathematically reordering operations and fusing matrix multiplication, activation functions, and max-pooling directly on-chip, Sparton achieves up to a 4.8× speedup and an order-of-magnitude reduction in peak memory usage. This allows researchers to train sparse retrieval models with significantly larger batch sizes and longer sequence lengths without sacrificing retrieval accuracy.
What Problem Does This Paper Address?
Learned Sparse Retrieval (LSR) models bridge the gap between traditional keyword search and deep neural search by projecting a transformer's hidden states into a massive vocabulary space (often ranging from 30,000 to over 250,000 tokens). This projection happens in the Language Modeling (LM) head, which generates a massive intermediate "logits matrix."
In standard deep learning frameworks like PyTorch, computing this matrix creates a severe memory bottleneck. The pipeline executes operations sequentially: it calculates the full logit matrix, writes it to slow global GPU memory (HBM), and then repeatedly reads and writes it back to apply activation functions (ReLU, log1p) and max-pooling. For a standard BERT model, this intermediate matrix alone can demand 16 GB of VRAM, severely limiting the maximum training batch size and throttling throughput. Even PyTorch’s automatic compilation (torch.compile) fails to solve this because it treats matrix multiplication as an unfusable black box.
Methods
The authors introduce Sparton, a fused GPU kernel written in Triton that avoids materializing the full logit matrix in global memory through two key innovations:
- Monotonicity Reordering: The authors observe that the activation function pipeline—$f(x) = \log(1 + \text{ReLU}(x))$—is monotonically non-decreasing. Mathematically, this means that taking the maximum value after the activations is identical to taking the maximum value before them ($\max(f(x)) = f(\max(x))$). Sparton performs the max-reduction immediately on the raw logit tiles, shrinking the data size by a factor of the sequence length ($S$) before activations are ever computed.
- Hybrid Fused Kernel Design: While a fully custom Triton kernel is highly memory-efficient, writing a custom matrix multiplication (GEMM) from scratch often lags behind highly optimized vendor libraries like cuBLAS. Sparton adopts a hybrid approach: it computes tiled logits using optimized vendor libraries, but immediately intercepts the tiles in fast on-chip memory (SRAM) using a custom Triton kernel to perform streaming max-reduction, ReLU, and log1p in a single pass.
For the backward pass, Sparton stores only the max values and their argmax indices, allowing gradients to be scattered directly to the necessary positions and reducing activation storage from $O(BS|V|)$ to $O(B|V|)$.
Datasets
To evaluate Sparton, the authors trained models on the Mistral-Splade dataset using an InfoNCE loss. For evaluation, they benchmarked retrieval effectiveness on a subset of the BEIR benchmark ("small-BEIR"), which includes:
- Arguana
- FiQA
- NFCorpus
- SciDocs
- SciFact
Performance was measured using the standard Average NDCG@10 metric.
Key Insights and Ideas
- Mathematical Properties as Optimization Levers: Exploiting the monotonicity of activation functions allowed the authors to restructure the entire computational graph, reducing data movement by a factor equal to the sequence length (e.g., 512× less data I/O).
- Bypassing the Autograd Tax: Standard PyTorch autograd saves massive intermediate tensors to compute gradients during the backward pass. By custom-writing the backward kernel to only require the max values and argmax indices, Sparton completely bypasses this "tax."
- The Pragmatic Hybrid Approach: Instead of dogmatically forcing everything into a single Triton kernel—which would sacrifice matrix multiplication speed—the authors combined the best of both worlds: vendor-optimized GEMM libraries for raw speed, and custom Triton code for fused reductions.
Key Results
- Isolated Performance: In isolation, the Sparton kernel achieved up to a 4.8× speedup and a 12× reduction in peak memory compared to compiled PyTorch baselines.
- End-to-End Training (Standard Vocab): When integrated into Splade-V3 ($|V| \approx 30\text{k}$), Sparton reduced training memory by nearly 30 GB, enabling a 33% larger batch size and 14% faster training with zero loss in retrieval effectiveness (NDCG@10).
- Multilingual Scaling (Large Vocab): On a multilingual backbone with a 250k token vocabulary, Sparton enabled a massive 26× larger batch size (420 vs. 16) and 2.5× faster training on an H100 GPU.
- Breaking the Length Wall: Standard PyTorch baselines hit an Out-Of-Memory (OOM) wall at sequence lengths of 4096 or 8192. Sparton successfully scaled to a sequence length of 8192 and beyond while utilizing only 5.13 GB of memory.
Limitations and Future Work
While Sparton significantly optimizes the LM head, it still relies on a hybrid design that calls external vendor libraries (cuBLAS/rocBLAS) for the initial tiled matrix multiplication because pure Triton GEMM implementations can lag in raw arithmetic throughput.
For future work, the authors suggest extending Sparton to leverage hardware-specific features found in newer GPU architectures, such as NVIDIA's Tensor Memory Accelerator (TMA) on Hopper/Blackwell architectures, or integrating lower-precision data formats like FP8 to push efficiency boundaries even further.
Summary updated