SyncAI.news, a Varaisys broadcasting
Tencent Open-Sources DFly2: Speculative Decoding That Reuses the Target’s Sparse KV Cache
AR

Asif Razzaq

· 6 min read

EngineeringMarkTechPost

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

Tencent has open-sourced DFly2, a speculative decoding drafter built for natively sparse LLMs. DFly2 speculative decoding targets models like DeepSeek-V4.1-Flash, GLM-5.3-Flash and Tencent’s own Hy4 flash. Its main approach is that the drafter keeps no KV cache of its own. This is important for long-context and agentic serving, where draft memory competes with concurrency.

TL;DR

  • Size: 0.85B-parameter, 5-layer drafter shipped with Hy4 flash.
  • Runs on: Serving tests used NVIDIA H20 GPUs with vLLM, TP8 per instance. Hy4 flash’s vLLM recipe defaults to 8x H200.
  • Performance: Higher draft acceptance than same-recipe DFlash and DSpark on all 3 targets and all general benchmarks.
  • Best: Up to 81% more throughput on DeepSeek-V4.1-Flash (SWE 64K), at matched per-user speed.
  • Worst: Smallest gain on Hy4 flash general tasks: only 3.9% over DSpark at temperature 0.

What is DFly2?

DFly2 is a block-parallel speculative decoding drafter from Tencent’s Hunyuan AI Infra team. It is described in the research paper ‘DFly2: Turbocharging Long-Context Speculative Decoding by Sharing the Target’s Sparsity‘.

Speculative decoding uses a small drafter to propose tokens. The target verifies them in 1 pass, so output stays lossless. Long context makes this costly. A normal drafter attends over the whole prefix and stores its own KV cache.

How does DFly2 work?

DFly2 pairs each draft layer with one sparse attention layer in the target. It shares 2 things with that layer.

  • KV sharing: the draft layer reads the paired target layer’s latent KV cache.
  • Index sharing: it attends only to positions the target’s indexer already selected (top-k sparse KV).
  • Initialization: each draft layer starts from its paired target layer’s weights.
  • Hidden injection: the target’s last-layer hidden state is gated into the draft block.
  • Intra-block correction: the drafter rereads the shared context slot by slot within a block.

On DeepSeek-V4.1-Flash, a selection made 1 step early covers close to 90% of what later block tokens select. A same-size sliding window recovers less than 20%.

Per the AngelSpec GitHub page, each draft token attends to at most about 2K keys. So drafting cost stays roughly flat at any context length. DFly2 also skips prefill entirely. The prefill-to-decode transfer adds only 1 last-layer hidden state.

How much memory does a separate draft cache cost?

A conventional 3-layer drafter cache would add this much per token (bf16, paper Table 2):

At 32K, removing the drafter’s cache lets the same memory pool hold 1.73x as many requests.

