{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/recurrent-drafter-for-fast-speculative","title":"Recurrent Drafter for Fast Speculative Decoding in Large Language Models","arxiv_id":"2403.09919","date":"2024-03-14","proceeding":null,"authors":["Yunfei Cheng","Aonan Zhang","Xuanyu Zhang","Chong Wang","Yi Wang"],"abstract":"We present Recurrent Drafter (ReDrafter), an advanced speculative decoding approach that achieves state-of-the-art speedup for large language models (LLMs) inference. The performance gains are driven by three key aspects: (1) leveraging a recurrent neural network (RNN) as the draft model conditioning on LLM's hidden states, (2) applying a dynamic tree attention algorithm over beam search results to eliminate duplicated prefixes in candidate sequences, and (3) training through knowledge distillation from the LLM. ReDrafter accelerates Vicuna inference in MT-Bench by up to 2.8x with a PyTorch implementation on Nvidia H100 GPUs. To demonstrate its practicality in real environments, we also validated its effectiveness for on-device applications by implementing the approach in MLX and benchmarking performance on Metal GPUs in Apple Silicon chips, achieving up to 2.3x speedup.","url_abs":"https://arxiv.org/abs/2403.09919v5","url_pdf":"https://arxiv.org/pdf/2403.09919v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"recurrent-drafter-for-fast-speculative","repo_url":"https://github.com/apple/ml-recurrent-drafter","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"benchmarking","task_name":"Benchmarking"},{"task_slug":"knowledge-distillation","task_name":"Knowledge Distillation"}],"methods":[{"method_slug":"knowledge-distillation","method_name":"Knowledge Distillation"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2403.09919","atlas_url":"https://app.syntology.ai/?focus=2403.09919","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.09919"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/apple/ml-recurrent-drafter","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":9},"by_repo_kind":{"official":{"samples":9,"ran":9,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"498726ff0c6569f1","entry":"apply_rotary_pos_emb","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/modeling_llama.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/modeling_llama.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"498726ff0c6569f1"}},{"code_sha256_prefix":"b6b2e19c2f35f52c","entry":"bias","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/attention.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b6b2e19c2f35f52c"}},{"code_sha256_prefix":"27fa8c790e9b0a65","entry":"causal_mask","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/attention.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"27fa8c790e9b0a65"}},{"code_sha256_prefix":"71388070a79766cc","entry":"find_all_sublists","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/chat.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/chat.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"71388070a79766cc"}},{"code_sha256_prefix":"846fc0050b3da25e","entry":"maintain_logits","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/modeling_drafter.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/modeling_drafter.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"846fc0050b3da25e"}},{"code_sha256_prefix":"c881b0be09c0a906","entry":"set_sdpa_fully_masked_rows","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/attention.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c881b0be09c0a906"}},{"code_sha256_prefix":"8d4fdd4b3a5b8461","entry":"standardize_sharegpt","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/chat.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/chat.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8d4fdd4b3a5b8461"}},{"code_sha256_prefix":"24dc61540a0c5424","entry":"vicuna_prompt","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/chat.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/chat.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"24dc61540a0c5424"}},{"code_sha256_prefix":"b232bab56ac1225f","entry":"warp_logits","repo":"apple/ml-recurrent-drafter","repo_kind":"official","path":"recurrent_drafting/modeling_drafter.py","file_url":"https://github.com/apple/ml-recurrent-drafter/blob/HEAD/recurrent_drafting/modeling_drafter.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b232bab56ac1225f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}