{"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/fastcache-fast-caching-for-diffusion","title":"FastCache: Fast Caching for Diffusion Transformer Through Learnable Linear Approximation","arxiv_id":"2505.20353","date":"2025-05-26","proceeding":null,"authors":["Dong Liu","Jiayi Zhang","YiFan Li","Yanxuan Yu","Ben Lengerich","Ying Nian Wu"],"abstract":"Diffusion Transformers (DiT) are powerful generative models but remain computationally intensive due to their iterative structure and deep transformer stacks. To alleviate this inefficiency, we propose FastCache, a hidden-state-level caching and compression framework that accelerates DiT inference by exploiting redundancy within the model's internal representations. FastCache introduces a dual strategy: (1) a spatial-aware token selection mechanism that adaptively filters redundant tokens based on hidden state saliency, and (2) a transformer-level cache that reuses latent activations across timesteps when changes are statistically insignificant. These modules work jointly to reduce unnecessary computation while preserving generation fidelity through learnable linear approximation. Theoretical analysis shows that FastCache maintains bounded approximation error under a hypothesis-testing-based decision rule. Empirical evaluations across multiple DiT variants demonstrate substantial reductions in latency and memory usage, with best generation output quality compared to other cache methods, as measured by FID and t-FID. Code implementation of FastCache is available on GitHub at https://github.com/NoakLiu/FastCache-xDiT.","url_abs":"https://arxiv.org/abs/2505.20353v1","url_pdf":"https://arxiv.org/pdf/2505.20353v1.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":"fastcache-fast-caching-for-diffusion","repo_url":"https://github.com/noakliu/fastcache-xdit","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2505.20353","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2505.20353"}},"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/noakliu/fastcache-xdit","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":10},"by_repo_kind":{"official":{"samples":10,"ran":0,"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":"a9a49a40764349d9","entry":"apply_cache","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/fastcache_benchmark.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/fastcache_benchmark.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a9a49a40764349d9"}},{"code_sha256_prefix":"3b5cf7a687be6905","entry":"apply_cache_to_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/cache_execute.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/cache_execute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3b5cf7a687be6905"}},{"code_sha256_prefix":"62df200d97c33d60","entry":"apply_cache_to_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/video_cache_execute.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/video_cache_execute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"62df200d97c33d60"}},{"code_sha256_prefix":"e0f2e1a2e1c02fd8","entry":"get_model_for_method","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/fastcache_benchmark.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/fastcache_benchmark.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e0f2e1a2e1c02fd8"}},{"code_sha256_prefix":"dff9bc3fb36537fc","entry":"load_baseline_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/cache_execution_xfuser.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/cache_execution_xfuser.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"dff9bc3fb36537fc"}},{"code_sha256_prefix":"839fc04bcb78e1d6","entry":"load_fastcache_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/cache_execution_xfuser.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/cache_execution_xfuser.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"839fc04bcb78e1d6"}},{"code_sha256_prefix":"d9dec598d26d6bba","entry":"load_video_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/video_cache_execute.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/video_cache_execute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d9dec598d26d6bba"}},{"code_sha256_prefix":"2d52c251f9bafe3b","entry":"load_xfuser_cache_model","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/cache_execution_xfuser.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/cache_execution_xfuser.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2d52c251f9bafe3b"}},{"code_sha256_prefix":"67fb4b8f0da79649","entry":"run_inference","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/cache_execute.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/cache_execute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"67fb4b8f0da79649"}},{"code_sha256_prefix":"f35b0e7e455b0508","entry":"run_inference","repo":"noakliu/fastcache-xdit","repo_kind":"official","path":"benchmark/video_cache_execute.py","file_url":"https://github.com/noakliu/fastcache-xdit/blob/HEAD/benchmark/video_cache_execute.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f35b0e7e455b0508"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}