[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-nunchaku-ai--deepcompressor":3,"tool-nunchaku-ai--deepcompressor":61},[4,18,26,36,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},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"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,52],"视频",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[14,35],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"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":78,"owner_twitter":77,"owner_website":79,"owner_url":80,"languages":81,"stars":98,"forks":99,"last_commit_at":100,"license":101,"difficulty_score":102,"env_os":103,"env_gpu":104,"env_ram":105,"env_deps":106,"category_tags":113,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":114,"updated_at":115,"faqs":116,"releases":145},4306,"nunchaku-ai\u002Fdeepcompressor","deepcompressor","Model Compression Toolbox for Large Language Models and Diffusion Models","DeepCompressor 是一款由麻省理工学院韩松实验室开发的开源模型压缩工具箱，专为大型语言模型（LLM）和扩散模型（Diffusion Models）打造。随着 AI 模型规模不断增大，其在部署时往往面临显存占用高、推理延迟大等挑战，DeepCompressor 正是为了解决这一痛点，帮助开发者在几乎不损失精度的前提下，大幅降低模型的资源消耗并提升运行速度。\n\n该工具主要面向 AI 研究人员、算法工程师及系统开发者，提供了基于 PyTorch 的灵活后训练量化方案。它支持多种高精度的低比特量化格式（如 INT4、FP4 等），涵盖了仅权重量化、权重 - 激活联合量化以及针对 LLM 特有的 KV 缓存量化等多种策略。\n\nDeepCompressor 的技术亮点在于集成了多项前沿研究成果，例如专为扩散模型设计的 SVDQuant 算法，能通过低秩分量有效处理 4 比特量化中的异常值问题；以及面向大语言模型的 QoQ 算法与 QServe 推理系统，实现了高效的 W4A8KV4 混合精度量化。此外，它还提供了与 TinyChat、Nunchaku 等推理引擎的集成示例，让用户能轻松","DeepCompressor 是一款由麻省理工学院韩松实验室开发的开源模型压缩工具箱，专为大型语言模型（LLM）和扩散模型（Diffusion Models）打造。随着 AI 模型规模不断增大，其在部署时往往面临显存占用高、推理延迟大等挑战，DeepCompressor 正是为了解决这一痛点，帮助开发者在几乎不损失精度的前提下，大幅降低模型的资源消耗并提升运行速度。\n\n该工具主要面向 AI 研究人员、算法工程师及系统开发者，提供了基于 PyTorch 的灵活后训练量化方案。它支持多种高精度的低比特量化格式（如 INT4、FP4 等），涵盖了仅权重量化、权重 - 激活联合量化以及针对 LLM 特有的 KV 缓存量化等多种策略。\n\nDeepCompressor 的技术亮点在于集成了多项前沿研究成果，例如专为扩散模型设计的 SVDQuant 算法，能通过低秩分量有效处理 4 比特量化中的异常值问题；以及面向大语言模型的 QoQ 算法与 QServe 推理系统，实现了高效的 W4A8KV4 混合精度量化。此外，它还提供了与 TinyChat、Nunchaku 等推理引擎的集成示例，让用户能轻松将压缩后的模型部署到实际应用中，是进行模型轻量化探索与落地的得力助手。","\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_f0afff404a03.png\" alt=\"DeepCompressor Logo\" width=\"450\">\n\u003C\u002Fp>\n\n\u003Ch2>\u003Cp align=\"center\">Model Compression Toolbox for Large Language Models and Diffusion Models\u003C\u002Fp>\u003C\u002Fh2>\n\n\u003Cp align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\u002Fblob\u002Fmaster\u002FLICENSE\">\n        \u003Cimg alt=\"Apache License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fmit-han-lab\u002Fdeepcompressor\">\n    \u003C\u002Fa>\n    \u003C!-- \u003Ca href=\"https:\u002F\u002Fdeepcompressor.mit.edu\">\n        \u003Cimg alt=\"Website\" src=\"https:\u002F\u002Fimg.shields.io\u002Fwebsite?up_message=deepcompressor&url=https%3A%2F%2Fdeepcompressor.mit.edu\">\n    \u003C\u002Fa> -->\n   \u003C!-- \u003Ca href=\"https:\u002F\u002Fpypi.org\u002Fproject\u002Fdeepcompressor\u002F\">\n        \u003Cimg alt=\"Pypi\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fdeepcompressor\">\n    \u003C\u002Fa> -->\n\u003C\u002Fp>\n\n## News\n- [2025\u002F02] 🎉 [**QServe**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532) has been accepted to MLSys 2025!\n- [2025\u002F01] 🎉 [**SVDQuant**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007) has been accepted to ICLR 2025 (Spotlight)!\n- [2024\u002F12] 🎉 [**QServe**](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve) has been integratedd into NVIDIA [TensorRT-LLM](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FTensorRT-LLM\u002Ftree\u002Fmain\u002Fexamples\u002Fllama)!\n- [2024\u002F11] 🔥 Our latest **W4A4** diffusion model quantization work [**SVDQuant**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007) algorithm and [**Nunchaku**](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fnunchaku) system is publicly released! Check our [paper](http:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007)!\n- [2024\u002F05] 🔥 Our latest **W4A8KV4** LLM quantization work **QoQ** algorithm and **QServe** system is publicly released! **QoQ** is short for *quattuor-octō-quattuor* which is 4-8-4 in latin. Check our [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532)!\n\n## Key Features\n\n***DeepCompressor*** is an open source model compression toolbox for large language models and diffusion models based on PyTorch. DeepCompressor currently supports fake quantization with any integer and floating-point data type within 8 bits, e.g., INT8, INT4 and FP4_E2M1. Here are examples that implement the following algorithms.\n\n+ [Post-training quantization for large language models](\u002Fexamples\u002Fllm\u002F):\n  + Weight-only Quantization\n    + [AWQ (W4A16)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fawq.yaml)\n    + [GPTQ (W4A16)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fgptq.yaml)\n  + Weight-Activation Quantization\n    + [SmoothQuant (W8A8)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fsmoothquant-static.yaml)\n  + Weight-Activation and KV-Cache Quantization\n    + [QoQ (W4A8KV4)](\u002Fexamples\u002Fllm\u002F)\n+ [Post-training quantization for diffusion models](\u002Fexamples\u002Fdiffusion\u002F):\n  + Weight-Activation Quantization\n    + [SVDQuant (W4A4)](\u002Fexamples\u002Fdiffusion\u002F)\n\nDeepCompressor also contains examples that integrate with other inference libraries.\n  + [Deploy weight-only quantized LLMs with TinyChat](\u002Fexamples\u002Fllm\u002F)\n  + [Deploy quantized LLMs with QServe]((\u002Fexamples\u002Fllm\u002F))\n  + [Deploy quantized diffusion models with Nunchaku](\u002Fexamples\u002Fdiffusion\u002F)\n\n## Installation\n\n### Install from Source\n\n1. Clone this repository and navigate to deepcompressor folder\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\ncd deepcompressor\n```\n\n2. Install Package\n```\nconda env create -f environment.yml\npoetry install\n```\n\n## Highlights\n### SVDQuant: Absorbing Outliers by Low-Rank Components for 4-Bit Diffusion Models\n\n[[Website](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fsvdquant)][[Paper](http:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007)][[Nunchaku Inference System](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fnunchaku)]\n\nDiffusion models have been proven highly effective at generating high-quality images. However, as these models grow larger, they require significantly more memory and suffer from higher latency, posing substantial challenges for deployment. In this work, we aim to accelerate diffusion models by quantizing their weights and activations to 4 bits. At such an aggressive level, both weights and activations are highly sensitive, where conventional post-training quantization methods for large language models like smoothing become insufficient. To overcome this limitation, we propose **SVDQuant**, a new 4-bit quantization paradigm. Different from smoothing which redistributes outliers between weights and activations, our approach absorbs these outliers using a low-rank branch. We first consolidate the outliers by shifting them from activations to weights, then employ a high-precision low-rank branch to take in the weight outliers with Singular Value Decomposition (SVD). This process eases the quantization on both sides. However, naïvely running the low-rank branch independently incurs significant overhead due to extra data movement of activations, negating the quantization speedup. To address this, we co-design an inference engine **Nunchaku** that fuses the kernels of the low-rank branch into those of the low-bit branch to cut off redundant memory access. It can also seamlessly support off-the-shelf low-rank adapters (LoRAs) without the need for re-quantization. Extensive experiments on SDXL, PixArt-∑, and FLUX.1 validate the effectiveness of SVDQuant in preserving image quality. We reduce the memory usage for the 12B FLUX.1 models by 3.5×, achieving 3.0× speedup over the 4-bit weight-only quantized baseline on the 16GB laptop 4090 GPU, paving the way for more interactive applications on PCs.\n\n![Teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_d36fbfd5cbde.jpg)\n![SVDQuant](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_9dac1d9089c8.gif)\n\n#### Quality Evaluation\n\nBelow is the quality and similarity evaluated with 5000 samples from MJHQ-30K dataset. IR means ImageReward. Our 4-bit results outperform other 4-bit baselines, effectively preserving the visual quality of 16-bit models.\n\n| Model                      | Precision |  Method   | FID ($\\downarrow$) | IR ($\\uparrow$) | LPIPS ($\\downarrow$) | PSNR( $\\uparrow$) |\n|----------------------------|-----------|-----------|--------------------|-----------------|----------------------|-------------------|\n| FLUX.1-dev (50 Steps)      | BF16      | --        | 20.3               | 0.953           | --                   | --                |\n|                            | W4A16     | NF4       | 20.6               | 0.910           | 0.272                | 19.5              |\n|                            | INT W4A4  |           | 20.2               | 0.908           | 0.322                | 18.5              |\n|                            | INT W4A4  | SVDQuant  | 19.9               | 0.935           | 0.223                | 21.0              |\n|                            | NVFP4     |           | 20.3               | 0.961           | 0.345                | 16.3              |\n|                            | NVFP4     | SVDQuant  | 20.3               | 0.945           | 0.205                | 21.5              |\n| FLUX.1-schnell (4 Steps)   | BF16      | --        | 19.2               | 0.938           | --                   | --                |\n|                            | W4A16     | NF4       | 18.9               | 0.943           | 0.257                | 18.2              |\n|                            | INT W4A4  |           | 18.1               | 0.962           | 0.345                | 16.3              |\n|                            | INT W4A4  | SVDQuant  | 18.3               | 0.951           | 0.257                | 18.3              |\n|                            | NVFP4     |           | 19.0               | 0.952           | 0.276                | 17.6              |\n|                            | NVFP4     | SVDQuant  | 18.9               | 0.966           | 0.228                | 19.0              |\n| SANA-1.6b (20 Steps)       | BF16      | --        | 20.6               | 0.952           | --                   | --                |\n|                            | INT W4A4  |           | 20.5               | 0.894           | 0.339                | 15.3              |\n|                            | INT W4A4  | SVDQuant  | 19.3               | 0.935           | 0.220                | 17.8              |\n|                            | NVFP4     |           | 19.7               | 0.929           | 0.236                | 17.4              |\n|                            | NVFP4     | SVDQuant  | 20.2               | 0.941           | 0.176                | 19.0              |\n| PixArt-Sigma (20 Steps)    | FP16      | --        | 16.6               | 0.944           | --                   | --                |\n|                            | INT W4A8  | ViDiT-Q   | 37.3               | 0.573           | 0.611                | 12.0              |\n|                            | INT W4A4  | SVDQuant  | 19.2               | 0.878           | 0.323                | 17.6              |\n|                            | NVFP4     |           | 31.8               | 0.660           | 0.517                | 14.8              |\n|                            | NVFP4     | SVDQuant  | 16.6               | 0.940           | 0.271                | 18.5              |\n\n### QServe: W4A8KV4 Quantization for Efficient LLM Serving\n\n[[Website](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fqserve)][[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532)][[QoQ Algorithm Code](\u002Fexamples\u002Fllm)][[QServe GPU System](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve)]\n\nQuantization can accelerate large language model (LLM) inference. Going beyond INT8 quantization, the research community is actively exploring even lower precision, such as INT4. Nonetheless, state-of-the-art INT4 quantization techniques only accelerate low-batch, edge LLM inference, failing to deliver performance gains in large-batch, cloud-based LLM serving. We uncover a critical issue: existing INT4 quantization methods suffer from significant runtime overhead (20-90%) when **dequantizing either weights or partial sums** on GPUs. To address this challenge, we introduce **QoQ**, a W4A8KV4 quantization algorithm with 4-bit weight, 8-bit activation, and 4-bit KV cache. QoQ stands for **quattuor-octo-quattuor**, which represents 4-8-4 in Latin. QoQ is implemented by the **QServe** inference library that achieves measured speedup. The key insight driving QServe is that the efficiency of LLM serving on GPUs is critically influenced by **operations on low-throughput CUDA cores**. Building upon this insight, in QoQ algorithm, we introduce progressive quantization that can allow low dequantization overhead in W4A8 GEMM. Additionally, we develop SmoothAttention to effectively mitigate the accuracy degradation incurred by 4-bit KV quantization. In the QServe system, we perform compute-aware weight reordering and take advantage of register-level parallelism to reduce dequantization latency. We also make fused attention memory-bound, harnessing the performance gain brought by KV4 quantization. As a result, QServe improves the maximum achievable serving throughput of Llama-3-8B by **1.2×** on A100, **1.4×** on L40S; and Qwen1.5-72B by **2.4×** on A100, **3.5×** on L40S, compared to TensorRT-LLM.\n\n![QoQ-QServe](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_865fa004f4e3.png)\n![QoQ](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_e0d315a18d08.png)\n\n\n#### Perplexity Evaluation\n\nBelow is the WikiText2 perplexity evaluated with 2048 sequence length. The lower is the better.\n\n|   Methods   |  Precision   | Llama-3.1 70B | Llama-3.1 8B | Llama-3 70B |  Llama-3 8B | Llama-2 7B | Llama-2 13B | Llama-2 70B | Llama 7B | Llama 13B | Llama 30B | Mistral 7B | Yi 34B |\n|-------------|--------------|---------------|--------------|-------------| ------------|------------|-------------|-------------|----------|-----------|-----------|------------|--------|\n| FP16        |              | 2.81          | 6.24         | 2.85        |  6.14       | 5.47       | 4.88        | 3.32        | 5.68     | 5.09      | 4.10      | 5.25       | 4.60   |\n| SmoothQuant | W8A8         | 3.23          | 6.38         | 3.14        |  6.28       | 5.54       | 4.95        | 3.36        | 5.73     | 5.13      | 4.23      | 5.29       | 4.69   |\n| GPTQ-R      | W4A16 g128   | 3.46          | 6.64         | 3.42        |  6.56       | 5.63       | 4.99        | 3.43        | 5.83     | 5.20      | 4.22      | 5.39       | 4.68   |\n| AWQ         | W4A16 g128   | 3.22          | 6.60         | 3.20        |  6.54       | 5.60       | 4.97        | 3.41        | 5.78     | 5.19      | 4.21      | 5.37       | 4.67   |\n| QuaRot      | W4A4         | 5.97          | 8.32         | 6.75        |  8.33       | 6.19       | 5.45        | 3.83        | 6.34     | 5.58      | 4.64      | 5.77       | -      |\n| SpinQuant   | W4A4         | 4.80          | 7.42         | 6.27        |  7.37       | 5.96       | 5.24        | 3.71        | 6.14     | 5.39      | 4.56      | -          | -      |\n| Atom        | W4A4 g128    | -             | -            | 4.33        |  7.78       | 6.12       | 5.31        | 3.73        | 6.25     | 5.52      | 4.61      | 5.76       | 4.97   |\n| QoQ         | W4A8KV4      | 3.68          | 6.87         | 3.65        |  6.81       | 5.75       | 5.11        | 3.50        | 5.92     | 5.27      | 4.31      | 5.44       | 4.73   |\n| QoQ         | W4A8KV4 g128 | 3.51          | 6.77         | 3.50        |  6.70       | 5.67       | 5.06        | 3.46        | 5.88     | 5.23      | 4.27      | 5.41       | 4.73   |\n\n\\* SmoothQuant is evaluated with per-tensor static KV cache quantization.\n\n#### Efficiency Benchmarks\n\nWhen serving the large language models Llama-3-8B and Qwen1.5-72B on L40S and A100 GPUs, QServe demonstrates superior performance, achieving **1.2x-1.4x higher throughput** compared to the leading industry solution, TensorRT-LLM, for Llama-3-8B, and a **2.4x-3.5x higher throughput** for Qwen1.5-72B.\n\nSee more about benchmarking setting in [QServe GPU Inference System](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve).\n| L40S (48G)           | Llama-3-8B | Llama-2-7B | Mistral-7B | Llama-2-13B | Llama-30B | Yi-34B    | Llama-2-70B | Qwen-1.5-72B |\n|----------------------|------------|------------|------------|-------------|-----------|-----------|-------------|--------------|\n| TRT-LLM-FP16         | 1326       | 444        | 1566       | 92          | OOM       | OOM       | OOM         | OOM          |\n| TRT-LLM-W4A16        | 1431       | 681        | 1457       | 368         | 148       | 313       | 119         | 17           |\n| TRT-LLM-W8A8         | 2634       | 1271       | 2569       | 440         | 123       | 364       | OOM         | OOM          |\n| Atom-W4A4            | --         | 2120       | --         | --          | --        | --        | --          | --           |\n| QuaRot-W4A4          | --         | 805        | --         | 413         | 133       | --        | --          | 15           |\n| QServe-W4A8KV4       | **3656**   | **2394**   | **3774**   | **1327**    | **504**   | **869**   | **286**     | **59**       |\n| Throughput Increase* | **1.39x**  | **1.13x**  | **1.47x**  | **3.02x**   | **3.41x** | **2.39x** | **2.40x**   | **3.47x**    |\n\n| A100 (80G)           | Llama-3-8B | Llama-2-7B | Mistral-7B | Llama-2-13B | Llama-30B | Yi-34B    | Llama-2-70B | Qwen-1.5-72B |\n|----------------------|------------| -----------|------------|-------------|-----------|-----------|-------------|--------------|\n| TRT-LLM-FP16         | 2503       | 1549       | 2371       | 488         | 80        | 145       | OOM         | OOM          |\n| TRT-LLM-W4A16        | 2370       | 1549       | 2403       | 871         | 352       | 569       | 358         | 143          |\n| TRT-LLM-W8A8         | 2396       | 2334       | 2427       | 1277        | 361       | 649       | 235         | 53           |\n| Atom-W4A4            | --         | 1160       | --         | --          | --        | --        | --          | --           |\n| QuaRot-W4A4          | --         | 1370       | --         | 289         | 267       | --        | --          | 68           |\n| QServe-W4A8KV4       | **3005**   | **2908**   | **2970**   | **1741**    | **749**   | **803**   | **419**     | **340**      |\n| Throughput Increase* | **1.20x**  | **1.25x**  | **1.22x**  | **1.36x**   | **2.07x** | **1.23x** | **1.17x**   | **2.38x**    |\n\nThe absolute token generation throughputs of QServe and baseline systems (Unit: tokens\u002Fsecond. `--` means unsupported). All experiments were conducted under the same device memory budget. Throughput increase of QServe is calculated with regard to the best baseline in each column.\n\n## Reference\n\nIf you find `deepcompressor` useful or relevant to your research, please kindly cite our paper:\n\n```bibtex\n@article{lin2024qserve,\n  title={QServe: W4A8KV4 Quantization and System Co-design for Efficient LLM Serving},\n  author={Lin*, Yujun and Tang*, Haotian and Yang*, Shang and Zhang, Zhekai and Xiao, Guangxuan and Gan, Chuang and Han, Song},\n  journal={arXiv preprint arXiv:2405.04532},\n  year={2024}\n}\n\n@article{\n  li2024svdquant,\n  title={SVDQuant: Absorbing Outliers by Low-Rank Components for 4-Bit Diffusion Models},\n  author={Li*, Muyang and Lin*, Yujun and Zhang*, Zhekai and Cai, Tianle and Li, Xiuyu and Guo, Junxian and Xie, Enze and Meng, Chenlin and Zhu, Jun-Yan and Han, Song},\n  journal={arXiv preprint arXiv:2411.05007},\n  year={2024}\n}\n```\n\n## Related Projects\n\nThe following projects are highly related to QServe. Our group has developed full-stack application-algorithm-system-hardware support for efficient large models, receiving **9k+ GitHub stars** and **over 1M Huggingface community downloads**.\n\nYou are also welcome to check out [MIT HAN Lab](https:\u002F\u002Fhanlab.mit.edu) for other exciting projects on **Efficient Generative AI**!\n\n- [**System**] [QServe: W4A8KV4 Quantization for Efficient LLM Serving](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve)\n\n- [**System**] [TinyChat: Efficient and Lightweight Chatbot with AWQ](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fllm-awq\u002Ftree\u002Fmain\u002Ftinychat)\n\n- [**Application**] [VILA: On Pretraining of Visual-Language Models](https:\u002F\u002Fgithub.com\u002FEfficient-Large-Model\u002FVILA)\n\n- [**Algorithm**] [AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fllm-awq)\n\n- [**Algorithm**] [SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fsmoothquant)\n\n- [**Algorithm**] [DistriFusion: Distributed Parallel Inference for High-Resolution Diffusion Models](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser)\n\n- [**Hardware**] [SpAtten: Efficient Sparse Attention Architecture with Cascade Token and Head Pruning](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09852)\n\n\n## Acknowledgments\n\nDeepCompressor is inspired by many open-source libraries, including (but not limited to) [GPTQ](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.17323), [QuaRot](https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.00456) and [Atom](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.19102). ","\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_f0afff404a03.png\" alt=\"DeepCompressor Logo\" width=\"450\">\n\u003C\u002Fp>\n\n\u003Ch2>\u003Cp align=\"center\">面向大型语言模型和扩散模型的模型压缩工具箱\u003C\u002Fp>\u003C\u002Fh2>\n\n\u003Cp align=\"center\">\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\u002Fblob\u002Fmaster\u002FLICENSE\">\n        \u003Cimg alt=\"Apache License\" src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fmit-han-lab\u002Fdeepcompressor\">\n    \u003C\u002Fa>\n    \u003C!-- \u003Ca href=\"https:\u002F\u002Fdeepcompressor.mit.edu\">\n        \u003Cimg alt=\"Website\" src=\"https:\u002F\u002Fimg.shields.io\u002Fwebsite?up_message=deepcompressor&url=https%3A%2F%2Fdeepcompressor.mit.edu\">\n    \u003C\u002Fa> -->\n   \u003C!-- \u003Ca href=\"https:\u002F\u002Fpypi.org\u002Fproject\u002Fdeepcompressor\u002F\">\n        \u003Cimg alt=\"Pypi\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fdeepcompressor\">\n    \u003C\u002Fa> -->\n\u003C\u002Fp>\n\n## 最新动态\n- [2025年2月] 🎉 [**QServe**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532) 已被 MLSys 2025 接收！\n- [2025年1月] 🎉 [**SVDQuant**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007) 已被 ICLR 2025（Spotlight）接收！\n- [2024年12月] 🎉 [**QServe**](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve) 已集成到 NVIDIA [TensorRT-LLM](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FTensorRT-LLM\u002Ftree\u002Fmain\u002Fexamples\u002Fllama) 中！\n- [2024年11月] 🔥 我们的最新 **W4A4** 扩散模型量化工作 [**SVDQuant**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007) 算法及 [**Nunchaku**](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fnunchaku) 系统已公开发布！请查看我们的 [论文](http:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007)！\n- [2024年5月] 🔥 我们的最新 **W4A8KV4** LLM 量化工作 **QoQ** 算法及 **QServe** 系统已公开发布！**QoQ** 是 *quattuor-octō-quattuor* 的缩写，意为拉丁语中的 4-8-4。请查看我们的 [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532)！\n\n## 核心功能\n\n***DeepCompressor*** 是一个基于 PyTorch 的开源模型压缩工具箱，适用于大型语言模型和扩散模型。目前，DeepCompressor 支持使用任何 8 位以内的整数和浮点数据类型进行伪量化，例如 INT8、INT4 和 FP4_E2M1。以下是实现以下算法的示例。\n\n+ [大型语言模型的后训练量化](\u002Fexamples\u002Fllm\u002F)：\n  + 仅权重量化\n    + [AWQ (W4A16)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fawq.yaml)\n    + [GPTQ (W4A16)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fgptq.yaml)\n  + 权重-激活量化\n    + [SmoothQuant (W8A8)](\u002Fexamples\u002Fllm\u002Fconfigs\u002Fsmoothquant-static.yaml)\n  + 权重-激活及 KV 缓存量化\n    + [QoQ (W4A8KV4)](\u002Fexamples\u002Fllm\u002F)\n+ [扩散模型的后训练量化](\u002Fexamples\u002Fdiffusion\u002F)：\n  + 权重-激活量化\n    + [SVDQuant (W4A4)](\u002Fexamples\u002Fdiffusion\u002F)\n\nDeepCompressor 还包含与其他推理库集成的示例。\n  + [使用 TinyChat 部署仅权重量化的 LLM](\u002Fexamples\u002Fllm\u002F)\n  + [使用 QServe 部署量化后的 LLM](\u002Fexamples\u002Fllm\u002F)\n  + [使用 Nunchaku 部署量化后的扩散模型](\u002Fexamples\u002Fdiffusion\u002F)\n\n## 安装\n\n### 从源码安装\n\n1. 克隆本仓库并进入 deepcompressor 文件夹\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\ncd deepcompressor\n```\n\n2. 安装软件包\n```\nconda env create -f environment.yml\npoetry install\n```\n\n## 亮点\n\n### SVDQuant：通过低秩组件吸收异常值，实现4位扩散模型量化\n\n[[官网](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fsvdquant)][[论文](http:\u002F\u002Farxiv.org\u002Fabs\u002F2411.05007)][[Nunchaku 推理系统](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fnunchaku)]\n\n扩散模型在生成高质量图像方面表现出色。然而，随着模型规模的增大，它们对内存的需求显著增加，延迟也随之上升，这给部署带来了巨大挑战。在本工作中，我们旨在通过将扩散模型的权重和激活量化的4位来加速模型推理。在如此激进的量化级别下，权重和激活都变得非常敏感，传统的针对大型语言模型的后训练量化方法（如平滑化）已不足以应对。为克服这一局限性，我们提出了**SVDQuant**，一种全新的4位量化范式。与通过在权重和激活之间重新分配异常值的平滑化方法不同，我们的方法利用低秩分支来吸收这些异常值。我们首先通过将异常值从激活转移到权重来集中处理它们，然后使用高精度的低秩分支，借助奇异值分解（SVD）来处理权重中的异常值。这一过程有效缓解了两侧的量化压力。然而，如果简单地独立运行低秩分支，由于激活数据的额外移动，会带来显著的开销，从而抵消量化带来的加速效果。为此，我们协同设计了一款推理引擎**Nunchaku**，它将低秩分支的核与低比特分支的核融合在一起，以减少冗余的内存访问。此外，该引擎还能无缝支持现成的低秩适配器（LoRA），无需重新量化。我们在SDXL、PixArt-∑和FLUX.1上的大量实验验证了SVDQuant在保持图像质量方面的有效性。我们使120亿参数的FLUX.1模型的内存占用减少了3.5倍，在配备16GB显存的4090 GPU的笔记本电脑上，相比仅量化权重的4位基线实现了3.0倍的加速，为在个人电脑上实现更交互式的应用铺平了道路。\n\n![预告图](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_d36fbfd5cbde.jpg)\n![SVDQuant](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_9dac1d9089c8.gif)\n\n#### 质量评估\n\n以下是对MJHQ-30K数据集中的5000个样本进行的质量和相似性评估。IR代表ImageReward分数。我们的4位结果优于其他4位基线，能够有效保留16位模型的视觉质量。\n\n| 模型                      | 精度   | 方法   | FID ($\\downarrow$) | IR ($\\uparrow$) | LPIPS ($\\downarrow$) | PSNR( $\\uparrow$) |\n|----------------------------|--------|--------|--------------------|-----------------|----------------------|-------------------|\n| FLUX.1-dev (50步)      | BF16   | --     | 20.3               | 0.953           | --                   | --                |\n|                            | W4A16  | NF4    | 20.6               | 0.910           | 0.272                | 19.5              |\n|                            | INT W4A4  |           | 20.2               | 0.908           | 0.322                | 18.5              |\n|                            | INT W4A4  | SVDQuant  | 19.9               | 0.935           | 0.223                | 21.0              |\n|                            | NVFP4  |           | 20.3               | 0.961           | 0.345                | 16.3              |\n|                            | NVFP4  | SVDQuant  | 20.3               | 0.945           | 0.205                | 21.5              |\n| FLUX.1-schnell (4步)   | BF16   | --     | 19.2               | 0.938           | --                   | --                |\n|                            | W4A16  | NF4    | 18.9               | 0.943           | 0.257                | 18.2              |\n|                            | INT W4A4  |           | 18.1               | 0.962           | 0.345                | 16.3              |\n|                            | INT W4A4  | SVDQuant  | 18.3               | 0.951           | 0.257                | 18.3              |\n|                            | NVFP4  |           | 19.0               | 0.952           | 0.276                | 17.6              |\n|                            | NVFP4  | SVDQuant  | 18.9               | 0.966           | 0.228                | 19.0              |\n| SANA-1.6b (20步)       | BF16   | --     | 20.6               | 0.952           | --                   | --                |\n|                            | INT W4A4  |           | 20.5               | 0.894           | 0.339                | 15.3              |\n|                            | INT W4A4  | SVDQuant  | 19.3               | 0.935           | 0.220                | 17.8              |\n|                            | NVFP4  |           | 19.7               | 0.929           | 0.236                | 17.4              |\n|                            | NVFP4  | SVDQuant  | 20.2               | 0.941           | 0.176                | 19.0              |\n| PixArt-Sigma (20步)    | FP16   | --     | 16.6               | 0.944           | --                   | --                |\n|                            | INT W4A8  | ViDiT-Q   | 37.3               | 0.573           | 0.611                | 12.0              |\n|                            | INT W4A4  | SVDQuant  | 19.2               | 0.878           | 0.323                | 17.6              |\n|                            | NVFP4  |           | 31.8               | 0.660           | 0.517                | 14.8              |\n|                            | NVFP4  | SVDQuant  | 16.6               | 0.940           | 0.271                | 18.5              |\n\n### QServe：W4A8KV4量化，用于高效的大语言模型服务\n\n[[官网](https:\u002F\u002Fhanlab.mit.edu\u002Fprojects\u002Fqserve)][[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.04532)][[QoQ算法代码](\u002Fexamples\u002Fllm)][[QServe GPU系统](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve)]\n\n量化可以加速大型语言模型（LLM）的推理过程。除了INT8量化之外，研究界也在积极探索更低精度的量化方法，例如INT4。然而，目前最先进的INT4量化技术仅能加速低批次、端侧的LLM推理，在大规模批次、云端部署的LLM服务中却无法带来性能提升。我们发现了一个关键问题：现有的INT4量化方法在GPU上对权重或部分和进行反量化时，会引入显著的运行时开销（20%–90%）。为了解决这一挑战，我们提出了**QoQ**，一种W4A8KV4量化算法，即权重采用4位、激活采用8位、KV缓存采用4位。QoQ源自拉丁语“quattuor-octo-quattuor”，意为4-8-4。QoQ由**QServe**推理库实现，并通过实测验证了其加速效果。驱动QServe的核心洞察是：GPU上的LLM服务效率主要受**低吞吐量CUDA核心上的操作**所影响。基于这一洞察，我们在QoQ算法中引入了渐进式量化，能够在W4A8 GEMM中大幅降低反量化开销。此外，我们还开发了SmoothAttention，以有效缓解4位KV量化带来的精度损失。在QServe系统中，我们采用了计算感知的权重重排，并充分利用寄存器级并行性来减少反量化延迟。同时，我们将注意力机制的内存访问部分融合化，从而充分发挥KV4量化带来的性能优势。最终，与TensorRT-LLM相比，QServe使Llama-3-8B在A100上的最大可实现服务吞吐量提升了**1.2倍**，在L40S上提升了**1.4倍**；而Qwen1.5-72B在A100上的吞吐量提升了**2.4倍**，在L40S上提升了**3.5倍**。\n\n![QoQ-QServe](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_865fa004f4e3.png)\n![QoQ](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_readme_e0d315a18d08.png)\n\n\n#### 困惑度评估\n\n以下是序列长度为2048时的WikiText2困惑度评估结果，数值越低越好。\n\n| 方法       | 精度         | Llama-3.1 70B | Llama-3.1 8B | Llama-3 70B | Llama-3 8B | Llama-2 7B | Llama-2 13B | Llama-2 70B | Llama 7B | Llama 13B | Llama 30B | Mistral 7B | Yi 34B |\n|------------|--------------|---------------|--------------|-------------| ------------|------------|-------------|-------------|----------|-----------|-----------|------------|--------|\n| FP16       |              | 2.81          | 6.24         | 2.85        |  6.14       | 5.47       | 4.88        | 3.32        | 5.68     | 5.09      | 4.10      | 5.25       | 4.60   |\n| SmoothQuant | W8A8         | 3.23          | 6.38         | 3.14        |  6.28       | 5.54       | 4.95        | 3.36        | 5.73     | 5.13      | 4.23      | 5.29       | 4.69   |\n| GPTQ-R     | W4A16 g128   | 3.46          | 6.64         | 3.42        |  6.56       | 5.63       | 4.99        | 3.43        | 5.83     | 5.20      | 4.22      | 5.39       | 4.68   |\n| AWQ        | W4A16 g128   | 3.22          | 6.60         | 3.20        |  6.54       | 5.60       | 4.97        | 3.41        | 5.78     | 5.19      | 4.21      | 5.37       | 4.67   |\n| QuaRot     | W4A4         | 5.97          | 8.32         | 6.75        |  8.33       | 6.19       | 5.45        | 3.83        | 6.34     | 5.58      | 4.64      | 5.77       | -      |\n| SpinQuant  | W4A4         | 4.80          | 7.42         | 6.27        |  7.37       | 5.96       | 5.24        | 3.71        | 6.14     | 5.39      | 4.56      | -          | -      |\n| Atom       | W4A4 g128    | -             | -            | 4.33        |  7.78       | 6.12       | 5.31        | 3.73        | 6.25     | 5.52      | 4.61      | 5.76       | 4.97   |\n| QoQ        | W4A8KV4      | 3.68          | 6.87         | 3.65        |  6.81       | 5.75       | 5.11        | 3.50        | 5.92     | 5.27      | 4.31      | 5.44       | 4.73   |\n| QoQ        | W4A8KV4 g128 | 3.51          | 6.77         | 3.50        |  6.70       | 5.67       | 5.06        | 3.46        | 5.88     | 5.23      | 4.27      | 5.41       | 4.73   |\n\n\\* SmoothQuant采用逐张量静态KV缓存量化进行评估。\n\n#### 效率基准测试\n\n在L40S和A100 GPU上服务Llama-3-8B和Qwen1.5-72B等大型语言模型时，QServe表现出卓越的性能，相较于行业领先的解决方案TensorRT-LLM，Llama-3-8B的吞吐量提升了**1.2–1.4倍**，而Qwen1.5-72B的吞吐量则提升了**2.4–3.5倍**。\n\n更多关于基准测试设置的信息，请参阅[QServe GPU推理系统](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve)。\n| L40S (48G)           | Llama-3-8B | Llama-2-7B | Mistral-7B | Llama-2-13B | Llama-30B | Yi-34B    | Llama-2-70B | Qwen-1.5-72B |\n|----------------------|------------|------------|------------|-------------|-----------|-----------|-------------|--------------|\n| TRT-LLM-FP16         | 1326       | 444        | 1566       | 92          | OOM       | OOM       | OOM         | OOM          |\n| TRT-LLM-W4A16        | 1431       | 681        | 1457       | 368         | 148       | 313       | 119         | 17           |\n| TRT-LLM-W8A8         | 2634       | 1271       | 2569       | 440         | 123       | 364       | OOM         | OOM          |\n| Atom-W4A4            | --         | 2120       | --         | --          | --        | --        | --          | --           |\n| QuaRot-W4A4          | --         | 805        | --         | 413         | 133       | --        | --          | 15           |\n| QServe-W4A8KV4       | **3656**   | **2394**   | **3774**   | **1327**    | **504**   | **869**   | **286**     | **59**       |\n| 吞吐量提升*         | **1.39倍**  | **1.13倍**  | **1.47倍**  | **3.02倍**  | **3.41倍** | **2.39倍** | **2.40倍**  | **3.47倍**    |\n\n| A100 (80G)           | Llama-3-8B | Llama-2-7B | Mistral-7B | Llama-2-13B | Llama-30B | Yi-34B    | Llama-2-70B | Qwen-1.5-72B |\n|----------------------|------------| -----------|------------|-------------|-----------|-----------|-------------|--------------|\n| TRT-LLM-FP16         | 2503       | 1549       | 2371       | 488         | 80        | 145       | OOM         | OOM          |\n| TRT-LLM-W4A16        | 2370       | 1549       | 2403       | 871         | 352       | 569       | 358         | 143          |\n| TRT-LLM-W8A8         | 2396       | 2334       | 2427       | 1277        | 361       | 649       | 235         | 53           |\n| Atom-W4A4            | --         | 1160       | --         | --          | --        | --        | --          | --           |\n| QuaRot-W4A4          | --         | 1370       | --         | 289         | 267       | --        | --          | 68           |\n| QServe-W4A8KV4       | **3005**   | **2908**   | **2970**   | **1741**    | **749**   | **803**   | **419**     | **340**      |\n| 吞吐量提升*         | **1.20倍**  | **1.25倍**  | **1.22倍**  | **1.36倍**  | **2.07倍** | **1.23倍** | **1.17倍**  | **2.38倍**    |\n\nQServe 与基线系统在绝对标记生成吞吐量方面的对比（单位：标记\u002F秒。“--”表示不支持）。所有实验均在相同的设备内存预算下进行。QServe 的吞吐量提升是相对于各列中最佳基线计算得出的。\n\n\n\n## 参考文献\n\n如果您认为 `deepcompressor` 对您的研究有用或相关，请引用我们的论文：\n\n```bibtex\n@article{lin2024qserve,\n  title={QServe: W4A8KV4 量化与系统协同设计，用于高效的大模型推理},\n  author={Lin*, Yujun 和 Tang*, Haotian 和 Yang*, Shang 和 Zhang, Zhekai 和 Xiao, Guangxuan 和 Gan, Chuang 和 Han, Song},\n  journal={arXiv 预印本 arXiv:2405.04532},\n  year={2024}\n}\n\n@article{\n  li2024svdquant,\n  title={SVDQuant：通过低秩成分吸收异常值，实现 4 位扩散模型量化},\n  author={Li*, Muyang 和 Lin*, Yujun 和 Zhang*, Zhekai 和 Cai, Tianle 和 Li, Xiuyu 和 Guo, Junxian 和 Xie, Enze 和 Meng, Chenlin 和 Zhu, Jun-Yan 和 Han, Song},\n  journal={arXiv 预印本 arXiv:2411.05007},\n  year={2024}\n}\n```\n\n## 相关项目\n\n以下项目与 QServe 密切相关。我们团队为高效大模型开发了从应用、算法、系统到硬件的全栈支持，获得了 **9000 多颗 GitHub 星标** 和 **超过 100 万次 Hugging Face 社区下载**。\n\n也欢迎您访问 [MIT HAN 实验室](https:\u002F\u002Fhanlab.mit.edu)，了解更多关于 **高效生成式 AI** 的精彩项目！\n\n- [**系统**] [QServe：用于高效 LLM 推理的 W4A8KV4 量化] (https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fqserve)\n\n- [**系统**] [TinyChat：基于 AWQ 的高效轻量级聊天机器人] (https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fllm-awq\u002Ftree\u002Fmain\u002Ftinychat)\n\n- [**应用**] [VILA：视觉-语言模型的预训练研究] (https:\u002F\u002Fgithub.com\u002FEfficient-Large-Model\u002FVILA)\n\n- [**算法**] [AWQ：面向 LLM 压缩与加速的激活感知权重量化] (https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fllm-awq)\n\n- [**算法**] [SmoothQuant：针对大型语言模型的高精度高效后训练量化] (https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fsmoothquant)\n\n- [**算法**] [DistriFusion：高分辨率扩散模型的分布式并行推理] (https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdistrifuser)\n\n- [**硬件**] [SpAtten：基于级联标记与头剪枝的高效稀疏注意力架构] (https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.09852)\n\n\n## 致谢\n\nDeepCompressor 灵感来源于众多开源库，包括但不限于 [GPTQ] (https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.17323)、[QuaRot] (https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.00456) 和 [Atom] (https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.19102)。","# DeepCompressor 快速上手指南\n\nDeepCompressor 是一个基于 PyTorch 的开源模型压缩工具箱，专为大型语言模型（LLM）和扩散模型（Diffusion Models）设计。它支持多种后训练量化（PTQ）算法，包括针对 LLM 的 **QoQ (W4A8KV4)**、**AWQ**、**GPTQ**，以及针对扩散模型的 **SVDQuant (W4A4)**。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu 20.04+)\n*   **Python 版本**: 3.9 - 3.11\n*   **依赖管理工具**: \n    *   [Conda](https:\u002F\u002Fdocs.conda.io\u002F) (用于创建隔离环境)\n    *   [Poetry](https:\u002F\u002Fpython-poetry.org\u002F) (用于项目依赖安装)\n*   **硬件**: NVIDIA GPU (建议显存 16GB+ 以运行大模型量化示例)\n\n> **注意**: 本项目目前主要通过源码安装，未提供直接的 `pip` 包。请确保已安装 `git`。\n\n## 2. 安装步骤\n\nDeepCompressor 推荐使用 Conda 管理基础环境，配合 Poetry 安装项目依赖。\n\n### 第一步：克隆代码库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\ncd deepcompressor\n```\n\n### 第二步：创建并激活 Conda 环境\n使用项目提供的 `environment.yml` 文件创建包含所有必要依赖的环境：\n```bash\nconda env create -f environment.yml\nconda activate deepcompressor\n```\n\n### 第三步：安装项目包\n在激活的环境中，使用 Poetry 安装 DeepCompressor 及其内部依赖：\n```bash\npoetry install\n```\n\n> **提示**: 如果 `poetry install` 速度较慢，可尝试配置国内镜像源（如清华源）加速：\n> ```bash\n> poetry config repositories.tsinghua https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\u002F\n> poetry source add --priority=explicit tsinghua https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\u002F\n> # 然后重新运行 poetry install (可能需要调整 pyproject.toml 或命令行参数指定源)\n> ```\n\n## 3. 基本使用\n\nDeepCompressor 的核心功能通过配置文件驱动。以下是针对不同模型类型的最简使用示例。\n\n### 场景一：大语言模型 (LLM) 量化\n\n项目提供了多种量化策略的配置文件，位于 `examples\u002Fllm\u002Fconfigs\u002F` 目录下。\n\n**示例：使用 AWQ 算法进行 4-bit 权重量化 (W4A16)**\n\n假设您已准备好模型路径和校准数据集，通常通过运行示例脚本来执行：\n\n```bash\n# 进入 LLM 示例目录\ncd examples\u002Fllm\n\n# 运行量化脚本 (具体脚本名称请参考 examples\u002Fllm\u002FREADME.md 或目录内容，通常为 run_quantization.py 类似名称)\n# 以下命令为示意，需根据实际入口文件调整\npython run_quantization.py \\\n    --model_path \u003CYOUR_MODEL_PATH> \\\n    --config configs\u002Fawq.yaml \\\n    --output_dir .\u002Fquantized_model_awq\n```\n\n*   **支持的算法配置**:\n    *   `configs\u002Fawq.yaml`: AWQ (W4A16, 仅权重量化)\n    *   `configs\u002Fgptq.yaml`: GPTQ (W4A16, 仅权重量化)\n    *   `configs\u002Fsmoothquant-static.yaml`: SmoothQuant (W8A8, 权重 + 激活量化)\n    *   `QoQ`: W4A8KV4 (权重 + 激活 + KV Cache 量化，需参考 QServe 集成示例)\n\n### 场景二：扩散模型 (Diffusion Models) 量化\n\n针对图像生成模型，DeepCompressor 提供了先进的 **SVDQuant** 算法，实现 4-bit 权重和激活量化 (W4A4)。\n\n**示例：使用 SVDQuant 量化扩散模型**\n\n```bash\n# 进入扩散模型示例目录\ncd examples\u002Fdiffusion\n\n# 运行 SVDQuant 量化脚本\n# 同样需根据实际入口文件调整参数\npython run_svdquant.py \\\n    --model_name flux.1-dev \\\n    --output_dir .\u002Fquantized_flux_svdquant\n```\n\n*   **核心特性**: SVDQuant 通过低秩分支吸收异常值，显著降低显存占用（如 FLUX.1 模型可减少 3.5 倍），同时保持图像生成质量。\n*   **推理部署**: 量化后的扩散模型可配合 **Nunchaku** 推理系统进行高效部署。\n\n### 进阶：推理部署\n\n量化完成后，您可以结合官方提供的推理后端进行部署：\n*   **LLM**: 使用 **TinyChat** 部署仅权重量化模型，或使用 **QServe** 部署 W4A8KV4 模型以获得最大吞吐量。\n*   **Diffusion**: 使用 **Nunchaku** 系统加载量化后的扩散模型进行快速推理。\n\n详细部署代码请参考 `examples\u002F` 目录下对应的子文件夹说明。","一家初创 AIGC 公司试图在消费级显卡上部署最新的文生图扩散模型，以提供低成本的实时图像生成服务。\n\n### 没有 deepcompressor 时\n- **显存爆满无法运行**：原始扩散模型参数量巨大，在单张 RTX 4090 上加载时直接超出 24GB 显存上限，导致服务根本无法启动。\n- **推理延迟过高**：即使勉强在多卡环境下运行，生成一张图片需要数秒甚至更久，完全无法满足用户“实时预览”的交互需求。\n- **量化精度严重损失**：尝试使用传统量化方法将模型压缩至 4bit 时，由于缺乏对异常值的有效处理，生成的图像出现严重噪点、色彩失真或结构崩坏。\n- **部署成本高昂**：为了维持服务可用性，被迫租用昂贵的企业级 A100 集群，导致运营成本远超预算，商业模式难以跑通。\n\n### 使用 deepcompressor 后\n- **单卡轻松部署**：利用 deepcompressor 集成的 SVDQuant 算法，成功将模型权重和激活值同时量化为 4bit（W4A4），显存占用降低 75%，单张消费级显卡即可流畅运行。\n- **推理速度显著提升**：配合 Nunchaku 推理系统，量化后的模型推理延迟大幅降低，实现了接近实时的图像生成体验，用户等待时间从秒级降至毫秒级。\n- **生成质量几乎无损**：deepcompressor 通过低秩分量吸收异常值的独特机制，即使在激进的 4bit 量化下，生成图像的清晰度、细节和色彩还原度仍与原始浮点模型几乎一致。\n- **硬件成本大幅缩减**：不再依赖昂贵的高端集群，仅用普通游戏显卡即可构建高性能推理节点，使整体基础设施成本下降了 80% 以上。\n\ndeepcompressor 通过极致的 4bit 量化技术，打破了扩散模型在消费级硬件上的部署瓶颈，让高质量 AIGC 应用真正实现了低成本落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fnunchaku-ai_deepcompressor_e0d315a1.png","nunchaku-ai","Nunchaku","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fnunchaku-ai_f6d26529.png","",null,"contact@nunchaku.tech","nunchaku.tech\u002Fdocs\u002Fnunchaku\u002F","https:\u002F\u002Fgithub.com\u002Fnunchaku-ai",[82,86,90,94],{"name":83,"color":84,"percentage":85},"Python","#3572A5",97.4,{"name":87,"color":88,"percentage":89},"Cuda","#3A4E3A",2.4,{"name":91,"color":92,"percentage":93},"C++","#f34b7d",0.1,{"name":95,"color":96,"percentage":97},"C","#555555",0,773,90,"2026-04-05T16:37:12","Apache-2.0",4,"Linux","需要 NVIDIA GPU（文中提及 RTX 4090, A100, L40S），显存需求视模型而定（文中提及在 16GB 显存上运行 12B 模型），需支持 CUDA（具体版本未说明，通常需配合 PyTorch 版本）","未说明",{"notes":107,"python":108,"dependencies":109},"该工具基于 PyTorch 开发。安装需先克隆仓库，然后使用 conda 根据 environment.yml 创建环境，最后使用 poetry install 安装依赖。主要功能包括大语言模型和扩散模型的量化（如 W4A4, W4A8KV4）。部分高级推理功能需配合 QServe 或 Nunchaku 系统使用。","未说明（通过 environment.yml 和 poetry 管理）",[110,111,112],"PyTorch","conda","poetry",[35,15,14],"2026-03-27T02:49:30.150509","2026-04-06T17:25:26.849776",[117,122,127,132,136,141],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},19606,"量化过程耗时过长（例如 8B 模型需要 50+ 小时），如何加速 PTQ 流程？","可以通过使用优化的配置文件来加速量化过程。维护者创建了 `fast_int4.yaml` 配置文件，替换默认的 `int4.yaml` 后，可在保持 FLUX 图像质量不变的情况下减少 50% 的量化时间。\n具体操作：\n1. 下载并使用 [fast_int4.yaml](https:\u002F\u002Fgithub.com\u002Fmit-han-lab\u002Fdeepcompressor\u002Fblob\u002Fmain\u002Fexamples\u002Fdiffusion\u002Fconfigs\u002Fsvdquant\u002Ffast_int4.yaml) 替换原有的 `int4.yaml`。\n2. 若需进一步加速，可修改该文件中第 50 行的 `num_grids` 参数为 5（注意：非默认值 20 的配置尚未经过充分测试）。\n此外，社区也提交了相关 PR (PR #111) 以解决多 GPU 并行量化的问题。","https:\u002F\u002Fgithub.com\u002Fnunchaku-ai\u002Fdeepcompressor\u002Fissues\u002F35",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},19607,"运行评估时遇到数据集链接失效或 403 Forbidden 错误（特别是 sDCI 数据集），如何解决？","Meta 已使旧的数据集链接失效。请使用以下新的 HuggingFace 链接下载 sDCI 数据集：\nhttps:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmit-han-lab\u002Fsvdquant-datasets\u002Fresolve\u002Fmain\u002FsDCI.gz\n项目方将在下一个版本中更新代码中的链接。如果遇到 `aiohttp.client_exceptions.ClientResponseError: 403` 错误，通常是因为使用了旧的 Facebook CDN 链接，请替换为上述新链接。","https:\u002F\u002Fgithub.com\u002Fnunchaku-ai\u002Fdeepcompressor\u002Fissues\u002F28",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},19608,"w4a8kv4 模型的存储机制是怎样的？为什么文件类型显示为 int8 但大小减半？","由于目前硬件和框架缺乏原生的 int4 存储数据类型，项目采用了一种打包存储策略：每 N 个 int4 数值被打包存储为 N\u002F2 个 int8 数值。因此，虽然文件的 dtype 显示为 `int8`，但其元素数量是原始张量的一半，从而实现了文件大小减半的效果。这是为了在现有存储限制下实现 4bit 量化的必要手段。","https:\u002F\u002Fgithub.com\u002Fnunchaku-ai\u002Fdeepcompressor\u002Fissues\u002F2",{"id":133,"question_zh":134,"answer_zh":135,"source_url":131},19609,"KV Cache 量化（kv4）的具体实现细节是什么？Scale 和 Zero-point 的形状及计算方式是怎样的？","1. **量化粒度**：KV Cache 量化是在 SmoothAttention 之后进行的简单 RTN（Round-to-Nearest）量化。\n2. **Scale\u002FZero-point 形状**：对于形状为 `[batchsize, attention_head_nums, token_num, hidden_dim\u002Fattention_head_nums]` 的 KV Cache，量化参数（scale 和 zero_point）的形状通常为 `[batchsize, attention_head_num, token_num]`（或者在某些实现中表现为 `[seq_len, 1, head_dim_group, 1]`）。这意味着每 `hidden_dim\u002Fattention_head_nums`（对于 Llama 通常是 128）个元素共享同一组量化参数。\n3. **计算方法**：量化参数是通过简单的 PyTorch `amin` 和 `amax` 操作计算得出的，未使用其他特殊技巧。",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},19610,"如何在不依赖 QServe 的情况下单独评估 w4a8kv4 算法的准确性（如困惑度）？","可以使用 `lm_eval` 框架进行端到端的零样本（zero-shot）准确性评估或困惑度计算。\n1. **代码位置**：评估逻辑位于 `lmquant\u002Fllm\u002Feval.py`。\n2. **实现原理**：项目通过替换 Attention 前向传播中的 `apply_rotary_pos_emb` 函数，并注册量化 hook 来实现 KV Cache 的量化。这与 HuggingFace `transformers` 库中 KV Cache 的直接拼接逻辑兼容。\n3. **使用方法**：参考 `lm_eval` 文档将本地数据集解析到 `simple_evaluate()` 函数中即可运行评估。WikiText-2 的困惑度评估方法沿用了 GPTQ 等 prior work 的标准实现。","https:\u002F\u002Fgithub.com\u002Fnunchaku-ai\u002Fdeepcompressor\u002Fissues\u002F4",{"id":142,"question_zh":143,"answer_zh":144,"source_url":131},19611,"自定义 Config 文件中的参数（如 s\u002Fn\u002Fz int）含义是什么？是否有教程？","虽然官方尚未提供详细的逐参数教程，但根据社区讨论和代码实现：\n1. **基本结构**：Config 文件定义了量化策略，包括权重、激活值和 KV Cache 的位宽设置。\n2. **关键参数推断**：\n   - `s` 通常指代 Scale（缩放因子）。\n   - `z` 通常指代 Zero-point（零点）。\n   - `int` 相关参数指定了数据类型的位宽（如 int4, int8）。\n3. **参考实现**：建议参考项目中提供的示例配置文件（如 `awq.yaml` 或 `int4.yaml`），并结合 `lmquant` 库中的量化器基类代码 (`lmquant\u002Fquant\u002Fquantizer\u002Fbase.py`) 来理解各参数的具体作用。对于复杂的排列操作（permute），其目的是为了满足特定硬件（如 Tensor Core）对内存布局的要求，将 int8 数据高效地拆解为两个 int4 数据进行计算。",[]]