SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.11912 · 2024

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

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 7 functions out of this paper's own repositories and ran 5 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
Infini-AI-Lab/TriForce canonical 5 of 7
FunctionStatusWhere it lives
repeat_kv Ran Infini-AI-Lab/TriForce/models/tensor_op.py
pointer only (licence: NONE) · get_code("3c76e52815c5401d")
apply_rotary_pos_emb Ran Infini-AI-Lab/TriForce/models/tensor_op.py
pointer only (licence: NONE) · get_code("0fe82a947dc39b42")
apply_rotary_pos_emb_single Ran Infini-AI-Lab/TriForce/models/modeling_llama_68m.py
pointer only (licence: NONE) · get_code("f101335059827a99")
get_sampling_logits Ran Infini-AI-Lab/TriForce/utils/SpecTree_TP.py
pointer only (licence: NONE) · get_code("e4dedff82f675b83")
rotate_half Ran Infini-AI-Lab/TriForce/models/modeling_llama_68m.py
pointer only (licence: NONE) · get_code("e03d53ba9d4f9ae5")
draft_run_capture_graph Not yet run Infini-AI-Lab/TriForce/utils/graph_infer.py
pointer only (licence: NONE) · get_code("c4404a21ff202740")
model_verify_capture_graph Not yet run Infini-AI-Lab/TriForce/utils/graph_infer.py
pointer only (licence: NONE) · get_code("aed1de4698a72f4f")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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$\times$ 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$\unicode{x2014}$only half as slow as the auto-regressive baseline on an A100, which attains 7.78$\times$ on our optimized offloading system. Additionally, TriForce performs 4.86$\times$ 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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2404.11912")
get_code_for_paper("2404.11912")
have("2404.11912")

Connect an agent — have() is free.