Papers › TriForce: Lossless Acceleration of Long Sequence Generation with Hierarchical...

TriForce: Lossless Acceleration of Long Sequence Generation with Hierarchical Speculative Decoding

18 Apr 2024arXiv:2404.11912archive 2025-07-28

Hanshi Sun, Zhuoming Chen, Xinyu Yang, Yuandong Tian, Beidi Chen

With large language models (LLMs) widely deployed in long content generation recently, there has emerged an increasing demand for efficient long-sequence inference support. However, key-value (KV) cache, which is stored to avoid re-computation, has emerged as a critical bottleneck by growing linearly in size with the sequence length. Due to the auto-regressive nature of LLMs, the entire KV cache will be loaded for every generated token, resulting in low utilization of computational cores and high latency. While various compression methods for KV cache have been proposed to alleviate this issue, they suffer from degradation in generation quality. We introduce TriForce, a hierarchical speculative decoding system that is scalable for long sequence generation. This approach leverages the original model weights and dynamic sparse KV cache via retrieval as a draft model, which serves as an intermediate layer in the hierarchy and is further speculated by a smaller model to reduce its drafting latency. TriForce not only facilitates impressive speedups for Llama2-7B-128K, achieving up to 2.31× on an A100 GPU but also showcases scalability in handling even longer contexts. For the offloading setting on two RTX 4090 GPUs, TriForce achieves 0.108s/token—only half as slow as the auto-regressive baseline on an A100, which attains 7.78× on our optimized offloading system. Additionally, TriForce performs 4.86× than DeepSpeed-Zero-Inference on a single RTX 4090 GPU. TriForce's robustness is highlighted by its consistently outstanding performance across various temperatures. The code is available at https://github.com/Infini-AI-Lab/TriForce.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2404.11912")

Code

Syntology Ran 5 of 7 code samples harvested from 1 repository linked to this paper; 2 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 2 ran · fixture could not drive it; 2 ran with no contract checked.

By repository: official repository: 7 samples from 1 repository, 5 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Infini-AI-Lab/TriForce officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

7 samples harvested; 5 ran; 0 honoured the contract we drafted; 2 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
2ran · fixture could not drive it
2ran
2unverified

Licence: 7 of the 7 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from Infini-AI-Lab/TriForce. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

repeat_kv Infini-AI-Lab/TriForce/models/tensor_op.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 3c76e52815c5401d · report
apply_rotary_pos_emb Infini-AI-Lab/TriForce/models/tensor_op.py official repository ran · fixture could not drive it no licence file found · pointer only · 0fe82a947dc39b42 · report
apply_rotary_pos_emb_single Infini-AI-Lab/TriForce/models/modeling_llama_68m.py official repository ran no licence file found · pointer only · f101335059827a99 · report
get_sampling_logits Infini-AI-Lab/TriForce/utils/SpecTree_TP.py official repository ran no licence file found · pointer only · e4dedff82f675b83 · report
rotate_half Infini-AI-Lab/TriForce/models/modeling_llama_68m.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · e03d53ba9d4f9ae5 · report
draft_run_capture_graph Infini-AI-Lab/TriForce/utils/graph_infer.py official repository unverified no licence file found · pointer only · c4404a21ff202740 · report
model_verify_capture_graph Infini-AI-Lab/TriForce/utils/graph_infer.py official repository unverified no licence file found · pointer only · aed1de4698a72f4f · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections