{"id":15030660,"url":"https://github.com/siliconflow/onediff","last_synced_at":"2025-05-13T18:07:09.188Z","repository":{"id":60179957,"uuid":"539362736","full_name":"siliconflow/onediff","owner":"siliconflow","description":"OneDiff: An out-of-the-box acceleration library for diffusion models.","archived":false,"fork":false,"pushed_at":"2025-05-08T08:59:44.000Z","size":119473,"stargazers_count":1884,"open_issues_count":127,"forks_count":124,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-05-12T07:18:48.937Z","etag":null,"topics":["aigc-serving","comfyui","comfyui-workflow","cuda","diffusers","diffusion-models","inference-engine","lcm","lcm-lora","lora","performance-optimization","pytorch","sd-webui","sdxl","sdxl-turbo","stable-diffusion","stable-video-diffusion"],"latest_commit_sha":null,"homepage":"https://github.com/siliconflow/onediff/wiki","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"huggingface/diffusers","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siliconflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-21T07:34:13.000Z","updated_at":"2025-05-11T20:30:50.000Z","dependencies_parsed_at":"2023-12-25T02:23:42.760Z","dependency_job_id":"de35bfc2-cc1d-49ee-8ce3-e779af8cf12e","html_url":"https://github.com/siliconflow/onediff","commit_stats":{"total_commits":571,"total_committers":30,"mean_commits":"19.033333333333335","dds":0.7460595446584939,"last_synced_commit":"9231f556a7b77d36b29b07cffd2a93143de2fb98"},"previous_names":["oneflow-inc/onediff","siliconflow/onediff"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siliconflow%2Fonediff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siliconflow%2Fonediff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siliconflow%2Fonediff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siliconflow%2Fonediff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siliconflow","download_url":"https://codeload.github.com/siliconflow/onediff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253692565,"owners_count":21948322,"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":["aigc-serving","comfyui","comfyui-workflow","cuda","diffusers","diffusion-models","inference-engine","lcm","lcm-lora","lora","performance-optimization","pytorch","sd-webui","sdxl","sdxl-turbo","stable-diffusion","stable-video-diffusion"],"created_at":"2024-09-24T20:13:58.983Z","updated_at":"2025-05-13T18:07:09.170Z","avatar_url":"https://github.com/siliconflow.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","图像生成"],"sub_categories":["资源传输下载"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"imgs/onediff_logo.png\" height=\"100\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/onediff\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/onediff\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pypistats.org/packages/onediff\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/pypi/dm/onediff?style=square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff?tab=Apache-2.0-1-ov-file#readme\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/license/siliconflow/onediff\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff/issues?q=is%3Aissue+is%3Aclosed\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-closed/siliconflow/onediff?color=blue\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff/issues?q=is%3Aopen+is%3Aissue\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/siliconflow/onediff\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff/stargazers\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/siliconflow/onediff?style=square\u0026label=Stars\u0026color=green\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/search?q=%22onediff%22\u0026src=typed_query\u0026f=live\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Twitter-Discuss-green?logo=twitter\u0026amp\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff/actions/workflows/sd.yml\" target=\"_blank\"\u003e\u003cimg src=\"https://github.com/siliconflow/onediff/actions/workflows/sd.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/siliconflow/onediff/actions/workflows/examples.yml?query=event%3Aschedule\" target=\"_blank\"\u003e\u003cimg src=\"https://github.com/siliconflow/onediff/actions/workflows/examples.yml/badge.svg?event=schedule\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  | \u003ca href=\"https://github.com/siliconflow/onediff?tab=readme-ov-file#documentation\"\u003e\u003cb\u003eDocumentation\u003c/b\u003e\u003c/a\u003e | \u003ca href=\"https://github.com/siliconflow/onediff/wiki\"\u003e\u003cb\u003eCommunity\u003c/b\u003e\u003c/a\u003e | \u003ca href=\"https://github.com/siliconflow/onediff/wiki/Contribution-Guide\"\u003e\u003cb\u003eContribution\u003c/b\u003e\u003c/a\u003e | \u003ca href=\"https://discord.gg/RKJTjZMcPQ\"\u003e\u003cb\u003eDiscord\u003c/b\u003e\u003c/a\u003e |\n\u003c/p\u003e\n\n---\n\n**onediff** is an out-of-the-box acceleration library for diffusion models, it provides:\n- Out-of-the-box **acceleration** for popular UIs/libs(such as **HF diffusers** and **ComfyUI**)\n- PyTorch code **compilation tools** and strong optimized **GPU Kernels** for diffusion models\n\n## News\n- [2024/07/23] :rocket: Up to 1.7x Speedup for Kolors: [Kolors Acceleration Report](https://github.com/siliconflow/onediff/tree/main/onediff_diffusers_extensions/examples/kolors)\n- [2024/06/18] :rocket: Acceleration for DiT models: [SD3 Acceleration Report](https://github.com/siliconflow/onediff/tree/main/onediff_diffusers_extensions/examples/sd3), [PixArt Acceleration Report](https://github.com/siliconflow/onediff/tree/main/onediff_diffusers_extensions/examples/pixart), and [Latte Acceleration Report](https://github.com/siliconflow/onediff/tree/main/onediff_diffusers_extensions/examples/latte)\n- [2024/04/13] :rocket: [OneDiff 1.0 is released (Acceleration of SD \u0026 SVD with one line of code)](https://www.reddit.com/r/StableDiffusion/comments/1c5gy1e/onediff_10_is_out_acceleration_of_sd_svd_with_one/)\n- [2024/01/12] :rocket: [Accelerating Stable Video Diffusion 3x faster with OneDiff DeepCache + Int8](https://www.reddit.com/r/StableDiffusion/comments/1adu2hn/accelerating_stable_video_diffusion_3x_faster/)\n- [2023/12/19] :rocket: [Accelerating SDXL 3x faster with DeepCache and OneDiff](https://www.reddit.com/r/StableDiffusion/comments/18lz2ir/accelerating_sdxl_3x_faster_with_deepcache_and/)\n\n## Hiring\nWe're hiring! If you are interested in working on onediff at SiliconFlow, we have roles open for [Interns](https://www.shixiseng.com/intern/inn_o2c63agwogc7) and [Engineers](https://www.zhipin.com/mpa/html/weijd/weijd-job/e03542c584120a261HN70ty7F1pW) in Beijing (near Tsinghua University).\n\nIf you have contributed significantly to open-source software and are interested in remote work, you can contact us at `talent@siliconflow.cn` with `onediff` in the email title.\n\n---\n\u003c!-- toc --\u003e\n- [Documentation](#documentation)\n  * [Use with HF diffusers and ComfyUI](#use-with-hf-diffusers-and-comfyui)\n  * [Performance comparison](#performance-comparison)\n    + [SDXL E2E time](#sdxl-e2e-time)\n    + [SVD E2E time](#svd-e2e-time)\n  * [Quality Evaluation](#quality-evaluation)\n  * [Community and Support](#community-and-support)\n  * [Installation](#installation)\n    + [0. OS and GPU Compatibility](#0-os-and-gpu-compatibility)\n    + [1. Install torch and diffusers](#1-install-torch-and-diffusers)\n    + [2. Install a compiler backend](#2-install-a-compiler-backend)\n      - [Nexfort](#nexfort)\n      - [OneFlow](#oneflow)\n    + [3. Install onediff](#3-install-onediff)\n- [More about onediff](#more-about-onediff)\n  * [Architecture](#architecture)\n  * [Features](#features)\n  * [Acceleration for State-of-the-art models](#acceleration-for-state-of-the-art-models)\n  * [Acceleration for production environment](#acceleration-for-production-environment)\n    + [PyTorch Module compilation](#pytorch-module-compilation)\n    + [Avoid compilation time for new input shape](#avoid-compilation-time-for-new-input-shape)\n    + [Avoid compilation time for online serving](#avoid-compilation-time-for-online-serving)\n    + [Distributed Run](#distributed-run)\n  * [OneDiff Enterprise Solution](#onediff-enterprise-solution)\n\u003c!-- tocstop --\u003e\n\n## Documentation\nonediff is the abbreviation of \"**one** line of code to accelerate **diff**usion models\".\n\n### Use with HF diffusers and ComfyUI\n- [onediff for HF diffusers 🤗](https://github.com/siliconflow/onediff/tree/main/onediff_diffusers_extensions)\n- [onediff for ComfyUI](https://github.com/siliconflow/onediff/tree/main/onediff_comfy_nodes)\n- [onediff for Stable Diffusion web UI](https://github.com/siliconflow/onediff/tree/main/onediff_sd_webui_extensions)\n\n### Performance comparison\n\n\u003cimg src=\"imgs/replace_a100.png\" height=\"400\"\u003e\n\n#### SDXL E2E time\n- Model stabilityai/stable-diffusion-xl-base-1.0;\n- Image size 1024*1024, batch size 1, steps 30;\n- NVIDIA A100 80G SXM4;\n\n\u003cimg src=\"imgs/0_12_sdxl.png\" height=\"400\"\u003e\n\n#### SVD E2E time\n- Model stabilityai/stable-video-diffusion-img2vid-xt;\n- Image size 576*1024, batch size 1, steps 25, decoder chunk size 5;\n- NVIDIA A100 80G SXM4;\n\n\u003cimg src=\"imgs/0_12_svd.png\" height=\"400\"\u003e\n\nNote that we haven't got a way to run SVD with TensorRT on Feb 29 2024.\n\n### Quality Evaluation\nWe also maintain a repository for benchmarking the quality of generation after acceleration: [odeval](https://github.com/siliconflow/odeval)\n\n### Community and Support\n- [Create an issue](https://github.com/siliconflow/onediff/issues)\n- Chat in Discord: [![](https://dcbadge.vercel.app/api/server/RKJTjZMcPQ?style=plastic)](https://discord.gg/RKJTjZMcPQ)\n- [Community and Feedback](https://github.com/siliconflow/onediff/wiki)\n\n### Installation\n#### 0. OS and GPU Compatibility\n- Linux\n  - If you want to use onediff on Windows, please use it under WSL.\n  - [The guide to install onediff in WSL2](https://github.com/siliconflow/onediff/wiki/Run-OneDiff-on-Windows-by-WSL2).\n- NVIDIA GPUs\n  - [Compatibility with Nvidia GPUs](https://github.com/siliconflow/onediff/wiki/Compatibility-with-Nvidia-GPUs).\n\n\n#### 1. Install torch and diffusers\n**Note: You can choose the latest versions you want for diffusers or transformers.**\n```\npython3 -m pip install \"torch\" \"transformers==4.27.1\" \"diffusers[torch]==0.19.3\"\n```\n\n#### 2. Install a compiler backend\nWhen considering the choice between OneFlow and Nexfort, either one is optional, and only one is needed.\n\n- For DiT structural models or H100 devices, it is recommended to use Nexfort.\n\n- For all other cases, it is recommended to use OneFlow. Note that optimizations within OneFlow will gradually transition to Nexfort in the future.\n\n##### Nexfort\nInstall Nexfort is Optional.\nThe detailed introduction of Nexfort is [here](https://github.com/siliconflow/onediff/tree/main/src/onediff/infer_compiler/backends/nexfort#readme).\n\n```bash\npython3 -m  pip install -U torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 torchao==0.1\npython3 -m  pip install -U nexfort\n```\n\n##### OneFlow\nInstall OneFlow is Optional.\n\u003e **_NOTE:_** We have updated OneFlow frequently for onediff, so please install OneFlow by the links below.\n\n- **CUDA 11.8**\n\n  For NA/EU users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://github.com/siliconflow/oneflow_releases/releases/expanded_assets/community_cu118\n  ```\n\n  For CN users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu118\n  ```\n\n\n\u003cdetails\u003e\n\u003csummary\u003e Click to get OneFlow packages for other CUDA versions. \u003c/summary\u003e\n\n- **CUDA 12.1**\n\n  For NA/EU users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://github.com/siliconflow/oneflow_releases/releases/expanded_assets/community_cu122\n  ```\n\n  For CN users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu122\n  ```\n\n\n- **CUDA 12.2**\n\n  For NA/EU users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://github.com/siliconflow/oneflow_releases/releases/expanded_assets/community_cu122\n  ```\n  For CN users\n  ```bash\n  python3 -m pip install -U --pre oneflow -f https://oneflow-pro.oss-cn-beijing.aliyuncs.com/branch/community/cu122\n  ```\n\n\u003c/details\u003e\n\n\n#### 3. Install onediff\n\n- From PyPI\n```\npython3 -m pip install --pre onediff\n```\n- From source\n```\ngit clone https://github.com/siliconflow/onediff.git\n```\n```\ncd onediff \u0026\u0026 python3 -m pip install -e .\n```\nOr install for development:\n```\n# install for dev\ncd onediff \u0026\u0026 python3 -m pip install -e '.[dev]'\n\n# code formatting and linting\npip3 install pre-commit\npre-commit install\npre-commit run --all-files\n```\n\n\u003e **_NOTE:_** If you intend to utilize plugins for ComfyUI/StableDiffusion-WebUI, we highly recommend installing OneDiff from the source rather than PyPI. This is necessary as you'll need to manually copy (or create a soft link) for the relevant code into the extension folder of these UIs/Libs.\n\n## More about onediff\n### Architecture\n\u003cimg src=\"imgs/onediff_arch.png\" height=\"500\"\u003e\n\n### Features\n\n| Functionality | Details |\n|----------------|----------------------------|\n| Compiling Time   | About 1 minute (SDXL) |\n| Deployment Methods              | Plug and Play |\n| Dynamic Image Size Support  | Support with no overhead |\n| Model Support                 | SD1.5~2.1, SDXL, SDXL Turbo, etc. |\n| Algorithm Support             | SD standard workflow, LoRA, ControlNet, SVD, InstantID, SDXL Lightning, etc. |\n| SD Framework Support | ComfyUI, Diffusers, SD-webui |\n| Save \u0026 Load Accelerated Models | Yes |\n| Time of LoRA Switching | Hundreds of milliseconds |\n| LoRA Occupancy | Tens of MB to hundreds of MB. |\n| Device Support | NVIDIA GPU 3090 RTX/4090 RTX/A100/A800/A10 etc. (Compatibility with Ascend in progress) |\n\n\n### Acceleration for State-of-the-art models\nonediff supports the acceleration for SOTA models.\n* stable: release for public usage, and has long-term support;\n* beta: release for professional usage, and has long-term support;\n* alpha: early release for expert usage, and should be careful to use;\n\n| AIGC Type | Models                      | HF diffusers |            | ComfyUI   |            | SD web UI |            |\n| --------- | --------------------------- | ------------ | ---------- | --------- | ---------- | --------- | ---------- |\n|           |                             | Community    | Enterprise | Community | Enterprise | Community | Enterprise |\n| Image     | SD 1.5                      | stable       | stable     | stable    | stable     | stable    | stable     |\n|           | SD 2.1                      | stable       | stable     | stable    | stable     | stable    | stable     |\n|           | SDXL                        | stable       | stable     | stable    | stable     | stable    | stable     |\n|           | LoRA                        | stable       |            | stable    |            | stable    |            |\n|           | ControlNet                  | stable       |            | stable    |            |           |            |\n|           | SDXL Turbo                  | stable       |            | stable    |            |           |            |\n|           | LCM                         | stable       |            | stable    |            |           |            |\n|           | SDXL DeepCache              | alpha        | alpha      | alpha     | alpha      |           |            |\n|           | InstantID                   | beta         |            | beta      |            |           |            |\n| Video     | SVD(stable Video Diffusion) | stable       | stable     | stable    | stable     |           |            |\n|           | SVD DeepCache               | alpha        | alpha      | alpha     | alpha      |           |            |\n\n### Acceleration for production environment\n#### PyTorch Module compilation\n- [compilation with oneflow_compile](https://github.com/siliconflow/onediff/blob/main/onediff_diffusers_extensions/examples/text_to_image_sdxl.py)\n#### Avoid compilation time for new input shape\n- [Support Multi-resolution input](https://github.com/siliconflow/onediff/blob/main/onediff_diffusers_extensions/examples/text_to_image_sdxl.py)\n#### Avoid compilation time for online serving\nCompile and save the compiled result offline, then load it online for serving\n- [Save and Load the compiled graph](https://github.com/siliconflow/onediff/blob/main/onediff_diffusers_extensions/examples/text_to_image_sdxl_save_load.py)\n- Compile at one device(such as device 0), then use the compiled result to other device(such as device 1~7). [Change device of the compiled graph to do multi-process serving](https://github.com/siliconflow/onediff/blob/main/onediff_diffusers_extensions/examples/text_to_image_sdxl_mp_load.py)\n#### Distributed Run\nIf you want to do distributed inference, you can use onediff's compiler to do single-device acceleration in a distributed inference engine such as [xDiT](https://github.com/xdit-project/xDiT)\n\n### OneDiff Enterprise Solution\nIf you need Enterprise-level Support for your system or business, you can email us at contact@siliconflow.com, or contact us through the website: https://siliconflow.cn/pricing\n|                                                          | Onediff Enterprise Solution                      |\n| -------------------------------------------------------- | ------------------------------------------------ |\n| More extreme compiler optimization for diffusion process | Usually another 20%~30% or more performance gain |\n| End-to-end workflow speedup solutions                    | Sometimes 200%~300% performance gain             |\n| End-to-end workflow deployment solutions                 | Workflow to online model API                     |\n| Technical support for deployment                         | High priority support                            |\n\n## Citation\n```bibtex\n@misc{2022onediff,\n  author={OneDiff Contributors},\n  title = {OneDiff: An out-of-the-box acceleration library for diffusion models},\n  year = {2022},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/siliconflow/onediff}}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiliconflow%2Fonediff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiliconflow%2Fonediff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiliconflow%2Fonediff/lists"}