Researchers from Stanford and UC Berkeley Introduce TokenGate: Token-Gated Attention Makes Long-Context Prefill Up to 11.3x Faster

2026年10月25日 12:12
站內 AI 整理稿

Stanford and UC Berkeley researchers released TokenGate, a module for long-context prefill.TokenGate learned token pruning lets an existing LLM skim its input.Only the tokens that matter get full processing.The research team reports 1.4x to 11.

3x faster time-to-first-token (TTFT) with no accuracy loss.Peak prefill memory drops 1.5x to 3.4x.Code and checkpoints are on GitHub under Apache-2.0.TL;DR MLP gate: A small MLP gate and LoRA (r=16) added to Qwen3-1.7B or Qwen3.5-2B.Tested on contexts up to 128k tokens.

Runs on: Paper timings use 1 A100 at batch size 1.Training used 4 A100s.Performance: Pareto-optimal on 5 tasks against 6 baselines.Best: NIAH 16k at 11.3x faster TTFT and 3.42x lower memory.TTFT gain hits 13.0x at 128k.Worst: Speedup drops to 1.4x on some tasks.What is TokenGate?

TokenGate is a drop-in component that adds trainable token pruning to pretrained LLMs.Transformers push every token through every layer.Attention cost grows quadratically with length.Training-free pruning is cheap but loses accuracy at high pruning rates.

Architectural changes often need pre-training from scratch.How does TokenGate learned token pruning work?The forward pass splits into 3 phases: Standard forward: layers below gate layer L process all N tokens as usual.Gate module: an MLP scores each token from its post-attention residual at layer L.

A top-K selector keeps the highest-scoring tokens.Pruned forward: layers above L process only those K tokens and never create KV entries for pruned ones.Only the document part of the prompt is prunable.The question is never pruned.What is token-gated attention?

Top-K selection is not differentiable, which blocks end-to-end training.TokenGate borrows the Mixture-of-Experts router trick.Each kept token’s score becomes a bias on attention logits above the gate.That bias gives gradients a path back to the scorer.

A learnable per-head gain and a learnable temperature refine this.The temperature corrects for each query seeing fewer keys.Training uses plain next-token loss.Each step averages a full-context loss and a random-budget loss.So 1 trained gate works across budgets.window.

addEventListener("message",function(e){if(e.data&&e.data.mtpH){var f=document.getElementById("mtp-tg-frame");if(f&&e.source===f.contentWindow){f.style.height=e.data.mtpH+"px";}}}); #mtp-tg-wrap hr,#mtp-tg-wrap p:empty,#mtp-tg-wrap del,#mtp-tg-wrap s{display:none!

important} How does TokenGate perform on benchmarks?The research team tested Qwen3-1.7B on RepoBench-P, 2WikiMultihopQA, MultiNews, BioDEX and needle-in-a-haystack (NIAH).Baselines were FastKV, SlimInfer, DASH, GemFilter, FlexPrefill and MInference, on the same LoRA backbone.Versus full prefill: 1.

4x to 11.3x faster TTFT and 1.5x to 3.4x lower memory.Versus the next-best baseline: 1.2x to 6.4x faster TTFT and up to 2.1x lower memory.2WikiMultihopQA: at 95% of full-context accuracy, prefill runs 3.0x faster with 2.7x less memory.Longer contexts: a gate trained at 16k reaches 12.

8x at 32k and 13.0x at 64k and 128k.Memory savings stay near 3.43x.The learned selector beats FastKV’s heuristic at the same layer.Even random-K selection scores higher on the TokenGate backbone.The research team credits backbone co-adaptation.Does it work on hybrid-attention models?Yes, Qwen3.

5-2B mixes Gated DeltaNet and full-attention layers.On NIAH 32k, TokenGate at layer 3 matched full-prefill accuracy.It ran 3.8x faster than full prefill and 2.1x faster than FastKV.Gating at layers 1 or 2 reached 7.8x, within 6% accuracy.FastKV can only prune attention layers.

TokenGate vs FastKV, SlimInfer, GemFilter and DASH FeatureTokenGateFastKVSlimInferGemFilterDASHToken selectionLearned MLP gateAttention from last queriesBlock attention, multi-stageLast-query attention at filter layerHidden-state stabilityTraining neededYes (gate + LoRA r=16)NoNoNoNoPruning layer in TokenGate’s Qwen3-1.

7B runs113 (default)8, 17, 251211Prunes at Gated DeltaNet layersYesNo (attention layers only)Not disclosedNot disclosedNot disclosedBest self-reported prefill gain (own setup)11.3x TTFT, 3.4x memory1.82x prefill2.53x TTFT (LLaMA3.1-8B, RTX 4090)2.

4x speed, 30% less GPU memory vs SOTANot disclosedCodeGitHubGitHubGitHubGitHubAnnounced Self-reported gains use different setups, so they are not directly comparable.Pruning layers come from TokenGate’s Appendix C.2.How do you deploy TokenGate?The GitHub Repo needs Python 3.10+ and CUDA PyTorch 2.

