{"id":16271936,"url":"https://github.com/horseee/learning-to-cache","last_synced_at":"2025-09-24T08:31:38.586Z","repository":{"id":242735198,"uuid":"809587634","full_name":"horseee/learning-to-cache","owner":"horseee","description":"[NeurIPS 2024] Learning-to-Cache: Accelerating Diffusion Transformer via Layer Caching","archived":false,"fork":false,"pushed_at":"2024-07-15T03:49:52.000Z","size":5581,"stargazers_count":88,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-08T14:30:06.324Z","etag":null,"topics":["diffusion-models","efficient-inference"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/horseee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-03T04:04:32.000Z","updated_at":"2025-01-07T02:48:21.000Z","dependencies_parsed_at":"2024-07-15T04:55:10.331Z","dependency_job_id":null,"html_url":"https://github.com/horseee/learning-to-cache","commit_stats":null,"previous_names":["horseee/learning-to-cache"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horseee%2Flearning-to-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horseee%2Flearning-to-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horseee%2Flearning-to-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horseee%2Flearning-to-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/horseee","download_url":"https://codeload.github.com/horseee/learning-to-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234059163,"owners_count":18773047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diffusion-models","efficient-inference"],"created_at":"2024-10-10T18:15:25.386Z","updated_at":"2025-09-24T08:31:37.926Z","avatar_url":"https://github.com/horseee.png","language":"Python","funding_links":[],"categories":["Accelerate"],"sub_categories":[],"readme":"# Learning-to-Cache: Accelerating Diffusion Transformer via Layer Caching\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/teaser.png\" width=\"100%\" \u003e\u003c/img\u003e\n  \u003cbr\u003e\n  \u003cem\u003e\n      (Results on DiT-XL/2 and U-ViT-H/2) \n  \u003c/em\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\u003e **Learning-to-Cache: Accelerating Diffusion Transformer via Layer Caching**   🥯[[Arxiv]](https://arxiv.org/abs/2406.01733)    \n\u003e [Xinyin Ma](https://horseee.github.io/), [Gongfan Fang](https://fangggf.github.io/), [Michael Bi Mi](), [Xinchao Wang](https://sites.google.com/site/sitexinchaowang/)   \n\u003e [Learning and Vision Lab](http://lv-nus.org/), National University of Singapore, Huawei Technologies Ltd  \n\n\n\n\n## Introduction\nWe introduce a novel scheme, named **L**earning-to-**C**ache (L2C), that learns to conduct caching in a dynamic manner for diffusion transformers. A router is optimized to decide the layers to be cached. \n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"U-ViT/u-vit.gif\" width=\"40%\" \u003e\u003c/img\u003e\n  \u003cbr\u003e\n  \u003cem\u003e\n      (Changes in the router for U-ViT when optimizing across different layers (x-axis) over all steps (y-axis). The white indicates the layer is activated, while the black indicates it is disabled.) \n  \u003c/em\u003e\n\u003c/div\u003e\n\n\n**Some takeaways**:\n\n1. A large proportion of layers in the diffusion transformer can be removed, without updating the model parameters.\n   - In U-ViT-H/2, up to 93.68% of the layers in the cache steps (46.84% for all steps) can be removed, with less than 0.01 drop in FID. \n\n2. L2C largely outperforms samplers such as DDIM and DPM-Solver. \n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/dit_baseline.png\" width=\"40%\" \u003e\u003c/img\u003e\n  \u003cimg src=\"assets/uvit_baseline.png\" width=\"40%\" \u003e\u003c/img\u003e\n  \u003cbr\u003e\n  \u003cem\u003e\n      (Comparison with Baselines. Left: DiT-XL/2. Right: U-ViT-H/2)\n  \u003c/em\u003e\n\u003c/div\u003e\n\n## Checkpoint for Routers\n| Model | NFE | Checkpoint |\n| -- | -- | -- |\n| DiT-XL/2 |  50 | [link](DiT/ckpt/DDIM50_router.pt) |\n| DiT-XL/2 |  20 | [link](DiT/ckpt/DDIM20_router.pt) |\n| U-ViT-H/2 |  50 | [link](U-ViT/ckpt/dpm50_router.pth) |\n| U-ViT-H/2 |  20 | [link](U-ViT/ckpt/dpm20_router.pth)|\n\n## Code\nWe implement Learning-to-Cache on two basic structures: DiT and U-ViT. Check the instructions below:\n\n1. DiT: [README](https://github.com/horseee/learning-to-cache/tree/main/DiT#learning-to-cache-for-dit)\n2. U-ViT: [README](https://github.com/horseee/learning-to-cache/blob/main/U-ViT/readme.md)\n\n## Citation\n```\n@misc{ma2024learningtocache,\n      title={Learning-to-Cache: Accelerating Diffusion Transformer via Layer Caching}, \n      author={Xinyin Ma and Gongfan Fang and Michael Bi Mi and Xinchao Wang},\n      year={2024},\n      eprint={2406.01733},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorseee%2Flearning-to-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorseee%2Flearning-to-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorseee%2Flearning-to-cache/lists"}