[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-mit-han-lab--distrifuser":3,"tool-mit-han-lab--distrifuser":62},[4,18,26,35,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":86,"forks":87,"last_commit_at":88,"license":89,"difficulty_score":10,"env_os":90,"env_gpu":91,"env_ram":90,"env_deps":92,"category_tags":98,"github_topics":99,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":105,"updated_at":106,"faqs":107,"releases":143},7057,"mit-han-lab\u002Fdistrifuser","distrifuser","[CVPR 2024 Highlight] DistriFusion: Distributed Parallel Inference for High-Resolution Diffusion Models","distrifuser 是一款专为高分辨率扩散模型设计的分布式并行推理加速工具，曾入选 CVPR 2024 亮点论文。它主要解决了在生成超高清图像（如 3840×3840 分辨率）时，单张显卡显存不足或计算速度过慢的瓶颈问题。\n\n传统的多卡并行方案往往简单地将图片切割分配给不同显卡，导致拼接处出现明显的断裂痕迹；而 distrifuser 通过独特的“同步通信初始化 + 异步通信复用”机制，让不同显卡在处理图像块时能高效交换信息。这种方法不仅彻底消除了拼接伪影，保证了生成图像的视觉质量与单卡运行一致，还能将通信耗时隐藏在计算过程中，显著提升效率。实测显示，在使用 8 张 NVIDIA A100 显卡生成超大图时，其速度可提升高达 6.1 倍。\n\n该工具无需重新训练模型即可直接使用，已集成至 NVIDIA TensorRT-LLM 和 ColossalAI 等主流框架。它非常适合需要快速生成高质量大图的 AI 研究人员、开发者以及专业设计师，帮助他们在多显卡环境下轻松突破分辨率与速度的限制。","# DistriFusion: Distributed Parallel Inference for High-Resolution Diffusion Models\n\n### [Paper](http:\u002F\u002Farxiv.org\u002Fabs\u002F2402.19481) | [Project](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fdistrifusion) | [Blog](https:\u002F\u002Fhanlab.mit.edu\u002Fblog\u002Fdistrifusion) | [Slides](https:\u002F\u002Fwww.dropbox.com\u002Fscl\u002Ffi\u002Fyv98hi2kdoh27ej4jqlbp\u002Fslides.key?rlkey=3rmfxpezqt3co5x2hgqvxv09i&st=ve4z9w6t&dl=0) | [Youtube](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=EZX7srDDmW0&list=PL80kAHvQbh-pKRxcSS6xjds7U7Yc0gDQI&index=1) | [Poster](https:\u002F\u002Fwww.dropbox.com\u002Fscl\u002Ffi\u002Flabhefjwi9r01e3o9eob0\u002Fposter.pdf?rlkey=rjj1jj179enln92h8kygrftmg&st=0ddego10&dl=0)\n\n**[Dec 1, 2024]** DistriFusion is integrated in NVIDIA's [TensorRT-LLM](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FTensorRT-LLM\u002Fblob\u002Fmain\u002Fexamples\u002Fsdxl\u002FREADME.md) for distributed inference on high-resolution image generation.\n\n**[Jul 29, 2024]** DistriFusion is supported in [ColossalAI](https:\u002F\u002Fgithub.com\u002Fhpcaitech\u002FColossalAI\u002Fblob\u002Fmain\u002Fcolossalai\u002Finference\u002FREADME.md)!\n\n**[Apr 4, 2024]** DistriFusion is selected as a **highlight** poster in CVPR 2024!\n\n**[Feb 29, 2024]** DistriFusion is accepted by CVPR 2024! Our code is publicly available!\n\n![teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_9a0759947cd1.jpg)\n*We introduce DistriFusion, a training-free algorithm to harness multiple GPUs to accelerate diffusion model inference without sacrificing image quality. Naïve Patch (Overview (b)) suffers from the fragmentation issue due to the lack of patch interaction. The presented examples are generated with SDXL using a 50-step Euler sampler at 1280×1920 resolution, and latency is measured on A100 GPUs.*\n\nDistriFusion: Distributed Parallel Inference for High-Resolution Diffusion Models\u003C\u002Fbr>\n[Muyang Li](https:\u002F\u002Flmxyy.me\u002F)\\*, [Tianle Cai](https:\u002F\u002Fwww.tianle.website\u002F)\\*, [Jiaxin Cao](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjiaxin-cao-2166081b3\u002F), [Qinsheng Zhang](https:\u002F\u002Fqsh-zh.github.io), [Han Cai](https:\u002F\u002Fhan-cai.github.io), [Junjie Bai](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjunjiebai\u002F), [Yangqing Jia](https:\u002F\u002Fdaggerfs.com), [Ming-Yu Liu](https:\u002F\u002Fmingyuliu.net), [Kai Li](https:\u002F\u002Fwww.cs.princeton.edu\u002F~li\u002F), and [Song Han](https:\u002F\u002Fhanlab.mit.edu\u002Fsonghan)\u003C\u002Fbr>\nMIT, Princeton, Lepton AI, and NVIDIA\u003C\u002Fbr>\nIn CVPR 2024.\n\n## Overview\n![idea](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_ecb18c62b56e.jpg)\n**(a)** Original diffusion model running on a single device. **(b)** Naïvely splitting the image into 2 patches across 2 GPUs has an evident seam at the boundary due to the absence of interaction across patches. **(c)** Our DistriFusion employs synchronous communication for patch interaction at the first step. After that, we reuse the activations from the previous step via asynchronous communication. In this way, the communication overhead can be hidden into the computation pipeline.\n\n## Performance\n### Speedups\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_37a0db872071.jpg\" width=\"80%\"\u002F>\n\u003C\u002Fp>Measured total latency of DistriFusion with SDXL using a 50-step DDIM sampler for generating a single image across on NVIDIA A100 GPUs. When scaling up the resolution, the GPU devices are better utilized. Remarkably, when generating 3840×3840 images, DistriFusion achieves 1.8×, 3.4× and 6.1× speedups with 2, 4, and 8 A100s, respectively.\n\n\n\n### Quality\n\n![quality](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_43b39c7922cd.jpg)\nQualitative results of SDXL. FID is computed against the ground-truth images. Our DistriFusion can reduce the latency according to the number of used devices while preserving visual fidelity.\n\nReferences:\n\n* Denoising Diffusion Implicit Model (DDIM), Song *et al.*, ICLR 2021\n* Elucidating the Design Space of Diffusion-Based Generative Models, Karras *et al.*, NeurIPS 2022\n* Parallel Sampling of Diffusion Models, Shih *et al.*, NeurIPS 2023\n* SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis, Podell *et al.*, ICLR 2024\n\n## Prerequisites\n\n* Python3\n* NVIDIA GPU + CUDA >= 12.0 and corresponding CuDNN\n* [PyTorch](https:\u002F\u002Fpytorch.org) = 2.2.\n\n## Getting Started\n\n### Installation\n\nAfter installing [PyTorch](https:\u002F\u002Fpytorch.org), you should be able to install `distrifuser` with PyPI\n\n```shell\npip install distrifuser\n```\n\nor via GitHub:\n\n```shell\npip install git+https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser.git\n```\n\nor locally for development\n\n```shell\ngit clone git@github.com:mit-han-lab\u002Fdistrifuser.git\ncd distrifuser\npip install -e .\n```\n\n### Usage Example\n\nIn  [`scripts\u002Fsdxl_example.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fsdxl_example.py), we provide a minimal script for running [SDXL](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fen\u002Fusing-diffusers\u002Fsdxl) with DistriFusion. \n\n```python\nimport torch\n\nfrom distrifuser.pipelines import DistriSDXLPipeline\nfrom distrifuser.utils import DistriConfig\n\ndistri_config = DistriConfig(height=1024, width=1024, warmup_steps=4)\npipeline = DistriSDXLPipeline.from_pretrained(\n    distri_config=distri_config,\n    pretrained_model_name_or_path=\"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    variant=\"fp16\",\n    use_safetensors=True,\n)\n\npipeline.set_progress_bar_config(disable=distri_config.rank != 0)\nimage = pipeline(\n    prompt=\"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k\",\n    generator=torch.Generator(device=\"cuda\").manual_seed(233),\n).images[0]\nif distri_config.rank == 0:\n    image.save(\"astronaut.png\")\n```\n\nSpecifically, our `distrifuser` shares the same APIs as [diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers) and can be used in a similar way. You just need to define a `DistriConfig` and use our wrapped `DistriSDXLPipeline` to load the pretrained SDXL model. Then, we can generate the image like the  `StableDiffusionXLPipeline` in [diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers). The running command is\n\n```shell\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Fsdxl_example.py\n```\n\nwhere `$N_GPUS` is the number GPUs you want to use.\n\nWe also provide a minimal script for running SD1.4\u002F2 with DistriFusion in [`scripts\u002Fsd_example.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fsd_example.py). The usage is the same.\n\n### Benchmark\n\nOur benchmark results are using [PyTorch](https:\u002F\u002Fpytorch.org) 2.2 and [diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers) 0.24.0. First, you may need to install some additional dependencies:\n\n```shell\npip install git+https:\u002F\u002Fgithub.com\u002Fzhijian-liu\u002Ftorchprofile datasets torchmetrics dominate clean-fid\n```\n\n#### COCO Quality\n\nYou can use [`scripts\u002Fgenerate_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fgenerate_coco.py) to generate images with COCO captions. The command is\n\n```\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Fgenerate_coco.py --no_split_batch\n```\n\nwhere `$N_GPUS` is the number GPUs you want to use. By default, the generated results will be stored in `results\u002Fcoco`. You can also customize it with `--output_root`. Some additional arguments that you may want to tune:\n\n* `--num_inference_steps`: The number of inference steps. We use 50 by default.\n* `--guidance_scale`: The classifier-free guidance scale. We use 5 by default.\n* `--scheduler`: The diffusion sampler. We use [DDIM sampler](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fv0.26.3\u002Fen\u002Fapi\u002Fschedulers\u002Fddim#ddimscheduler) by default. You can also use `euler` for [Euler sampler](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fv0.26.3\u002Fen\u002Fapi\u002Fschedulers\u002Feuler#eulerdiscretescheduler) and `dpm-solver` for [DPM solver](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fen\u002Fapi\u002Fschedulers\u002Fmultistep_dpm_solver).\n* `--warmup_steps`: The number of additional warmup steps (4 by default). \n* `--sync_mode`: Different GroupNorm synchronization modes. By default, it is using our corrected asynchronous GroupNorm.\n* `--parallelism`: The parallelism paradigm you use. By default, it is patch parallelism. You can use `tensor` for tensor parallelism and `naive_patch` for naïve patch.\n\nAfter you generate all the images, you can use our script [`scripts\u002Fcompute_metrics.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fcompute_metrics.py) to calculate PSNR, LPIPS and FID. The usage is \n\n```shell\npython scripts\u002Fcompute_metrics.py --input_root0 $IMAGE_ROOT0 --input_root1 $IMAGE_ROOT1\n```\n\nwhere `$IMAGE_ROOT0` and `$IMAGE_ROOT1` are paths to the image folders you are trying to compare. If `IMAGE_ROOT0` is the ground-truth foler, please add a `--is_gt` flag for resizing. We also provide a script [`scripts\u002Fdump_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fdump_coco.py) to dump the ground-truth images.\n\n#### Latency\n\nYou can use  [`scripts\u002Frun_sdxl.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Frun_sdxl.py) to benchmark the latency our different methods. The command is\n\n```shell\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Frun_sdxl.py --mode benchmark --output_type latent\n```\n\nwhere `$N_GPUS` is the number GPUs you want to use. Similar to [`scripts\u002Fgenerate_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fgenerate_coco.py), you can also change some arguments:\n\n* `--num_inference_steps`: The number of inference steps. We use 50 by default.\n* `--image_size`: The generated image size. By default, it is 1024×1024.\n* `--no_split_batch`: Disable the batch splitting for classifier-free guidance.\n* `--warmup_steps`: The number of additional warmup steps (4 by default). \n* `--sync_mode`: Different GroupNorm synchronization modes. By default, it is using our corrected asynchronous GroupNorm.\n* `--parallelism`: The parallelism paradigm you use. By default, it is patch parallelism. You can use `tensor` for tensor parallelism and `naive_patch` for naïve patch.\n* `--warmup_times`\u002F`--test_times`: The number of warmup\u002Ftest runs. By default, they are 5 and 20, respectively.\n\n\n## Citation\n\nIf you use this code for your research, please cite our paper.\n\n```bibtex\n@inproceedings{li2023distrifusion,\n  title={DistriFusion: Distributed Parallel Inference for High-Resolution Diffusion Models},\n  author={Li, Muyang and Cai, Tianle and Cao, Jiaxin and Zhang, Qinsheng and Cai, Han and Bai, Junjie and Jia, Yangqing and Liu, Ming-Yu and Li, Kai and Han, Song},\n  booktitle={Proceedings of the IEEE\u002FCVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n  year={2024}\n}\n```\n\n## Acknowledgments\n\nOur code is developed based on [huggingface\u002Fdiffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers) and [lmxyy\u002Fsige](https:\u002F\u002Fgithub.com\u002Flmxyy\u002Fsige). We thank [torchprofile](https:\u002F\u002Fgithub.com\u002Fzhijian-liu\u002Ftorchprofile) for MACs measurement, [clean-fid](https:\u002F\u002Fgithub.com\u002FGaParmar\u002Fclean-fid) for FID computation and [Lightning-AI\u002Ftorchmetrics](https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Ftorchmetrics) for PSNR and LPIPS.\n\nWe thank Jun-Yan Zhu and Ligeng Zhu for their helpful discussion and valuable feedback. The project is supported by MIT-IBM Watson AI Lab, Amazon, MIT Science Hub, and National Science Foundation.\n","# DistriFusion：高分辨率扩散模型的分布式并行推理\n\n### [论文](http:\u002F\u002Farxiv.org\u002Fabs\u002F2402.19481) | [项目](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fdistrifusion) | [博客](https:\u002F\u002Fhanlab.mit.edu\u002Fblog\u002Fdistrifusion) | [幻灯片](https:\u002F\u002Fwww.dropbox.com\u002Fscl\u002Ffi\u002Fyv98hi2kdoh27ej4jqlbp\u002Fslides.key?rlkey=3rmfxpezqt3co5x2hgqvxv09i&st=ve4z9w6t&dl=0) | [YouTube](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=EZX7srDDmW0&list=PL80kAHvQbh-pKRxcSS6xjds7U7Yc0gDQI&index=1) | [海报](https:\u002F\u002Fwww.dropbox.com\u002Fscl\u002Ffi\u002Flabhefjwi9r01e3o9eob0\u002Fposter.pdf?rlkey=rjj1jj179enln92h8kygrftmg&st=0ddego10&dl=0)\n\n**[2024年12月1日]** DistriFusion已被集成到NVIDIA的[TensorRT-LLM](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FTensorRT-LLM\u002Fblob\u002Fmain\u002Fexamples\u002Fsdxl\u002FREADME.md)中，用于高分辨率图像生成的分布式推理。\n\n**[2024年7月29日]** DistriFusion现已支持[ColossalAI](https:\u002F\u002Fgithub.com\u002Fhpcaitech\u002FColossalAI\u002Fblob\u002Fmain\u002Fcolossalai\u002Finference\u002FREADME.md)！\n\n**[2024年4月4日]** DistriFusion被选为CVPR 2024的**亮点**海报！\n\n**[2024年2月29日]** DistriFusion已被CVPR 2024接收！我们的代码已公开！\n\n![teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_9a0759947cd1.jpg)\n*我们提出了DistriFusion，这是一种无需训练的算法，能够利用多张GPU加速扩散模型的推理，同时不牺牲图像质量。朴素的分块方法（概述(b)）由于缺乏补丁之间的交互而存在碎片化问题。所展示的例子是使用SDXL和50步欧拉采样器在1280×1920分辨率下生成的，延迟是在A100 GPU上测量的。*\n\nDistriFusion：高分辨率扩散模型的分布式并行推理\u003C\u002Fbr>\n[Muyang Li](https:\u002F\u002Flmxyy.me\u002F)\\*, [Tianle Cai](https:\u002F\u002Fwww.tianle.website\u002F)\\*, [Jiaxin Cao](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjiaxin-cao-2166081b3\u002F)，[Qinsheng Zhang](https:\u002F\u002Fqsh-zh.github.io)，[Han Cai](https:\u002F\u002Fhan-cai.github.io)，[Junjie Bai](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjunjiebai\u002F)，[Yangqing Jia](https:\u002F\u002Fdaggerfs.com)，[Ming-Yu Liu](https:\u002F\u002Fmingyuliu.net)，[Kai Li](https:\u002F\u002Fwww.cs.princeton.edu\u002F~li\u002F)，以及[Song Han](https:\u002F\u002Fhanlab.mit.edu\u002Fsonghan)\u003C\u002Fbr>\n麻省理工学院、普林斯顿大学、Lepton AI和NVIDIA\u003C\u002Fbr>\n发表于CVPR 2024。\n\n## 概述\n![idea](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_ecb18c62b56e.jpg)\n**(a)** 原始扩散模型在单个设备上运行。**(b)** 将图像简单地分成2个补丁并在2张GPU上处理时，由于补丁之间缺乏交互，边界处会出现明显的接缝。**(c)** 我们的DistriFusion在第一步中采用同步通信来实现补丁间的交互。之后，我们通过异步通信复用前一步的激活值。这样，通信开销可以隐藏在计算流水线中。\n\n## 性能\n### 加速比\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_37a0db872071.jpg\" width=\"80%\"\u002F>\n\u003C\u002Fp>使用50步DDIM采样器，在NVIDIA A100 GPU上使用SDXL生成单张图像时，DistriFusion的总延迟测量结果。随着分辨率的提高，GPU设备的利用率也会更高。值得注意的是，在生成3840×3840图像时，使用2、4和8张A100 GPU时，DistriFusion分别实现了1.8倍、3.4倍和6.1倍的加速。\n\n### 质量\n\n![quality](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_readme_43b39c7922cd.jpg)\nSDXL的定性结果。FID是与真实图像对比计算得出的。我们的DistriFusion可以根据使用的设备数量减少延迟，同时保持视觉保真度。\n\n参考文献：\n\n* 去噪扩散隐式模型（DDIM），Song *et al.*，ICLR 2021\n* 阐明基于扩散的生成模型的设计空间，Karras *et al.*，NeurIPS 2022\n* 扩散模型的并行采样，Shih *et al.*，NeurIPS 2023\n* SDXL：改进潜在扩散模型以用于高分辨率图像合成，Podell *et al.*，ICLR 2024\n\n## 先决条件\n\n* Python3\n* NVIDIA GPU + CUDA >= 12.0 及对应的CuDNN\n* [PyTorch](https:\u002F\u002Fpytorch.org) = 2.2。\n\n## 快速入门\n\n### 安装\n\n安装[PyTorch](https:\u002F\u002Fpytorch.org)后，您可以通过PyPI安装`distrifuser`\n\n```shell\npip install distrifuser\n```\n\n或者通过GitHub安装：\n\n```shell\npip install git+https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser.git\n```\n\n也可以在本地进行开发：\n\n```shell\ngit clone git@github.com:mit-han-lab\u002Fdistrifuser.git\ncd distrifuser\npip install -e .\n```\n\n### 使用示例\n\n在[`scripts\u002Fsdxl_example.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fsdxl_example.py)中，我们提供了一个最小化的脚本，用于使用DistriFusion运行[SDXL](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fen\u002Fusing-diffusers\u002Fsdxl)。\n\n```python\nimport torch\n\nfrom distrifuser.pipelines import DistriSDXLPipeline\nfrom distrifuser.utils import DistriConfig\n\ndistri_config = DistriConfig(height=1024, width=1024, warmup_steps=4)\npipeline = DistriSDXLPipeline.from_pretrained(\n    distri_config=distri_config,\n    pretrained_model_name_or_path=\"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    variant=\"fp16\",\n    use_safetensors=True,\n)\n\npipeline.set_progress_bar_config(disable=distri_config.rank != 0)\nimage = pipeline(\n    prompt=\"丛林中的宇航员，冷色调，柔和色彩，细节丰富，8k\",\n    generator=torch.Generator(device=\"cuda\").manual_seed(233),\n).images[0]\nif distri_config.rank == 0:\n    image.save(\"astronaut.png\")\n```\n\n具体来说，我们的`distrifuser`与[diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers)共享相同的API，并且可以用类似的方式使用。您只需要定义一个`DistriConfig`，然后使用我们封装的`DistriSDXLPipeline`加载预训练的SDXL模型。之后，我们可以像在[diffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers)中的`StableDiffusionXLPipeline`一样生成图像。运行命令如下：\n\n```shell\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Fsdxl_example.py\n```\n\n其中`$N_GPUS`为您想要使用的GPU数量。\n\n我们还在[`scripts\u002Fsd_example.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fsd_example.py)中提供了一个最小化的脚本，用于使用DistriFusion运行SD1.4\u002F2。使用方法相同。\n\n### 基准测试\n\n我们的基准测试结果使用的是 PyTorch 2.2 和 diffusers 0.24.0。首先，您可能需要安装一些额外的依赖项：\n\n```shell\npip install git+https:\u002F\u002Fgithub.com\u002Fzhijian-liu\u002Ftorchprofile datasets torchmetrics dominate clean-fid\n```\n\n#### COCO 质量评估\n\n您可以使用 [`scripts\u002Fgenerate_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fgenerate_coco.py) 来生成带有 COCO 标题的图像。命令如下：\n\n```\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Fgenerate_coco.py --no_split_batch\n```\n\n其中 `$N_GPUS` 是您想要使用的 GPU 数量。默认情况下，生成的结果会存储在 `results\u002Fcoco` 目录中。您也可以通过 `--output_root` 参数自定义输出路径。以下是一些您可能需要调整的附加参数：\n\n* `--num_inference_steps`: 推理步数。默认值为 50。\n* `--guidance_scale`: 无分类器指导尺度。默认值为 5。\n* `--scheduler`: 扩散采样器。默认使用 [DDIM 采样器](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fv0.26.3\u002Fen\u002Fapi\u002Fschedulers\u002Fddim#ddimscheduler)。您也可以选择 `euler` 使用 [欧拉采样器](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fv0.26.3\u002Fen\u002Fapi\u002Fschedulers\u002Feuler#eulerdiscretescheduler)，或选择 `dpm-solver` 使用 [DPM 求解器](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdiffusers\u002Fen\u002Fapi\u002Fschedulers\u002Fmultistep_dpm_solver)。\n* `--warmup_steps`: 额外的预热步数（默认为 4）。\n* `--sync_mode`: 不同的 GroupNorm 同步模式。默认使用我们修正后的异步 GroupNorm。\n* `--parallelism`: 您使用的并行化范式。默认是补丁并行，您也可以选择 `tensor` 进行张量并行，或 `naive_patch` 进行朴素补丁并行。\n\n生成所有图像后，您可以使用我们的脚本 [`scripts\u002Fcompute_metrics.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fcompute_metrics.py) 来计算 PSNR、LPIPS 和 FID。使用方法如下：\n\n```shell\npython scripts\u002Fcompute_metrics.py --input_root0 $IMAGE_ROOT0 --input_root1 $IMAGE_ROOT1\n```\n\n其中 `$IMAGE_ROOT0` 和 `$IMAGE_ROOT1` 分别是要比较的图像文件夹路径。如果 `IMAGE_ROOT0` 是真实数据集，请添加 `--is_gt` 标志以进行尺寸调整。我们还提供了一个脚本 [`scripts\u002Fdump_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fdump_coco.py)，用于导出真实数据集图像。\n\n#### 延迟\n\n您可以使用 [`scripts\u002Frun_sdxl.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Frun_sdxl.py) 来测试我们不同方法的延迟。命令如下：\n\n```shell\ntorchrun --nproc_per_node=$N_GPUS scripts\u002Frun_sdxl.py --mode benchmark --output_type latent\n```\n\n其中 `$N_GPUS` 是您想要使用的 GPU 数量。与 [`scripts\u002Fgenerate_coco.py`](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fblob\u002Fmain\u002Fscripts\u002Fgenerate_coco.py) 类似，您也可以调整以下参数：\n\n* `--num_inference_steps`: 推理步数。默认为 50。\n* `--image_size`: 生成图像的尺寸。默认为 1024×1024。\n* `--no_split_batch`: 禁用无分类器指导中的批处理拆分。\n* `--warmup_steps`: 额外的预热步数（默认为 4）。\n* `--sync_mode`: 不同的 GroupNorm 同步模式。默认使用我们修正后的异步 GroupNorm。\n* `--parallelism`: 您使用的并行化范式。默认是补丁并行，您也可以选择 `tensor` 进行张量并行，或 `naive_patch` 进行朴素补丁并行。\n* `--warmup_times`\u002F`--test_times`: 预热和测试的运行次数。默认分别为 5 和 20 次。\n\n## 引用\n\n如果您在研究中使用了此代码，请引用我们的论文。\n\n```bibtex\n@inproceedings{li2023distrifusion,\n  title={DistriFusion: 高分辨率扩散模型的分布式并行推理},\n  author={李牧阳、蔡天乐、曹嘉欣、张钦盛、蔡涵、白俊杰、贾扬青、刘明宇、李凯、韩松},\n  booktitle={IEEE\u002FCVF 计算机视觉与模式识别会议（CVPR）论文集},\n  year={2024}\n}\n```\n\n## 致谢\n\n我们的代码基于 [huggingface\u002Fdiffusers](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdiffusers) 和 [lmxyy\u002Fsige](https:\u002F\u002Fgithub.com\u002Flmxyy\u002Fsige) 开发。我们感谢 [torchprofile](https:\u002F\u002Fgithub.com\u002Fzhijian-liu\u002Ftorchprofile) 提供的 MACs 测量工具，[clean-fid](https:\u002F\u002Fgithub.com\u002FGaParmar\u002Fclean-fid) 提供的 FID 计算功能，以及 [Lightning-AI\u002Ftorchmetrics](https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Ftorchmetrics) 提供的 PSNR 和 LPIPS 工具。\n\n我们感谢 Jun-Yan Zhu 和 Ligeng Zhu 的有益讨论和宝贵反馈。本项目得到了 MIT-IBM Watson AI 实验室、亚马逊公司、MIT 科学中心以及美国国家科学基金会的支持。","# DistriFusion 快速上手指南\n\nDistriFusion 是一种无需训练的分布式并行推理算法，旨在利用多张 GPU 加速高分辨率扩散模型（如 SDXL）的生成过程，同时保持图像质量。\n\n## 环境准备\n\n在开始之前，请确保您的系统满足以下要求：\n\n*   **操作系统**: Linux\n*   **Python**: Python 3\n*   **GPU**: NVIDIA GPU\n*   **CUDA**: 版本 >= 12.0\n*   **CuDNN**: 与 CUDA 版本对应\n*   **PyTorch**: 版本必须为 2.2 (`torch==2.2`)\n\n> **注意**：请确保已正确安装与 CUDA 12.0+ 匹配的 PyTorch 2.2 版本。\n\n## 安装步骤\n\n您可以选择通过 PyPI 直接安装，或从 GitHub 源码安装。\n\n### 方式一：通过 PyPI 安装（推荐）\n\n```shell\npip install distrifuser\n```\n\n### 方式二：通过 GitHub 安装\n\n```shell\npip install git+https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser.git\n```\n\n### 方式三：本地开发模式安装\n\n如果您需要修改源码或进行开发：\n\n```shell\ngit clone git@github.com:mit-han-lab\u002Fdistrifuser.git\ncd distrifuser\npip install -e .\n```\n\n## 基本使用\n\n`distrifuser` 的 API 设计与 Hugging Face `diffusers` 完全兼容。只需定义 `DistriConfig` 并使用封装好的 `DistriSDXLPipeline` 即可加载模型并进行分布式推理。\n\n以下是一个基于 SDXL 模型的最小化运行示例（保存为 `sdxl_example.py`）：\n\n```python\nimport torch\n\nfrom distrifuser.pipelines import DistriSDXLPipeline\nfrom distrifuser.utils import DistriConfig\n\n# 配置分布式参数，例如生成 1024x1024 图像，预热步数为 4\ndistri_config = DistriConfig(height=1024, width=1024, warmup_steps=4)\n\n# 加载预训练的 SDXL 模型\npipeline = DistriSDXLPipeline.from_pretrained(\n    distri_config=distri_config,\n    pretrained_model_name_or_path=\"stabilityai\u002Fstable-diffusion-xl-base-1.0\",\n    variant=\"fp16\",\n    use_safetensors=True,\n)\n\n# 仅在主进程 (rank 0) 显示进度条\npipeline.set_progress_bar_config(disable=distri_config.rank != 0)\n\n# 执行生成\nimage = pipeline(\n    prompt=\"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k\",\n    generator=torch.Generator(device=\"cuda\").manual_seed(233),\n).images[0]\n\n# 仅在主进程保存图像\nif distri_config.rank == 0:\n    image.save(\"astronaut.png\")\n```\n\n### 运行命令\n\n使用 `torchrun` 启动多卡推理，将 `$N_GPUS` 替换为您想要使用的 GPU 数量：\n\n```shell\ntorchrun --nproc_per_node=$N_GPUS sdxl_example.py\n```\n\n该工具同样支持 SD 1.4\u002F2.0 模型，使用方法类似（参考项目中的 `scripts\u002Fsd_example.py`）。","某数字艺术工作室需要为户外巨型广告牌批量生成 3840×3840 超高清创意海报，且对出图速度和画面完整性有极高要求。\n\n### 没有 distrifuser 时\n- **显存瓶颈限制分辨率**：单张 A100 显卡无法承载如此高分辨率的 SDXL 模型推理，强行运行会导致显存溢出（OOM），只能降低分辨率牺牲画质。\n- **简单分块导致画面割裂**：若尝试手动将图像切分至多卡并行，由于缺乏块间交互，生成结果在拼接处会出现明显的断裂或伪影，破坏整体美感。\n- **生成效率极其低下**：受限于单卡计算能力，生成一张高质量大图耗时过长，无法满足客户短时间内批量交付的需求。\n- **硬件资源利用率低**：多卡环境下，除主卡外其余显卡处于闲置状态，昂贵的算力集群无法转化为实际生产力。\n\n### 使用 distrifuser 后\n- **无缝多卡并行扩展**：distrifuser 通过同步通信机制实现图块间的有效交互，轻松利用 8 张 A100 显卡协同工作，完美支持 3840×3840 分辨率而不爆显存。\n- **保证视觉 fidelity**：算法消除了传统分块生成的边界缝隙，生成的巨幅海报画面连贯、细节丰富，视觉质量与单卡低分辨率生成保持一致。\n- **推理速度显著提升**：在 8 卡环境下，distrifuser 实现了高达 6.1 倍的加速比，将单张海报的生成时间从数分钟缩短至秒级，大幅提升交付效率。\n- **隐藏通信开销**：通过异步通信复用激活值，distrifuser 将多卡间的通信耗时隐藏在计算流水线中，确保了多机多卡扩展的高效性。\n\ndistrifuser 让高分辨率扩散模型的分布式推理变得训练免费且高效，彻底释放了多 GPU 集群在超高清图像生成领域的生产力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmit-han-lab_distrifuser_73a2c5f2.png","mit-han-lab","MIT HAN Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmit-han-lab_65e6a38d.png","Efficient AI Computing. PI: Song Han",null,"songhan_mit","https:\u002F\u002Fhanlab.mit.edu","https:\u002F\u002Fgithub.com\u002Fmit-han-lab",[82],{"name":83,"color":84,"percentage":85},"Python","#3572A5",100,727,35,"2026-04-13T03:07:58","MIT","未说明","必需 NVIDIA GPU，支持多卡分布式推理（示例使用 A100），需安装 CUDA >= 12.0 及对应的 CuDNN",{"notes":93,"python":94,"dependencies":95},"该工具专为高分辨率扩散模型（如 SDXL）的分布式并行推理设计，需通过 torchrun 启动以指定 GPU 数量。已集成至 NVIDIA TensorRT-LLM 和 ColossalAI。基准测试基于 PyTorch 2.2 和 diffusers 0.24.0。若进行质量评估基准测试，需额外安装 torchprofile, datasets, torchmetrics, dominate, clean-fid 等库。","3.x (README 仅标注 Python3，结合 PyTorch 2.2 通常建议 3.8+)",[96,97,65],"torch==2.2","diffusers>=0.24.0",[15],[100,101,102,103,104],"acceleration","diffusion-models","generative-ai","generative-model","parallelism","2026-03-27T02:49:30.150509","2026-04-13T17:43:13.783305",[108,113,118,123,128,133,138],{"id":109,"question_zh":110,"answer_zh":111,"source_url":112},31760,"为什么需要将 n_device_per_batch 设置为 world_size \u002F\u002F 2？这与补丁并行（Patch Parallelism）有什么关系？","扩散模型推理通常使用无分类器引导（Classifier-Free Guidance, CFG），这会使批次大小（batch size）加倍。因此，代码首先将批次拆分（split batch），然后在每个批次内使用位移补丁并行（displaced patch parallelism）。如果您希望实现补丁并行，通常需要 world_size >= 4，以便在每个补丁上至少分配 2 个设备（考虑到 CFG 导致的批次翻倍）。如果 world_size=2，则每个设备处理半个批次，此时可能无法在单个补丁内实现并行。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F19",{"id":114,"question_zh":115,"answer_zh":116,"source_url":117},31761,"是否支持奇数个 GPU？如果不支持，原因是什么？","理论上可以使用奇数个 GPU，但通常不建议。因为图像潜在空间（latent）的高度通常是 2 的倍数，如果 GPU 数量为奇数，补丁大小（patch size）不容易均匀分割。不过这不是不可能的，您可以尝试选择潜在空间高度为 GPU 数量的倍数来进行调整。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F15",{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},31762,"论文表 2 中的通信量（Communication Amount）是如何计算的？如何查看具体的缓冲區大小？","通信量计算取决于使用的原语：\n1. Ring AllReduce: 通信量 = s × (n-1)\u002Fn × 2 × 2。其中第一个 2 代表 Ring AllReduce 的两轮通信，第二个 2 代表 FP16 精度的 2 字节。\n2. Ring AllGather: 通信量 = s × (n-1) × 2。\n其中 s 是缓冲区大小，n 是设备数量。\n要获取 s，可以在初始化 distri_config 时设置 verbose=True，或者在代码中手动累加 attention.py、conv.py 等文件中所有进行 AllReduce 的张量的 numel。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F10",{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},31763,"如何在 VSCode 中调试基于 torchrun 的多进程程序？","多进程程序的逐行调试比较困难。建议采取以下措施：\n1. 在配置中传递 use_cuda_graph=False，这将禁用 CUDAGraph，允许您查看 PyTorch 的前向传播过程（虽然会降低并行速度）。\n2. 由于调试工具对多进程支持有限，维护者通常直接在代码中添加 print 语句来输出调试信息和变量值。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F9",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},31764,"当设置 do_classifier_free_guidance=False 时出现 AssertionError 报错，如何解决？","这是一个已知问题。当您禁用无分类器引导（classifier-free guidance）时，必须同时将 guidance_scale 参数设置为 1。您可以在脚本中显式传递 guidance_scale=1。最新代码已更新为当禁用 CFG 时自动将 guidance 设置为 1。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F8",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},31765,"在 SD2.1 或 SD1.5 等低分辨率模型上使用 4 个或更多 GPU 时输出全黑图像，怎么办？","这在低分辨率下是一个已知问题。stale_gn 和 correct_async_gn 模式在小分辨率下似乎存在 Bug。建议尝试使用 separate_gn 模式以获得更好的速度和稳定性。维护者正在修复小分辨率下的相关问题。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F7",{"id":139,"question_zh":140,"answer_zh":141,"source_url":142},31766,"如何支持 SD3 或 SD3.5 等新架构（如 Diffusion Transformers）？","目前官方管道已将 Unet 骨干网替换为 SD3Transformer2DModel。由于 Transformer 在计算注意力之前会将嵌入（embeddings）添加到潜变量（latents）中，这导致维度不匹配（例如 1,4096,1536 的嵌入无法直接加到 DistriConv2dPP 输出的 1,2048,1536 上）。目前社区用户正在编写自定义的 DistriSD3AttentionPP 和 DistriConv2dPP 代码来解决此问题，建议关注相关讨论或直接联系维护者获取最新的适配代码。","https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser\u002Fissues\u002F14",[144,149,154,159],{"id":145,"version":146,"summary_zh":147,"released_at":148},238982,"v0.0.1.beta1","在禁用无分类器指导时，自动将指导尺度设置为1。","2024-05-05T03:22:43",{"id":150,"version":151,"summary_zh":152,"released_at":153},238983,"v0.0.1.beta0","支持 SD。\n修复了 run_sdxl.py 脚本中的一些 minor bug。","2024-04-24T19:41:22",{"id":155,"version":156,"summary_zh":157,"released_at":158},238984,"v0.0.0beta1","修复一些小问题。","2024-03-05T21:55:53",{"id":160,"version":161,"summary_zh":162,"released_at":163},238985,"0.0.0beta0","初始发布。","2024-02-29T21:01:49"]