Abstract
STree introduces the first scalable algorithm for tree-based speculative decoding in State-Space Models (SSMs) and hybrid SSM-Transformer architectures. By mathematically exploiting the structure of modern SSM transition matrices, STree enables the verification of multiple "draft" token paths in a single forward pass. This approach delivers significant speedups with minimal memory overhead compared to traditional methods, addressing the inherent limitations of recurrent state-space models in branching generation scenarios.
Introduction
Large Language Models (LLMs) are typically constrained by sequential token generation. Speculative decoding mitigates this by using a small "draft" model to predict multiple future tokens, which a larger "verifier" model then checks in parallel. Tree-based speculative decoding enhances this by drafting a branching tree of possibilities, increasing the probability of finding a valid sequence.
While effective for Transformers via attention masking, tree-based decoding is challenging for State-Space Models (SSMs) like Mamba. Because SSMs are recurrent, they compress history into a single hidden state. Current implementations must "unroll" every branch into a separate sequence, leading to a "memory explosion" where the model maintains unique states for every path and redundantly processes shared parent tokens.
Methods
STree treats the tree structure as a topological mask rather than a set of independent sequences. The core innovation lies in a mathematical reformulation: modern SSMs (e.g., Mamba-2) utilize diagonal transition matrices ($A$). The authors demonstrate that the output of any node in a token tree can be calculated by accumulating these diagonal matrices along the path to the root.
This formulation allows the representation of the tree structure using a "tree mask" ($L$) to compute a global Atree matrix. To implement this efficiently, the researchers developed a custom hardware-aware GPU "Tree Scan" kernel. This kernel performs the tree-based scan while keeping intermediate calculations in fast shared memory, avoiding the need to instantiate massive hidden states for every branch. Additionally, an "activation replay" method handles backtracking during token rejection by recomputing states from the last known valid token, further saving memory.
Experimental Setup
STree was evaluated across three standard benchmarks: MT-Bench (general instruction following), HumanEval (Python programming), and GSM-8K (math word problems). Testing was conducted using two primary architectures:
- Mamba2-2.7B: A pure SSM model.
- MambaInLlama-8B: A hybrid model consisting of 50% Transformer layers and 50% SSM layers.
Key Results and Insights
STree achieved a 1.74x speedup on MT-Bench over standard autoregressive generation, outperforming vanilla speculative decoding (1.69x). The memory efficiency gains are even more pronounced; for a tree of depth 6, STree requires only 1 hidden state compared to the 32 states required by unrolled baselines.
A critical finding is the "Constant Overhead" advantage. As model size increases, the time spent loading weights dominates runtime. STree exploits this by processing trees of 15–60 tokens with only marginal increases in latency compared to 5-token sequences, significantly boosting the "acceptance length" (tokens generated per step). As shown in Figure 6, the relative overhead of STree decreases as models scale; for a 23B model, the overhead dropped to just 1.26x, suggesting high effectiveness for frontier-scale models.
Conclusion
STree bridges the gap between the efficiency of SSMs and the performance gains of tree-based speculative decoding. By reformulating SSM recurrence as a masked matrix operation, it enables hybrid architectures to leverage the best of both worlds: the long-context efficiency of SSMs and the parallel verification capabilities of Transformers. Future work will explore dynamic tree structures and further optimization for smaller model scales where kernel overhead is more significant.
Summary updated