9+.An optional FlashAttention-2 key-bias kernel speeds up dense Qwen3.It costs 1.0x to 1.1x a plain call.Without it, inference falls back to FlexAttention.A {state} placeholder marks the prunable document.generate takes a maxkeptprefill_tokens budget.Checkpoints cover all 5 tasks on Qwen3-1.

7B, plus a Qwen3.5-2B NIAH gate.Example: liana313/tokengate-niah-qwen3-1.7b.Training mirrors a TRL/PEFT recipe.Each step is 1.3x slower than plain LoRA.Runs converged faster on 4 of 5 tasks.Mean training time was 1.8 versus 2.2 A100 hours.

Key Takeaways TokenGate adds learned token pruning to existing LLMs via a small gate and LoRA.Prefill runs 1.4x to 11.3x faster with 1.5x to 3.4x lower peak memory.Token-gated attention makes top-K selection trainable, MoE-router style.It beats the next-best pruning baseline by up to 6.4x on TTFT.

It works on hybrid Qwen3.5-2B, where FastKV cannot prune DeltaNet layers.Check out the Paper, GitHub repo and Hugging Face paper page.Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter.Wait!are you on telegram?

now you can join us on telegram as well.Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.?Connect with us The post Researchers from Stanford and UC Berkeley Introduce TokenGate: Token-Gated Attention Makes Long-Context Prefill Up to 11.

3x Faster appeared first on MarkTechPost.

Related

相關文章

智東西生成式AI

英特爾與騰訊發佈基於至強6+的雲實例,曬智能體AI基礎設施全家桶

作者 | ZeR0 編輯 | 漠影 11月3日報道,近日,在2026騰訊全球數字生態大會上,英特爾與騰訊雲發佈基於英特爾至強6+處理器的騰訊雲新一代雲實例,並全面展示英特爾的芯片產品與雲端實踐。 全新至強6+處理器擁有最高288顆能效核,單顆處理器最高可支持超過1000個智能體的穩定部署,這也為騰訊雲服務器提供更高併發、更低時延、更優能效的雲端算力服務。

2 小時前
雷峰網生成式AI

智元榮獲2026世界互聯網大會傑出貢獻獎

11月3日,2026年世界互聯網大會烏鎮峰會在浙江烏鎮隆重開幕,國務院總理李強出席開幕式並發表主旨演講。開幕式上,智元憑藉在具身智能領域的系統性技術突破與產業化實踐,獲頒世界互聯網大會傑出貢獻獎。智元合夥人、高級副總裁朱潔在領獎時表示:人工智能的終局,不在於屏幕與雲端,而紮根於工廠一線和尋常煙火。具身智能賽道的競爭,早已跳出單點技術的競速,轉向軟硬協同、工程化落地、產業組織與治理體系的綜合比拼。智元期待與各界同心同行,堅守務實,躬身落地。

2 小時前

電動車退燒、AI 儲能燒起來:LG 新能源把產能挪向數據中心

11 月 3 日,首席財務官李昌植在財報電話會上給出時間表:今年底軟包儲能系統(ESS)產能將超 50 吉瓦時,明年進一步拉到 70 GWh 以上。在他看來,電動車增速放緩之際,AI 數據中心的大規模新建為電池廠撕開了新口子——第三季度 ESS 在手訂單已達 160 GWh,公司正與電力企業、超大型數據中心運營商談新項目,今年 9 月還作為儲能供應商擠進了英偉達的 DSX Ready 計劃。

2 小時前4700
雷峰網生成式AI

最高288核的至強6+,為了Agent高密度部署還下了哪些「雲功夫」?

作者 | 陳悅琳編輯 | 包永剛 一個智能體能順利完成任務,不代表成百上千個智能體就能同時高效運行。 對於承載大量智能體任務的雲服務器而言,除了提升計算速度,如何在任務集中到來時迅速準備好執行環境、怎樣減少暫時閒置的任務對內存資源的佔用,也成為亟待解決的問題。 對此,在一年一度的騰訊全球數字生態大會上,英特爾與騰訊雲聯合發佈了基於至強6+處理器的新一代雲實例,圍繞任務啟動效率、內存資源利用率等關鍵因素進行優化後,其綜合性能較上一代提升30%以上。

3 小時前

聯合國副秘書長點贊!千問AI耳夾式耳機亮相烏鎮互聯網大會

他認為,產品非常實用,適合自己日常工作中需要使用多國語言進行交流的場景。面對面交流時,用戶可以通過耳機收聽譯文;會議中的討論內容,也能通過AI聽記整理為結構化紀要,方便會後回顧。連接千問App後,用戶還可通過語音交辦資料研究等任務、接收完成提醒,讓耳機成為日常辦公的隨身助手。

3 小時前