Back&lt;/button&gt;&lt;button class=&quot;btn on&quot; id=&quot;next&quot;&gt;Next step <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/25b6.png" alt="▶" class="wp-smiley" style="height: 1em; max-height: 1em;" />&lt;/button&gt;&lt;button class=&quot;btn&quot; id=&quot;auto&quot;&gt;Auto-play&lt;/button&gt;&lt;/div&gt; &lt;div class=&quot;dg&quot;&gt; &lt;div class=&quot;col&quot;&gt;&lt;h4&gt;Target sparse layers&lt;/h4&gt; &lt;div class=&quot;ly&quot; id=&quot;t1&quot;&gt;Layer k&lt;span class=&quot;kv&quot; id=&quot;kv1&quot;&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;ly&quot; id=&quot;t2&quot;&gt;Layer m&lt;span class=&quot;kv&quot; id=&quot;kv2&quot;&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;ly&quot; id=&quot;t3&quot;&gt;Layer l&lt;span class=&quot;kv&quot; id=&quot;kv3&quot;&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;arc&quot;&gt;&lt;div class=&quot;arw&quot;&gt;&lt;div class=&quot;ar&quot; id=&quot;a1&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;arw&quot;&gt;&lt;div class=&quot;ar&quot; id=&quot;a2&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;arw&quot;&gt;&lt;div class=&quot;ar&quot; id=&quot;a3&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;col&quot;&gt;&lt;h4&gt;DFly2 drafter&lt;/h4&gt; &lt;div class=&quot;ly dr&quot; id=&quot;d1&quot;&gt;Draft 1 · init from k&lt;span&gt;KV + index&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;ly dr&quot; id=&quot;d2&quot;&gt;Draft 2 · init from m&lt;span&gt;KV + index&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;ly dr&quot; id=&quot;d3&quot;&gt;Draft 3 · init from l&lt;span&gt;KV + index&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;tok&quot; id=&quot;tok&quot;&gt;&lt;span&gt;anchor&lt;/span&gt;&lt;span&gt;t1&lt;/span&gt;&lt;span&gt;t2&lt;/span&gt;&lt;span&gt;t3&lt;/span&gt;&lt;span&gt;t4&lt;/span&gt;&lt;span&gt;t5&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;exp&quot; id=&quot;exp&quot;&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;pn&quot; id=&quot;p1&quot;&gt; &lt;div class=&quot;row&quot;&gt;&lt;button class=&quot;btn on&quot; data-m=&quot;std&quot;&gt;Drafter with own cache&lt;/button&gt;&lt;button class=&quot;btn&quot; data-m=&quot;dfly&quot;&gt;DFly2 (shared)&lt;/button&gt;&lt;/div&gt; &lt;div id=&quot;mem&quot;&gt;&lt;/div&gt; &lt;p class=&quot;note&quot;&gt;Per-token KV, bf16, 3-layer drafter (paper Table 2). At 32K, dropping the drafter cache fits 1.73x as many requests in the same memory pool.&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;pn&quot; id=&quot;p2&quot;&gt; &lt;div class=&quot;row&quot; id=&quot;tg&quot;&gt;&lt;button class=&quot;btn on&quot; data-g=&quot;0&quot;&gt;DeepSeek-V4.1-Flash&lt;/button&gt;&lt;button class=&quot;btn&quot; data-g=&quot;1&quot;&gt;GLM-5.3-Flash&lt;/button&gt;&lt;button class=&quot;btn&quot; data-g=&quot;2&quot;&gt;Hy4 flash&lt;/button&gt;&lt;/div&gt; &lt;div class=&quot;row&quot; id=&quot;tp&quot;&gt;&lt;button class=&quot;btn on&quot; data-p=&quot;0&quot;&gt;Temp 0&lt;/button&gt;&lt;button class=&quot;btn&quot; data-p=&quot;1&quot;&gt;Temp 1&lt;/button&gt;&lt;/div&gt; &lt;div id=&quot;acc&quot;&gt;&lt;/div&gt; &lt;p class=&quot;note&quot;&gt;Average accepted length (τ) on general workloads. Baselines retrained by Tencent on the same recipe. Long-context and agentic margins: 10.0% to 31.5% over DSpark.&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;pn&quot; id=&quot;p3&quot;&gt; &lt;div class=&quot;big&quot;&gt; &lt;div class=&quot;st&quot;&gt;&lt;b data-n=&quot;28&quot;&gt;0%&lt;/b&gt;&lt;span&gt;Short text&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;st&quot;&gt;&lt;b data-n=&quot;62&quot;&gt;0%&lt;/b&gt;&lt;span&gt;CodeSpan 64K&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;st&quot;&gt;&lt;b data-n=&quot;81&quot;&gt;0%&lt;/b&gt;&lt;span&gt;SWE 64K&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id=&quot;spd&quot; style=&quot;margin-top:14px&quot;&gt;&lt;/div&gt; &lt;p class=&quot;note&quot;&gt;Top: extra throughput vs DSpark on DeepSeek-V4.1-Flash at matched per-user speed (NVIDIA H20, vLLM). Bottom: end-to-end speedup over target alone, greedy, concurrency 1.&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;ft&quot;&gt;&lt;span&gt;Sources: &lt;a href=&quot;https://arxiv.org/abs/2611.34776&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;DFly2 paper&lt;/a&gt; · &lt;a href=&quot;https://github.com/Tencent/AngelSpec&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;AngelSpec&lt;/a&gt; · &lt;a href=&quot;https://huggingface.co/tencent/Hy4-flash&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hy4 flash&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;mtp&quot;&gt;© Marktechpost&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;script&gt; (function(){ var R=document.getElementById('mtp-dfly2'); function rs(){try{parent.postMessage({mtpH:R.offsetHeight+40,id:'mtp-dfly2'},'*')}catch(e){}} // tabs var tabs=R.querySelectorAll('.tab'); tabs.forEach(function(t){t.onclick=function(){tabs.forEach(function(x){x.classList.remove('on')});t.classList.add('on'); R.querySelectorAll('.pn').forEach(function(p){p.classList.remove('on')});var i=t.dataset.t;document.getElementById('p'+i).classList.add('on'); if(i==1)mem(curM);if(i==2)acc();if(i==3)thr();setTimeout(rs,60);}}); // diagram var picks=[[1,4,7,11],[0,5,6,12],[2,3,9,13]]; for(var k=1;k&lt;=3;k++){var h='';for(var j=0;j&lt;14;j++)h+='&lt;i&gt;&lt;/i&gt;';document.getElementById('kv'+k).innerHTML=h;} var steps=[ 'Prefill runs on the &lt;b&gt;target only&lt;/b&gt;. DFly2 is not involved in prefill, so the handoff adds just 1 last-layer hidden state.', 'Each target sparse layer has an &lt;b&gt;indexer&lt;/b&gt; that picks top-k positions from its KV cache (highlighted). Each draft token reads at most about 2K keys.', '&lt;b&gt;KV sharing + index sharing:&lt;/b&gt; each draft layer reads its paired target layer\'s latent KV and the same picks. No separate draft cache.', 'The drafter fills a &lt;b&gt;block of 5 slots&lt;/b&gt; in parallel. Intra-block correction rereads the shared context slot by slot.', 'The target &lt;b&gt;verifies the whole block in 1 pass&lt;/b&gt;. Accepted tokens (green) are kept, so output stays lossless. Accept counts here are illustrative.']; var s=0,timer=null; function draw(){ for(var k=1;k&lt;=3;k++){var is=document.querySelectorAll('#kv'+k+' i');is.forEach(function(x,j){x.classList.toggle('p',s&gt;=1&amp;&amp;picks[k-1].indexOf(j)&gt;-1)}); document.getElementById('t'+k).classList.toggle('hl',s&gt;=1);document.getElementById('a'+k).classList.toggle('on',s&gt;=2);document.getElementById('d'+k).classList.toggle('hl',s&gt;=2);} var ts=document.querySelectorAll('#tok span');ts.forEach(function(x,j){x.classList.toggle('ok',s&gt;=4&amp;&amp;j&lt;5);x.style.opacity=(s&gt;=3||j==0)?1:.35}); document.getElementById('exp').innerHTML='&lt;b&gt;Step '+(s+1)+' of 5.&lt;/b&gt; '+steps[s];} document.getElementById('next').onclick=function(){s=(s+1)%5;draw()}; document.getElementById('prev').onclick=function(){s=(s+4)%5;draw()}; document.getElementById('auto').onclick=function(){var b=this;if(timer){clearInterval(timer);timer=null;b.classList.remove('on');b.textContent='Auto-play';}else{b.classList.add('on');b.textContent='Pause';timer=setInterval(function(){s=(s+1)%5;draw()},2200);}}; draw(); // bars function bars(el,rows,max,fmt){var h='';rows.forEach(function(r){h+='&lt;div class=&quot;bar&quot;&gt;&lt;span&gt;'+r[0]+'&lt;/span&gt;&lt;div class=&quot;tr&quot;&gt;&lt;div class=&quot;fl'+(r[2]?' me':'')+'&quot; data-w=&quot;'+(r[1]/max*100)+'&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;v&quot;&gt;'+fmt(r[1])+'&lt;/span&gt;&lt;/div&gt;'}); el.innerHTML=h;setTimeout(function(){el.querySelectorAll('.fl').forEach(function(f){f.style.width=f.dataset.w+'%'})},40);} var M=[['DeepSeek-V4.1-Flash',4.4,3.4],['GLM-5.3-Flash',11.7,3.0],['Hy4 flash',17.2,3.4]],curM='std'; function mem(m){curM=m;var rows=[];M.forEach(function(r){var v=m=='std'?r[1]+r[2]:r[1];rows.push([r[0],v,m=='dfly'])}); bars(document.getElementById('mem'),rows,21,function(v){return v.toFixed(1)+' KiB'});} R.querySelectorAll('[data-m]').forEach(function(b){b.onclick=function(){R.querySelectorAll('[data-m]').forEach(function(x){x.classList.remove('on')});b.classList.add('on');mem(b.dataset.m)}}); var A=[[[3.65,3.28],[3.81,3.51],[4.12,3.88]],[[3.43,3.07],[3.68,3.35],[3.96,3.69]],[[3.58,3.48],[3.81,3.73],[3.96,3.95]]],g=0,p=0; function acc(){var a=A[g];bars(document.getElementById('acc'),[['DFlash',a[0][p]],['DSpark',a[1][p]],['DFly2',a[2][p],1]],4.5,function(v){return v.toFixed(2)})} function grp(sel,key,fn){R.querySelectorAll(sel+' .btn').forEach(function(b){b.onclick=function(){R.querySelectorAll(sel+' .btn').forEach(function(x){x.classList.remove('on')});b.classList.add('on');fn(+b.dataset[key]);acc()}})} grp('#tg','g',function(v){g=v});grp('#tp','p',function(v){p=v}); function thr(){R.querySelectorAll('[data-n]').forEach(function(e){var n=+e.dataset.n,c=0;var t=setInterval(function(){c+=Math.ceil(n/20);if(c&gt;=n){c=n;clearInterval(t)}e.textContent='+'+c+'%'},35)}); bars(document.getElementById('spd'),[['DS-V4.1-Flash',2.97,1],['GLM-5.3-Flash',2.36,1],['Hy4 flash',3.19,1]],3.6,function(v){return v.toFixed(2)+'x'})} mem('std');acc(); window.addEventListener('load',rs);window.addEventListener('resize',rs);setTimeout(rs,300); })(); &lt;/script&gt; &lt;/body&gt;&lt;/html&gt; " style="width:100%;height:600px;border:0;display:block;background:#071330;border-radius:14px;" loading="lazy">

