Tencent Open-Sources DFly2: Speculative Decoding That Reuses the Target’s Sparse KV Cache

2026-11-27 03:31

Tencent has officially open-sourced DFly2, an innovative speculative decoding drafter specifically engineered for natively sparse Large Language Models (LLMs). Developed by the Hunyuan AI Infra team, this technology aims to solve the memory bottlenecks often associated with long-context and agentic AI serving. By enabling a drafter to operate without its own dedicated Key-Value (KV) cache, DFly2 significantly improves throughput and efficiency for models like DeepSeek-V4.1-Flash, GLM-5.3-Flash, and Tencent’s own Hy4 flash.

In traditional speculative decoding, a smaller ‘drafter’ model generates token sequences that are then verified by a larger ’target’ model in a single pass, ensuring the output remains lossless. However, as context lengths grow, maintaining a separate KV cache for the drafter becomes prohibitively expensive in terms of memory, often limiting concurrency. DFly2 addresses this by pairing each draft layer with a corresponding sparse attention layer in the target model. Instead of storing its own data, the drafter reads the target layer’s latent KV cache and utilizes the same top-k indexer selections, effectively eliminating the need for additional draft KV memory.

The architecture of DFly2 is highly optimized for performance. It features a 0.85B-parameter, 5-layer design that leverages hidden state injection and intra-block correction to maintain high accuracy. By sharing context slots and utilizing the target model’s sparse attention patterns, the drafter can achieve high acceptance rates even at extreme context lengths. For instance, on the DeepSeek-V4.1-Flash model, a selection made one step early covers nearly 90% of the tokens selected by later block tokens, a significant improvement over standard sliding window approaches.

Performance metrics reported by Tencent highlight the efficacy of this approach. In tests conducted on NVIDIA H20 GPUs, DFly2 demonstrated substantial gains over existing baselines like DFlash and DSpark. On the DeepSeek-V4.1-Flash model at a 64K context length, DFly2 achieved up to an 81% increase in serving throughput while maintaining matched per-user decode speeds. Furthermore, the removal of the drafter’s cache allows the system to accommodate 1.73 times as many requests within the same memory pool at a 32K context length.

Beyond raw throughput, DFly2 excels in long-context and agentic workloads. While traditional drafters often see a performance drop when shifting from general tasks to complex agentic scenarios, DFly2 maintains stability, with its average accepted token length remaining within 4% of its general performance. This makes it particularly well-suited for applications requiring deep reasoning and extended interaction windows.

DFly2 is currently integrated into the tencent/Hy4-flash repository, a 220B-total MoE model with a 1M context capacity. It is supported by major serving frameworks, including vLLM and SGLang, where it can be deployed via specific recipes. For developers looking to adapt DFly2 for their own sparse models, Tencent has provided the AngelSpec toolkit, which facilitates the training process. By rethinking how drafters interact with target model memory, Tencent’s DFly2 represents a significant step forward in making high-performance, long-context LLM inference more accessible and scalable.