{"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/turning-trash-into-treasure-accelerating","title":"Turning Trash into Treasure: Accelerating Inference of Large Language Models with Token Recycling","arxiv_id":"2408.08696","date":"2024-08-16","proceeding":null,"authors":["Xianzhen Luo","YiXuan Wang","Qingfu Zhu","Zhiming Zhang","Xuanyu Zhang","Qing Yang","Dongliang Xu"],"abstract":"Massive parameters of LLMs have made inference latency a fundamental bottleneck. Speculative decoding represents a lossless approach to accelerate inference through a guess-and-verify paradigm. Some methods rely on additional architectures to guess draft tokens, which need extra training before use. Alternatively, retrieval-based training-free techniques build libraries from pre-existing corpora or by n-gram generation. However, they face challenges like large storage requirements, time-consuming retrieval, and limited adaptability. Observing that candidate tokens generated during the decoding process are likely to reoccur in future sequences, we propose Token Recycling. It stores candidate tokens in an adjacency matrix and employs a breadth-first-search (BFS)-like algorithm to construct a draft tree, which is then validated through tree attention. New candidate tokens from the decoding process are then used to update the matrix. Token Recycling requires \\textless2MB of additional storage and achieves approximately 2x speedup across all sizes of LLMs. It significantly outperforms existing train-free methods by 30\\% and even a widely recognized training method by 25\\%.","url_abs":"https://arxiv.org/abs/2408.08696v2","url_pdf":"https://arxiv.org/pdf/2408.08696v2.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":"turning-trash-into-treasure-accelerating","repo_url":"https://github.com/luowaterbi/tokenrecycling","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"turning-trash-into-treasure-accelerating","repo_url":"https://github.com/hemingkx/Spec-Bench","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"turning-trash-into-treasure-accelerating","repo_url":"https://github.com/hyx1999/sam-decoding","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"turning-trash-into-treasure-accelerating","repo_url":"https://github.com/smpanaro/token-recycling","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"retrieval","task_name":"Retrieval"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2408.08696","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.08696"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/luowaterbi/tokenrecycling","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/smpanaro/token-recycling","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hemingkx/Spec-Bench","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hyx1999/sam-decoding","reach":{"status":"ok"}}],"summary":{"ran":5,"ran_draft_wrong":3},"by_repo_kind":{"official":{"samples":6,"ran":6,"repositories":2},"listed":{"samples":2,"ran":2,"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":3,"samples":[{"code_sha256_prefix":"b354a46df3f907b8","entry":"baseline_forward","repo":"hemingkx/Spec-Bench","repo_kind":"official","path":"evaluation/inference_baseline.py","file_url":"https://github.com/hemingkx/Spec-Bench/blob/HEAD/evaluation/inference_baseline.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":"b354a46df3f907b8"}},{"code_sha256_prefix":"11a5f4d33e62670d","entry":"choose_tree_template","repo":"luowaterbi/tokenrecycling","repo_kind":"official","path":"model/recycling/tree_template_.py","file_url":"https://github.com/luowaterbi/tokenrecycling/blob/HEAD/model/recycling/tree_template_.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"11a5f4d33e62670d"}},{"code_sha256_prefix":"a847b79719e8cea9","entry":"ea_forward","repo":"hemingkx/Spec-Bench","repo_kind":"official","path":"evaluation/inference_eagle2.py","file_url":"https://github.com/hemingkx/Spec-Bench/blob/HEAD/evaluation/inference_eagle2.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":"a847b79719e8cea9"}},{"code_sha256_prefix":"57aba3c21a2ebe44","entry":"lookahead_forward","repo":"hemingkx/Spec-Bench","repo_kind":"official","path":"evaluation/inference_lookahead.py","file_url":"https://github.com/hemingkx/Spec-Bench/blob/HEAD/evaluation/inference_lookahead.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":"57aba3c21a2ebe44"}},{"code_sha256_prefix":"54c658b820659f2c","entry":"map_breadthfirst","repo":"smpanaro/token-recycling","repo_kind":"listed","path":"src/token_recycling.py","file_url":"https://github.com/smpanaro/token-recycling/blob/HEAD/src/token_recycling.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"54c658b820659f2c"}},{"code_sha256_prefix":"374944ca8ccfdcbc","entry":"map_depthfirst","repo":"smpanaro/token-recycling","repo_kind":"listed","path":"src/token_recycling.py","file_url":"https://github.com/smpanaro/token-recycling/blob/HEAD/src/token_recycling.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"374944ca8ccfdcbc"}},{"code_sha256_prefix":"ccf07672a5bb126f","entry":"pld_forward","repo":"hemingkx/Spec-Bench","repo_kind":"official","path":"evaluation/inference_pld.py","file_url":"https://github.com/hemingkx/Spec-Bench/blob/HEAD/evaluation/inference_pld.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":"ccf07672a5bb126f"}},{"code_sha256_prefix":"3e8e4782434ee868","entry":"txt_compare","repo":"hemingkx/Spec-Bench","repo_kind":"official","path":"evaluation/equal.py","file_url":"https://github.com/hemingkx/Spec-Bench/blob/HEAD/evaluation/equal.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":"3e8e4782434ee868"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}