DFly2 benchmarks: acceptance, speedup and throughput

All numbers below are self-reported by Tencent. Baselines are DFlash and DSpark retrained on the same recipe.

Average accepted length (τ), general workloads, temp 0 / temp 1:

The margin over the stronger baseline is 3.9% to 10.5% on general workloads. It rises to 10.0% to 31.5% on long-context and agentic workloads up to 128K. On agentic sets, DFly2’s average stays within 4% of its general average. DSpark’s falls by 11% to 21%.

End-to-end speedup (greedy, concurrency 1): 2.97x on DeepSeek-V4.1-Flash, 2.36x on GLM-5.3-Flash, 3.19x on Hy4 flash.

Serving throughput on DeepSeek-V4.1-Flash, matched per-user decode speed vs DSpark:

  • +28% on short text
  • +62% on CodeSpan 64K
  • +81% on SWE 64K

At matched throughput, each user decodes 15% to 24% faster.

Tencent’s announcement adds 3 figures for Hy4 flash agentic tasks. It claims up to 4.2x faster decoding and about 30% over same-recipe DSpark. It also claims 10.4% more accepted tokens than open-source DSpark.

DFly2 vs DSpark vs DFlash

How do you deploy DFly2?

DFly2 ships inside tencent/Hy4-flash, a 220B-total, roughly 12B-active MoE with 1M context. vLLM serves it with the dfly speculative method via vllm/vllm-openai:hy4-flash. SGLang uses the DFLY algorithm via lmsysorg/sglang:hy4-flash. In the vLLM recipe, DFly speculative decoding is on by default.

To train DFly2 for your own sparse model, use AngelSpec. Its quick start expects 1 node with 8 GPUs (4 inference, 4 training).

Key Takeaways

  • DFly2 reuses the target’s sparse KV cache and indexer picks: zero extra draft KV memory.
  • Up to 81% more throughput on DeepSeek-V4.1-Flash at 64K, at matched per-user speed.
  • Beats same-recipe DSpark by 10.0% to 31.5% on long-context and agentic acceptance.
  • Smallest win: 3.9% on Hy4 flash general tasks.
  • Ships in Hy4 flash on vLLM and SGLang; train your own with AngelSpec.

Check out the the paper, grab the code, and get Hy4 flash weights. You can check the deployment options and specs here through our GPULeaderboard.com chrome extension.

Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us

Original source

This story was published by MarkTechPost and written by Asif Razzaq. SyncAI.news shows a preview; the complete article is on the publisher's site.

Read the full story on marktechpost.com

Similar News