[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-microsoft--MInference":3,"tool-microsoft--MInference":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 真正成长为懂上",142651,2,"2026-04-06T23:34:12",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,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},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",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":101,"forks":102,"last_commit_at":103,"license":104,"difficulty_score":10,"env_os":105,"env_gpu":106,"env_ram":105,"env_deps":107,"category_tags":116,"github_topics":76,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":117,"updated_at":118,"faqs":119,"releases":147},4687,"microsoft\u002FMInference","MInference","[NeurIPS'24 Spotlight, ICLR'25, ICML'25] To speed up Long-context LLMs' inference, approximate and dynamic sparse calculate the attention, which reduces inference latency by up to 10x for pre-filling on an A100 while maintaining accuracy.","MInference 是一款专为加速长上下文大语言模型推理而设计的开源工具。面对处理百万级 token 提示词时传统模型计算缓慢、延迟高的问题，MInference 通过引入近似计算与动态稀疏注意力机制，显著提升了预填充阶段的效率。在单张 A100 显卡上，它不仅能将推理速度提升最高达 10 倍，还能保持甚至优化模型的准确性。\n\n该工具特别适合 AI 开发者、研究人员以及需要部署长文本应用场景的工程团队。其核心技术亮点在于巧妙利用了大模型注意力机制中“动态稀疏但包含静态模式”的特性：系统会离线分析并确定每个注意力头的稀疏模式，随后在线运行时动态近似稀疏索引，并调用最优化的自定义内核进行计算。目前，MInference 已集成至 SGLang、vLLM 等主流推理框架，并支持 LLaMA-3、GLM-4 及 Qwen2.5 等热门长上下文模型，让用户能够轻松实现高效、低延迟的百万字级文本处理。","\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Cimg alt=\"MInference\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_dcd208504c58.png\" width=70%>\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n\u003Ch2 align=\"center\">MInference: Million-Tokens Prompt Inference for Long-context LLMs\u003C\u002Fh2>\n\n\u003Cp align=\"center\">\n    | \u003Ca href=\"https:\u002F\u002Faka.ms\u002FMInference\">\u003Cb>Project Page\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490\">\u003Cb>Paper\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\">\u003Cb>HF Demo\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Faka.ms\u002FSCBench\">\u003Cb>SCBench\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Faka.ms\u002FMMInference\">\u003Cb>MMInference\u003C\u002Fb>\u003C\u002Fa> |\n\u003C\u002Fp>\n\nhttps:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fassets\u002F30883354\u002F52613efc-738f-4081-8367-7123c81d6b19\n\n_Now, you can process **1M context 10x faster in a single A100** using Long-context LLMs like LLaMA-3-8B-1M, GLM-4-1M, with even **better accuracy**, try **MInference 1.0** right now!_\n\n## 📰 News\n- 🐝 [25\u002F05\u002F02] MMInference has been accepted at **ICML'25**.\n- 👨‍💻‍ [25\u002F04\u002F14] [SGLang](https:\u002F\u002Fgithub.com\u002Fsgl-project\u002Fsglang\u002Fpull\u002F5327) and [vLLM](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fflash-attention\u002Fpull\u002F33) have merged the MInference sparse attention kernel. _MInference already supports the optimized kernels._ Just try `pip install sglang`. You can achieve up to **1.64× (64K), 2.4× (96K), 2.9× (128K), 5.2× (256K), 8× (512K), and 15× (1M)** speedup. Notably, SGLang also adapted it for FlashAttention-3. Special thanks to @zhyncs and @yinfan98 for their contributions!\n- 👾 [25\u002F04\u002F23] We are excited to announce the release of our multi-modality work, [MMInference](https:\u002F\u002Faka.ms\u002F2504.16083), which use **modality-aware permutation sparse attention** to accelerate long-context VLMs. We'll present MMInference at **Microsoft Booth** and **FW-Wild at ICLR'25**. See you in Singapore!\n- 🤗 [25\u002F01\u002F27] MInference has been integrated into [Qwen2.5-1M](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwen2.5-1m\u002F) and online services. For details, refer to the [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.15383) and the [vLLM implementation](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm\u002Fpull\u002F11844).\n- 🪸 [25\u002F01\u002F23] SCBench has been accepted at **ICLR'25**.\n\u003Cdetails>\n\u003Csummary>More News\u003C\u002Fsummary>\n \u003Cul>\n  \u003Cli> 🍩 [24\u002F12\u002F13] We are excited to announce the release of our KV cache-centric analysis work, \u003Ca href=\"https:\u002F\u002Faka.ms\u002FSCBench\">SCBench\u003C\u002Fa>, which evaluates long-context methods from a KV cache perspective.\u003C\u002Fli>\n  \u003Cli> 🧤 [24\u002F09\u002F26] MInference has been accepted as \u003Cb>spotlight\u003C\u002Fb> at \u003Cb>NeurIPS'24\u003C\u002Fb>. See you in Vancouver!\u003C\u002Fli>\n  \u003Cli> 👘 [24\u002F09\u002F16] We are pleased to announce the release of our KV cache offloading work, \u003Ca href=\"https:\u002F\u002Faka.ms\u002FRetrievalAttention\">RetrievalAttention\u003C\u002Fa>, which accelerates long-context LLM inference via vector retrieval.\u003C\u002Fli>\n  \u003Cli> 🥤 [24\u002F07\u002F24] MInference supports \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-8B-Instruct\">meta-llama\u002FMeta-Llama-3.1-8B-Instruct\u003C\u002Fa> now.\u003C\u002Fli>\n  \u003Cli> 🪗 [24\u002F07\u002F07] Thanks @AK for sponsoring. You can now use MInference online in the \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\">HF Demo\u003C\u002Fa> with ZeroGPU.\u003C\u002Fli>\n  \u003Cli> 📃 [24\u002F07\u002F03] Due to an issue with arXiv, the PDF is currently unavailable there. You can find the paper at this \u003Ca href=\"https:\u002F\u002Fexport.arxiv.org\u002Fpdf\u002F2407.02490\">link\u003C\u002Fa>.\u003C\u002Fli>\n  \u003Cli> 🧩 [24\u002F07\u002F03] We will present \u003Cb>MInference 1.0\u003C\u002Fb> at the \u003Cb>\u003Ci>Microsoft Booth\u003C\u002Fi>\u003C\u002Fb> and \u003Cb>\u003Ci>ES-FoMo\u003C\u002Fi>\u003C\u002Fb> at ICML'24. See you in Vienna!\u003C\u002Fli>\n\u003C\u002Ful>\n\u003C\u002Fdetails>\n\n## TL;DR\n\n**MInference 1.0** leverages the dynamic sparse nature of LLMs' attention, which exhibits some static patterns, to speed up the pre-filling for long-context LLMs. It first determines offline which sparse pattern each head belongs to, then approximates the sparse index online and dynamically computes attention with the optimal custom kernels. This approach achieves up to a **10x speedup** for pre-filling on an A100 while maintaining accuracy.\n\n- [MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490) (NeurIPS'24 **spotlight**, ES-FoMo @ ICML'24)\u003Cbr>\n  _Huiqiang Jiang†, Yucheng Li†, Chengruidong Zhang†, Qianhui Wu, Xufang Luo, Surin Ahn, Zhenhua Han, Amir H. Abdi, Dongsheng Li, Chin-Yew Lin, Yuqing Yang and Lili Qiu_\n\n**SCBench** analyzes long-context methods from a **KV cache-centric perspective** across the full KV cache lifecycle (e.g., KV cache generation, compression, retrieval, and loading). It evaluates 12 tasks under two shared context modes, covering four categories of long-context capabilities: string retrieval, semantic retrieval, global information, and multi-task scenarios.\n\n- [SCBench: A KV Cache-Centric Analysis of Long-Context Methods](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319) (ICLR'25, ENLSP @ NeurIPS'24)\u003Cbr>\n  _Yucheng Li, Huiqiang Jiang, Qianhui Wu, Xufang Luo, Surin Ahn, Chengruidong Zhang, Amir H. Abdi, Dongsheng Li, Jianfeng Gao, Yuqing Yang and Lili Qiu_\n\n**MMInference** use **modality-aware permutation sparse attention** to accelerate long-context VLMs inference in prefilling-stage. Specifically, we implement three distinct permutation-based sparse attention mechanisms, with FlashAttention, FlashDecoding and PIT, to address the grid patterns in vision inputs and the modality boundary issues in mixed-modality scenarios.\n\n- [MMInference: Accelerating Pre-filling for Long-Context VLMs via Modality-Aware Permutation Sparse Attention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2504.16083) (ICML'25, FM-Wild @ ICLR'25)\u003Cbr>\n  _Yucheng Li, Huiqiang Jiang, Chengruidong Zhang, Qianhui Wu, Xufang Luo, Surin Ahn, Amir H. Abdi, Dongsheng Li, Jianfeng Gao, Yuqing Yang and Lili Qiu_\n\n\n## 🎥 Overview\n\n![Onepage of MInference](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_ed1620dac5ce.png)\n![Onepage of SCBench](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_8b9bf40308e4.png)\n![Onepage of MMInference](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_3d87f067f6d9.png)\n\n## 🎯 Quick Start\n\n### Requirements\n\n- Torch\n- FlashAttention-2 (Optional)\n- Triton\n- **Transformers >= 4.46.0**\n\nTo get started with MInference, simply install it using pip:\n\n```bash\npip install minference\n```\n\n### Supported Efficient Methods\n\nYou can get the complete list of supported efficient methods by running the following code:\n```python\nfrom minference import MInferenceConfig\nsupported_attn_types = MInferenceConfig.get_available_attn_types()\nsupported_kv_types = MInferenceConfig.get_available_kv_types()\n```\n\nCurrently, we support the following long-context methods:\n\n- **[① KV Cache Generation]:** [MInference](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490), [xAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2503.16428), [FlexPrefill](https:\u002F\u002Farxiv.org\u002Fabs\u002F2502.20766), [A-shape](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.17453), [Tri-shape](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319), [MInference w\u002F static](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490), [Dilated](https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.05150), [Strided](https:\u002F\u002Farxiv.org\u002Fabs\u002F1904.10509)\n- **[② KV Cache Compression]:** [StreamingLLM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.17453), [SnapKV](https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.14469), [PyramidKV](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.02069), [KIVI](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02750)\n- **[③ KV Cache Retrieval]:** [CacheBlend](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.16444)\n- **[④ KV Cache Loading]:** [Quest](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.10774), [RetrievalAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.10516)\n\nFor more details about the KV cache lifecycle, please refer to [**SCBench**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319). Note that some modes are supported by vLLM, while all modes are supported by HF.\n\n### Supported Models\n\nGeneral *MInference* **supports any decoding LLMs**, including LLaMA-style models, and Phi models.\nWe have adapted nearly all open-source long-context LLMs available in the market.\nIf your model is not on the supported list, feel free to let us know in the issues, or you can follow [the guide](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002Fexperiments) to manually generate the sparse heads config.\n\nYou can get the complete list of supported LLMs by running:\n```python\nfrom minference import get_support_models\nget_support_models()\n```\n\nCurrently, we support the following LLMs:\n- Qwen2.5: [Qwen\u002FQwen2.5-7B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-7B-Instruct), [Qwen\u002FQwen2.5-32B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-32B-Instruct), [Qwen\u002FQwen2.5-72B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-72B-Instruct), [Qwen\u002FQwen2.5-7B-Instruct-1M](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-7B-Instruct-1M), [Qwen\u002FQwen2.5-14B-Instruct-1M](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-14B-Instruct-1M)\n- LLaMA-3.1: [meta-llama\u002FMeta-Llama-3.1-8B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-8B-Instruct), [meta-llama\u002FMeta-Llama-3.1-70B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-70B-Instruct)\n- LLaMA-3: [gradientai\u002FLlama-3-8B-Instruct-262k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-262k), [gradientai\u002FLlama-3-8B-Instruct-Gradient-1048k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-Gradient-1048k), [gradientai\u002FLlama-3-8B-Instruct-Gradient-4194k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-Gradient-4194k), [gradientai\u002FLlama-3-70B-Instruct-Gradient-262k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-70B-Instruct-Gradient-262k), [gradientai\u002FLlama-3-70B-Instruct-Gradient-1048k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-70B-Instruct-Gradient-1048k)\n- GLM-4: [THUDM\u002Fglm-4-9b-chat-1m](https:\u002F\u002Fhuggingface.co\u002FTHUDM\u002Fglm-4-9b-chat-1m)\n- Yi: [01-ai\u002FYi-9B-200K](https:\u002F\u002Fhuggingface.co\u002F01-ai\u002FYi-9B-200K)\n- Phi-3: [microsoft\u002FPhi-3-mini-128k-instruct](https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FPhi-3-mini-128k-instruct)\n- Qwen2: [Qwen\u002FQwen2-7B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2-7B-Instruct)\n\n### How to use MInference\n\n> [!TIP]\n> To benefit from fast kernel implementations, we recommend installing **SGLang** or **vLLM**.\n> for sglang\n> ```bash\n> uv pip install \"sglang[all]>=0.4.6.post4\"\n> ```\n>\n> for vllm\n> ```bash\n> uv pip install \"vllm>=0.9.0\"\n> uv pip install git+https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fflash-attention\n> ```\n\nfor HF,\n```diff\nfrom transformers import pipeline\n+from minference import MInference\n\npipe = pipeline(\"text-generation\", model=model_name, torch_dtype=\"auto\", device_map=\"auto\")\n\n# Patch MInference Module,\n# If you use the local path, please use the model_name from HF when initializing MInference.\n+minference_patch = MInference(\"minference\", model_name)\n+pipe.model = minference_patch(pipe.model)\n\npipe(prompt, max_length=10)\n\n# Using sparse kv methods, e.g. snapkv, quest, retr_attn, kivi\n+minference_patch = MInference(attn_type=\"minference\", model_name=model_name, kv_type=\"quest\")\n+pipe.model = minference_patch(pipe.model)\n\npipe(prompt, max_length=10)\n```\n\nfor vLLM,\n> For now, please use vllm>=0.4.1\n\n```diff\nfrom vllm import LLM, SamplingParams\n+ from minference import MInference\n\nllm = LLM(model_name, enforce_eager=True, max_model_len=128_000, enable_chunked_prefill=False)\n\n# Patch MInference Module,\n# If you use the local path, please use the model_name from HF when initializing MInference.\n+minference_patch = MInference(\"vllm\", model_name)\n+llm = minference_patch(llm)\n\noutputs = llm.generate(prompts, sampling_params)\n```\n\nfor vLLM w\u002F TP,\n\n1. Copy `minference_patch_vllm_tp` and `minference_patch_vllm_executor` from `minference\u002Fpatch.py` to the end of the `Worker` class in `vllm\u002Fworker\u002Fworker.py`. Make sure to indent `minference_patch_vllm_tp`.\n2. When calling VLLM, ensure `enable_chunked_prefill=False` is set.\n3. Refer to the script in https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002Fexperiments\u002Fbenchmarks\u002Frun_e2e_vllm_tp.sh\n\n```diff\nfrom vllm import LLM, SamplingParams\n+ from minference import MInference\n\nllm = LLM(model_name, enforce_eager=True, max_model_len=128_000, enable_chunked_prefill=False, tensor_parallel_size=2)\n\n# Patch MInference Module,\n# If you use the local path, please use the model_name from HF when initializing MInference.\n+minference_patch = MInference(\"vllm\", model_name)\n+llm = minference_patch(llm)\n\noutputs = llm.generate(prompts, sampling_params)\n```\n\nusing only the kernel,\n```python\nfrom minference import vertical_slash_sparse_attention, block_sparse_attention, streaming_forward\n\nattn_output = vertical_slash_sparse_attention(q, k, v, vertical_topk, slash)\nattn_output = block_sparse_attention(q, k, v, topk)\nattn_output = streaming_forward(q, k, v, init_num, local_window_num)\n```\n\nfor a local gradio demo \u003Ca href='https:\u002F\u002Fgithub.com\u002Fgradio-app\u002Fgradio'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fgradio-app\u002Fgradio'>\u003C\u002Fa>\n\n```bash\ngit clone https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\ncd MInference\npip install -r requirments.txt\npip install flash_attn\npython app.py\n```\n\nFor more details, please refer to our [Examples](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain\u002Fexamples) and [Experiments](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain\u002Fexperiments). You can find more information about the dynamic compiler PIT in this [paper](https:\u002F\u002Fdl.acm.org\u002Fdoi\u002F10.1145\u002F3600006.3613139) and on [GitHub](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSparTA\u002Ftree\u002Fpit_artifact).\n\n## SCBench\n\n> [!Note]\n> - **datasets >= 2.15.0**\n\n### Load Data\nYou can download and load the **SCBench** data through the Hugging Face datasets ([🤗 HF Repo](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FSCBench)):\n```python\nfrom datasets import load_dataset\n\ndatasets = [\"scbench_kv\", \"scbench_prefix_suffix\", \"scbench_vt\", \"scbench_repoqa\", \"scbench_qa_eng\", \"scbench_qa_chn\", \"scbench_choice_eng\", \"scbench_many_shot\", \"scbench_summary\", \"scbench_mf\", \"scbench_summary_with_needles\", \"scbench_repoqa_and_kv\"]\n\nfor dataset in datasets:\n    data = load_dataset(\"microsoft\u002FSCBench\", dataset, split=\"test\")\n```\n\n### Data Format\n\nAll data in **SCBench** are standardized to the following format:\n\n```json\n{\n    \"id\": \"Random id for each piece of data.\",\n    \"context\": \"The long context required for the task, such as repo-code, long-document, and many-shot.\",\n    \"multi_turns\": [{\"input\": \"multi-turn question.\", \"answer\": \"multi-turn reference answer.\"}],\n}\n```\n\n### Experiments\n\nWe implement **Multi-Turn** and **Multi-Request** modes with HF and vLLM in [`GreedySearch`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fyucheng\u002Fkvcompression\u002Fscbench\u002Feval_utils.py#L1160) and [`GreedySearch_vllm`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fyucheng\u002Fkvcompression\u002Fscbench\u002Feval_utils.py#L1070) two class. Please refer the follow scripts to run the experiments.\n\nfor all methods,\n```bash\ncd scbench\n# Single-GPU, in Multi-Turn Mode\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 1 multi-turn\n# Multi-GPU, in Multi-Turn Mode\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 multi-turn\n# Multi-GPU, in Multi-Request Mode\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 scdq\n```\n\nfor single methods,\n```bash\ncd scbench\n# Single-GPU, in Multi-Turn Mode, using attn_type: vllm, kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 1 multi-turn vllm dense\n# Multi-GPU, in Multi-Turn Mode, using attn_type: vllm, kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 multi-turn vllm dense\n# Multi-GPU, in Multi-Request Mode, using attn_type: vllm, kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 scdq vllm dense\n```\n\nMore details about **attn_type** and **kv_type**, please refer to this section: [Supported Efficient Methods](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain?tab=readme-ov-file#supported-efficient-methods).\n\n## FAQ\n\nFor more insights and answers, visit our [FAQ section](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002FTransparency_FAQ.md).\n\n**Q1: How to effectively evaluate the impact of dynamic sparse attention on the capabilities of long-context LLMs?**\n\nTo evaluate long-context LLM capabilities using models like LLaMA-3-8B-Instruct-1M and GLM-4-9B-1M, we tested: 1) context window with RULER, 2) general tasks with InfiniteBench, 3) retrieval tasks with Needle in a Haystack, and 4) language model prediction with PG-19.\u003Cbr\u002F>\nWe found traditional methods perform poorly in retrieval tasks, with difficulty levels as follows: \u003Cfont color=\"#337ab7\">\u003Cb>KV retrieval > Needle in a Haystack > Retrieval.Number > Retrieval PassKey\u003C\u002Fb>\u003C\u002Ffont>. The main challenge is the semantic difference between needles and the haystack. Traditional methods excel when this difference is larger, as in passkey tasks. KV retrieval requires higher retrieval capabilities since any key can be a target, and multi-needle tasks are even more complex.\u003Cbr\u002F>\nWe will continue to update our results with more models and datasets in future versions.\n\n**Q2: Does this dynamic sparse attention pattern only exist in long-context LLMs that are not fully trained?**\n\nFirstly, attention is dynamically sparse, a characteristic inherent to the mechanism. We selected state-of-the-art long-context LLMs, GLM-4-9B-1M and LLaMA-3-8B-Instruct-1M, with effective context windows of 64K and 16K. With MInference, these can be extended to 64K and 32K, respectively. We will continue to adapt our method to other advanced long-context LLMs and update our results, as well as explore the theoretical basis for this dynamic sparse attention pattern.\n\n**Q3: Does this dynamic sparse attention pattern only exist in Auto-regressive LMs or RoPE based LLMs?**\n\nSimilar vertical and slash line sparse patterns have been discovered in BERT[1] and multi-modal LLMs[2]. Our analysis of T5's attention patterns, shown in the figure, reveals these patterns persist across different heads, even in bidirectional attention.\u003Cbr\u002F>\n[1] SparseBERT: Rethinking the Importance Analysis in Self-Attention, ICML 2021.\u003Cbr\u002F>\n[2] LOOK-M: Look-Once Optimization in KV Cache for Efficient Multimodal Long-Context Inference, 2024.\u003Cbr\u002F>\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_a98a53d075a3.png\" width=\"600px\" style=\"margin:auto;border-radius: 5px;display: inline-block;padding: 0 0 0 10px;\" alt=''>\n\u003C\u002Fp>\n\u003Cp align=\"center\">Figure 1. The sparse pattern in T5 Encoder.\u003C\u002Fp>\n\n**Q4: What is the relationship between MInference, SSM, Linear Attention, and Sparse Attention?**\n\nAll four approaches (MInference, SSM, Linear Attention, and Sparse Attention) efficiently optimize attention complexity in Transformers, each introducing inductive bias differently. The latter three require training from scratch. Recent works like Mamba-2 and Unified Implicit Attention Representation unify SSM and Linear Attention as static sparse attention, with Mamba-2 itself being a block-wise sparse method. While these approaches show potential due to sparse redundancy in attention, static sparse attention may struggle with dynamic semantic associations in complex tasks. In contrast, dynamic sparse attention is better suited for managing these relationships.\n\n**Q5**: CUDA Out of Memory in in `_prepare_4d_causal_attention_mask_with_cache_position`\n\n_Solution_: Set the Hugging Face model's attention backend to FlashAttention-2 by adding the following argument during model initialization: `_attn_implementation=\"flash_attention_2\",`.\n\n**Q6**: CUDA Out of Memory in in `logits = self.lm_head(hidden_states[:, -logits_to_keep:, :])`\n\n_Solution_: Set the `logits_to_keep=1` in model forward.\n\n## Citation\n\nIf you find MInference useful or relevant to your project and research, please kindly cite our paper:\n\n```bibtex\n@inproceedings{jiang2024minference,\n  author = {Huiqiang Jiang and Yucheng Li and Chengruidong Zhang and Qianhui Wu and Xufang Luo and Surin Ahn and Zhenhua Han and Amir H. Abdi and Dongsheng Li and Chin-Yew Lin and Yuqing Yang and Lili Qiu},\n  booktitle = {The Thirty-eighth Annual Conference on Neural Information Processing Systems},\n  title = {{MI}nference 1.0: Accelerating Pre-filling for Long-Context {LLM}s via Dynamic Sparse Attention},\n  url = {https:\u002F\u002Fopenreview.net\u002Fforum?id=fPBACAbqSN},\n  year = {2024}\n}\n\n@inproceedings{li2025scbench,\n  title={{SCB}ench: A {KV} Cache-Centric Analysis of Long-Context Methods},\n  author={Yucheng Li and Huiqiang Jiang and Qianhui Wu and Xufang Luo and Surin Ahn and Chengruidong Zhang and Amir H. Abdi and Dongsheng Li and Jianfeng Gao and Yuqing Yang and Lili Qiu},\n  booktitle={The Thirteenth International Conference on Learning Representations},\n  year={2025},\n  url={https:\u002F\u002Fopenreview.net\u002Fforum?id=gkUyYcY1W9}\n}\n\n@inproceedings{li2025mminference,\n    title={{MMI}ference: Accelerating Pre-filling for Long-Context VLMs via Modality-Aware Permutation Sparse Attention},\n    author={Li, Yucheng and Jiang, Huiqiang and Zhang, Chengruidong and Wu, Qianhui and Luo, Xufang and Ahn, Surin and Abdi, Amir H and Li, Dongsheng and Gao, Jianfeng and Yang, Yuqing and Qiu, Lili},\n    booktitle={Forty-second International Conference on Machine Learning},\n    year={2025},\n    url={https:\u002F\u002Fopenreview.net\u002Fforum?id=me6PfbATWM}\n}\n```\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https:\u002F\u002Fcla.opensource.microsoft.com.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F).\nFor more information see the [Code of Conduct FAQ](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Flegal\u002Fintellectualproperty\u002Ftrademarks\u002Fusage\u002Fgeneral).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n","\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Cimg alt=\"MInference\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_dcd208504c58.png\" width=70%>\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n\u003Ch2 align=\"center\">MInference：面向长上下文大模型的百万令牌提示推理\u003C\u002Fh2>\n\n\u003Cp align=\"center\">\n    | \u003Ca href=\"https:\u002F\u002Faka.ms\u002FMInference\">\u003Cb>项目页面\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490\">\u003Cb>论文\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\">\u003Cb>HF 演示\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Faka.ms\u002FSCBench\">\u003Cb>SCBench\u003C\u002Fb>\u003C\u002Fa> |\n    \u003Ca href=\"https:\u002F\u002Faka.ms\u002FMMInference\">\u003Cb>MMInference\u003C\u002Fb>\u003C\u002Fa> |\n\u003C\u002Fp>\n\nhttps:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fassets\u002F30883354\u002F52613efc-738f-4081-8367-7123c81d6b19\n\n_现在，借助 MInference 1.0，您可以在单张 A100 上以 10 倍的速度处理 100 万令牌的上下文，同时保持更高的准确性！使用 LLaMA-3-8B-1M、GLM-4-1M 等长上下文大模型，立即体验吧！_\n\n## 📰 新闻\n- 🐝 [25\u002F05\u002F02] MMInference 已被 **ICML'25** 接受。\n- 👨‍💻‍ [25\u002F04\u002F14] [SGLang](https:\u002F\u002Fgithub.com\u002Fsgl-project\u002Fsglang\u002Fpull\u002F5327) 和 [vLLM](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fflash-attention\u002Fpull\u002F33) 已合并 MInference 的稀疏注意力核。_MInference 已经支持这些优化后的核。_ 只需运行 `pip install sglang` 即可。您将获得高达 **1.64× (64K), 2.4× (96K), 2.9× (128K), 5.2× (256K), 8× (512K), 以及 15× (1M)** 的加速效果。值得一提的是，SGLang 还将其适配到了 FlashAttention-3 上。特别感谢 @zhyncs 和 @yinfan98 的贡献！\n- 👾 [25\u002F04\u002F23] 我们很高兴地宣布推出多模态工作 [MMInference](https:\u002F\u002Faka.ms\u002F2504.16083)，该工作采用 **模态感知的置换稀疏注意力** 来加速长上下文视觉语言模型的推理。我们将在 **Microsoft 展位** 和 **FW-Wild at ICLR'25** 上展示 MMInference。新加坡见！\n- 🤗 [25\u002F01\u002F27] MInference 已集成到 [Qwen2.5-1M](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwen2.5-1m\u002F) 及其在线服务中。详情请参阅 [论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.15383) 和 [vLLM 实现](https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fvllm\u002Fpull\u002F11844)。\n- 🪸 [25\u002F01\u002F23] SCBench 已被 **ICLR'25** 接受。\n\u003Cdetails>\n\u003Csummary>更多新闻\u003C\u002Fsummary>\n \u003Cul>\n  \u003Cli> 🍩 [24\u002F12\u002F13] 我们很高兴地宣布发布以 KV 缓存为中心的分析工作，\u003Ca href=\"https:\u002F\u002Faka.ms\u002FSCBench\">SCBench\u003C\u002Fa>,它从 KV 缓存的角度评估长上下文方法。\u003C\u002Fli>\n  \u003Cli> 🧤 [24\u002F09\u002F26] MInference 被选为 \u003Cb>NeurIPS'24\u003C\u002Fb> 的 \u003Cb>亮点\u003C\u002Fb>。温哥华见！\u003C\u002Fli>\n  \u003Cli> 👘 [24\u002F09\u002F16] 我们很荣幸地宣布发布 KV 缓存卸载工作，\u003Ca href=\"https:\u002F\u002Faka.ms\u002FRetrievalAttention\">RetrievalAttention\u003C\u002Fa>,它通过向量检索加速长上下文大模型的推理。\u003C\u002Fli>\n  \u003Cli> 🥤 [24\u002F07\u002F24] MInference 现在支持 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-8B-Instruct\">meta-llama\u002FMeta-Llama-3.1-8B-Instruct\u003C\u002Fa>。\u003C\u002Fli>\n  \u003Cli> 🪗 [24\u002F07\u002F07] 感谢 @AK 的赞助。您现在可以在 \u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\">HF 演示\u003C\u002Fa> 中使用 MInference，无需 GPU。\u003C\u002Fli>\n  \u003Cli> 📃 [24\u002F07\u002F03] 由于 arXiv 出现问题，目前无法在其上获取 PDF 文件。您可以通过此链接查看论文：\u003Ca href=\"https:\u002F\u002Fexport.arxiv.org\u002Fpdf\u002F2407.02490\">链接\u003C\u002Fa>。\u003C\u002Fli>\n  \u003Cli> 🧩 [24\u002F07\u002F03] 我们将在 ICML'24 的 \u003Cb>\u003Ci>Microsoft 展位\u003C\u002Fi>\u003C\u002Fb> 和 \u003Cb>\u003Ci>ES-FoMo\u003C\u002Fi>\u003C\u002Fb> 上展示 \u003Cb>MInference 1.0\u003C\u002Fb>。维也纳见！\u003C\u002Fli>\n\u003C\u002Ful>\n\u003C\u002Fdetails>\n\n## TL;DR\n\n**MInference 1.0** 利用大模型注意力的动态稀疏特性——尽管存在一些静态模式——来加速长上下文大模型的预填充过程。它首先离线确定每个注意力头所属的稀疏模式，然后在线近似稀疏索引，并使用最优的自定义核动态计算注意力。这种方法能够在 A100 上实现高达 **10 倍的预填充加速**，同时保持准确性。\n\n- [MInference 1.0：通过动态稀疏注意力加速长上下文大模型的预填充](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490)（NeurIPS'24 **亮点**，ICML'24 ES-FoMo）\u003Cbr>\n  _Huiqiang Jiang†, Yucheng Li†, Chengruidong Zhang†, Qianhui Wu, Xufang Luo, Surin Ahn, Zhenhua Han, Amir H. Abdi, Dongsheng Li, Chin-Yew Lin, Yuqing Yang 和 Lili Qiu_\n\n**SCBench** 从 **KV 缓存为核心视角** 分析长上下文方法，覆盖整个 KV 缓存生命周期（如 KV 缓存的生成、压缩、检索和加载）。它在两种共享上下文模式下评估了 12 项任务，涵盖长上下文能力的四个类别：字符串检索、语义检索、全局信息以及多任务场景。\n\n- [SCBench：长上下文方法的 KV 缓存中心分析](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319)（ICLR'25，ENLSP @ NeurIPS'24）\u003Cbr>\n  _Yucheng Li, Huiqiang Jiang, Qianhui Wu, Xufang Luo, Surin Ahn, Chengruidong Zhang, Amir H. Abdi, Dongsheng Li, Jianfeng Gao, Yuqing Yang 和 Lili Qiu_\n\n**MMInference** 使用 **模态感知的置换稀疏注意力** 来加速长上下文视觉语言模型的预填充阶段。具体而言，我们实现了三种基于置换的稀疏注意力机制——FlashAttention、FlashDecoding 和 PIT——以应对视觉输入中的网格模式以及混合模态场景中的模态边界问题。\n\n- [MMInference：通过模态感知的置换稀疏注意力加速长上下文视觉语言模型的预填充](https:\u002F\u002Farxiv.org\u002Fabs\u002F2504.16083)（ICML'25，FM-Wild @ ICLR'25）\u003Cbr>\n  _Yucheng Li, Huiqiang Jiang, Chengruidong Zhang, Qianhui Wu, Xufang Luo, Surin Ahn, Amir H. Abdi, Dongsheng Li, Jianfeng Gao, Yuqing Yang 和 Lili Qiu_\n\n\n## 🎥 概览\n\n![MInference 一页](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_ed1620dac5ce.png)\n![SCBench 一页](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_8b9bf40308e4.png)\n![MMInference 一页](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_3d87f067f6d9.png)\n\n## 🎯 快速开始\n\n### 需求\n\n- Torch\n- FlashAttention-2（可选）\n- Triton\n- **Transformers >= 4.46.0**\n\n要开始使用 MInference，只需通过 pip 安装即可：\n\n```bash\npip install minference\n```\n\n### 支持的高效方法\n\n您可以通过运行以下代码获取支持的所有高效方法的完整列表：\n```python\nfrom minference import MInferenceConfig\nsupported_attn_types = MInferenceConfig.get_available_attn_types()\nsupported_kv_types = MInferenceConfig.get_available_kv_types()\n```\n\n目前，我们支持以下长上下文方法：\n\n- **[① KV缓存生成]：** [MInference](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490)、[xAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2503.16428)、[FlexPrefill](https:\u002F\u002Farxiv.org\u002Fabs\u002F2502.20766)、[A-shape](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.17453)、[Tri-shape](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319)、[MInference w\u002F static](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.02490)、[Dilated](https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.05150)、[Strided](https:\u002F\u002Farxiv.org\u002Fabs\u002F1904.10509)\n- **[② KV缓存压缩]：** [StreamingLLM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.17453)、[SnapKV](https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.14469)、[PyramidKV](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.02069)、[KIVI](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02750)\n- **[③ KV缓存检索]：** [CacheBlend](https:\u002F\u002Farxiv.org\u002Fabs\u002F2405.16444)\n- **[④ KV缓存加载]：** [Quest](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.10774)、[RetrievalAttention](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.10516)\n\n有关KV缓存生命周期的更多详细信息，请参阅[**SCBench**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.10319)。请注意，某些模式由vLLM支持，而所有模式均由HF支持。\n\n### 支持的模型\n\n通用*MInference* **支持任何解码型LLM**，包括LLaMA风格的模型和Phi系列模型。\n我们已经适配了市面上几乎所有的开源长上下文LLM。\n如果您的模型不在支持列表中，请随时在问题区告知我们，或者您可以按照[指南](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002Fexperiments)手动生成稀疏注意力头配置。\n\n您可以通过运行以下代码获取支持的LLM完整列表：\n```python\nfrom minference import get_support_models\nget_support_models()\n```\n\n目前，我们支持以下LLM：\n- Qwen2.5：[Qwen\u002FQwen2.5-7B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-7B-Instruct)、[Qwen\u002FQwen2.5-32B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-32B-Instruct)、[Qwen\u002FQwen2.5-72B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-72B-Instruct)、[Qwen\u002FQwen2.5-7B-Instruct-1M](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-7B-Instruct-1M)、[Qwen\u002FQwen2.5-14B-Instruct-1M](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2.5-14B-Instruct-1M)\n- LLaMA-3.1：[meta-llama\u002FMeta-Llama-3.1-8B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-8B-Instruct)、[meta-llama\u002FMeta-Llama-3.1-70B-Instruct](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-3.1-70B-Instruct)\n- LLaMA-3：[gradientai\u002FLlama-3-8B-Instruct-262k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-262k)、[gradientai\u002FLlama-3-8B-Instruct-Gradient-1048k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-Gradient-1048k)、[gradientai\u002FLlama-3-8B-Instruct-Gradient-4194k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-8B-Instruct-Gradient-4194k)、[gradientai\u002FLlama-3-70B-Instruct-Gradient-262k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-70B-Instruct-Gradient-262k)、[gradientai\u002FLlama-3-70B-Instruct-Gradient-1048k](https:\u002F\u002Fhuggingface.co\u002Fgradientai\u002FLlama-3-70B-Instruct-Gradient-1048k)\n- GLM-4：[THUDM\u002Fglm-4-9b-chat-1m](https:\u002F\u002Fhuggingface.co\u002FTHUDM\u002Fglm-4-9b-chat-1m)\n- Yi：[01-ai\u002FYi-9B-200K](https:\u002F\u002Fhuggingface.co\u002F01-ai\u002FYi-9B-200K)\n- Phi-3：[microsoft\u002FPhi-3-mini-128k-instruct](https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FPhi-3-mini-128k-instruct)\n- Qwen2：[Qwen\u002FQwen2-7B-Instruct](https:\u002F\u002Fhuggingface.co\u002FQwen\u002FQwen2-7B-Instruct)\n\n### 如何使用MInference\n\n> [!TIP]\n> 为了享受快速的内核实现，我们建议安装**SGLang**或**vLLM**。\n> 对于sglang：\n> ```bash\n> uv pip install \"sglang[all]>=0.4.6.post4\"\n> ```\n>\n> 对于vLLM：\n> ```bash\n> uv pip install \"vllm>=0.9.0\"\n> uv pip install git+https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fflash-attention\n> ```\n\n对于HF：\n```diff\nfrom transformers import pipeline\n+from minference import MInference\n\npipe = pipeline(\"text-generation\", model=model_name, torch_dtype=\"auto\", device_map=\"auto\")\n\n# 替换MInference模块，\n# 如果您使用本地路径，请在初始化MInference时使用HF中的model_name。\n+minference_patch = MInference(\"minference\", model_name)\n+pipe.model = minference_patch(pipe.model)\n\npipe(prompt, max_length=10)\n\n# 使用稀疏KV方法，例如snapkv、quest、retr_attn、kivi\n+minference_patch = MInference(attn_type=\"minference\", model_name=model_name，kv_type=\"quest\")\n+pipe.model = minference_patch(pipe.model)\n\npipe(prompt, max_length=10)\n```\n\n对于vLLM：\n> 目前，请使用vllm>=0.4.1版本。\n\n```diff\nfrom vllm import LLM、SamplingParams\n+ from minference import MInference\n\nllm = LLM(model_name，enforce_eager=True，max_model_len=128_000，enable_chunked_prefill=False)\n\n# 替换MInference模块，\n# 如果您使用本地路径，请在初始化MInference时使用HF中的model_name。\n+minference_patch = MInference(\"vllm\", model_name)\n+llm = minference_patch(llm)\n\noutputs = llm.generate(prompts，sampling_params)\n```\n\n对于带有张量并行的vLLM：\n\n1. 将`minference_patch_vllm_tp`和`minference_patch_vllm_executor`从`minference\u002Fpatch.py`复制到`vllm\u002Fworker\u002Fworker.py`中`Worker`类的末尾。确保缩进`minference_patch_vllm_tp`。\n2. 调用VLLM时，务必设置`enable_chunked_prefill=False`。\n3. 参考位于https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002Fexperiments\u002Fbenchmarks\u002Frun_e2e_vllm_tp.sh的脚本。\n\n```diff\nfrom vllm import LLM、SamplingParams\n+ from minference import MInference\n\nllm = LLM(model_name，enforce_eager=True，max_model_len=128_000，enable_chunked_prefill=False，tensor_parallel_size=2)\n\n# 替换MInference模块，\n# 如果您使用本地路径，请在初始化MInference时使用HF中的model_name。\n+minference_patch = MInference(\"vllm\", model_name)\n+llm = minference_patch(llm)\n\noutputs = llm.generate(prompts，sampling_params)\n```\n\n仅使用内核：\n```python\nfrom minference import vertical_slash_sparse_attention、block_sparse_attention、streaming_forward\n\nattn_output = vertical_slash_sparse_attention(q、k、v、vertical_topk、slash)\nattn_output = block_sparse_attention(q、k、v、topk)\nattn_output = streaming_forward(q、k、v、init_num、local_window_num)\n```\n\n对于本地Gradio演示 \u003Ca href='https:\u002F\u002Fgithub.com\u002Fgradio-app\u002Fgradio'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fgradio-app\u002Fgradio'>\u003C\u002Fa>\n\n```bash\ngit clone https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fmicrosoft\u002FMInference\ncd MInference\npip install -r requirments.txt\npip install flash_attn\npython app.py\n```\n\n如需更多详情，请参阅我们的[示例](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain\u002Fexamples)和[实验](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain\u002Fexperiments)。您可以在这篇[论文](https:\u002F\u002Fdl.acm.org\u002Fdoi\u002F10.1145\u002F3600006.3613139)以及[GitHub](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSparTA\u002Ftree\u002Fpit_artifact)上找到关于动态编译器PIT的更多信息。\n\n## SCBench\n\n> [!注意]\n> - **datasets >= 2.15.0**\n\n### 加载数据\n您可以通过 Hugging Face 数据集下载并加载 **SCBench** 数据（[🤗 HF 仓库](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FSCBench)）：\n```python\nfrom datasets import load_dataset\n\ndatasets = [\"scbench_kv\", \"scbench_prefix_suffix\", \"scbench_vt\", \"scbench_repoqa\", \"scbench_qa_eng\", \"scbench_qa_chn\", \"scbench_choice_eng\", \"scbench_many_shot\", \"scbench_summary\", \"scbench_mf\", \"scbench_summary_with_needles\", \"scbench_repoqa_and_kv\"]\n\nfor dataset in datasets:\n    data = load_dataset(\"microsoft\u002FSCBench\", dataset, split=\"test\")\n```\n\n### 数据格式\n\n**SCBench** 中的所有数据都统一为以下格式：\n\n```json\n{\n    \"id\": \"每条数据的随机 ID。\",\n    \"context\": \"任务所需的长上下文，例如代码库、长文档或多轮示例。\",\n    \"multi_turns\": [{\"input\": \"多轮问题\", \"answer\": \"多轮参考答案\"}],\n}\n```\n\n### 实验\n\n我们在 [`GreedySearch`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fyucheng\u002Fkvcompression\u002Fscbench\u002Feval_utils.py#L1160) 和 [`GreedySearch_vllm`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fyucheng\u002Fkvcompression\u002Fscbench\u002Feval_utils.py#L1070) 两个类中，分别使用 HF 和 vLLM 实现了 **多轮模式** 和 **多请求模式**。请参考以下脚本运行实验。\n\n对于所有方法：\n```bash\ncd scbench\n# 单 GPU，多轮模式\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 1 multi-turn\n# 多 GPU，多轮模式\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 multi-turn\n# 多 GPU，多请求模式\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_all_tasks.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 scdq\n```\n\n对于单个方法：\n```bash\ncd scbench\n# 单 GPU，多轮模式，使用 attn_type: vllm，kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 1 multi-turn vllm dense\n# 多 GPU，多轮模式，使用 attn_type: vllm，kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 multi-turn vllm dense\n# 多 GPU，多请求模式，使用 attn_type: vllm，kv_type: dense\nVLLM_ALLOW_LONG_MAX_MODEL_LEN=1 CUDA_VISIBLE_DEVICES=0,1 VLLM_WORKER_MULTIPROC_METHOD=spawn bash scripts\u002Frun_single_method.sh meta-llama\u002FLlama-3.1-8B-Instruct 2 scdq vllm dense\n```\n\n关于 **attn_type** 和 **kv_type** 的更多细节，请参阅此部分：[支持的高效方法](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Ftree\u002Fmain?tab=readme-ov-file#supported-efficient-methods)。\n\n## 常见问题解答\n\n如需更多见解和解答，请访问我们的 [FAQ 部分](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fblob\u002Fmain\u002FTransparency_FAQ.md)。\n\n**Q1：如何有效评估动态稀疏注意力对长上下文大模型能力的影响？**\n\n为了评估像 LLaMA-3-8B-Instruct-1M 和 GLM-4-9B-1M 这样的长上下文大模型的能力，我们测试了：1) 使用 RULER 测量上下文窗口；2) 使用 InfiniteBench 测试通用任务；3) 使用 Needle in a Haystack 测试检索任务；4) 使用 PG-19 测试语言模型预测。\u003Cbr\u002F>\n我们发现传统方法在检索任务中的表现较差，难度排序如下：\u003Cfont color=\"#337ab7\">\u003Cb>KV 检索 > 北针任务 > Retrieval.Number > Retrieval PassKey\u003C\u002Fb>\u003C\u002Ffont>。主要挑战在于针与 haystack 之间的语义差异。当这种差异较大时，比如 passkey 任务，传统方法表现较好。而 KV 检索则需要更高的检索能力，因为任何键都可能成为目标，多针任务更是复杂。\u003Cbr\u002F>\n我们将在后续版本中继续用更多模型和数据集更新结果。\n\n**Q2：这种动态稀疏注意力模式是否只存在于未完全训练的长上下文大模型中？**\n\n首先，注意力本身就是动态稀疏的，这是其机制 inherent 的特性。我们选择了最先进的长上下文大模型，GLM-4-9B-1M 和 LLaMA-3-8B-Instruct-1M，它们的有效上下文窗口分别为 64K 和 16K。借助 MInference，这些窗口可以分别扩展到 64K 和 32K。我们将继续将该方法应用于其他先进的长上下文大模型，并更新结果，同时探索这种动态稀疏注意力模式的理论基础。\n\n**Q3：这种动态稀疏注意力模式是否只存在于自回归语言模型或基于 RoPE 的语言模型中？**\n\n类似的垂直和斜线稀疏模式已在 BERT[1] 和多模态大模型[2] 中被发现。我们对 T5 注意力模式的分析显示，即使在双向注意力中，这些模式也会出现在不同的头中。\u003Cbr\u002F>\n[1] SparseBERT：重新思考自注意力中的重要性分析，ICML 2021。\u003Cbr\u002F>\n[2] LOOK-M：KV 缓存中的一次性优化，用于高效的多模态长上下文推理，2024年。\u003Cbr\u002F>\n\u003Cp align=\"center\">\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_readme_a98a53d075a3.png\" width=\"600px\" style=\"margin:auto;border-radius: 5px;display: inline-block;padding: 0 0 0 10px;\" alt=''>\n\u003C\u002Fp>\n\u003Cp align=\"center\">图 1. T5 编码器中的稀疏模式。\u003C\u002Fp>\n\n**Q4：MInference、SSM、线性注意力和稀疏注意力之间有什么关系？**\n\n这四种方法（MInference、SSM、线性注意力和稀疏注意力）都能高效地优化 Transformer 中的注意力复杂度，但它们引入归纳偏置的方式各不相同。后三种方法需要从头开始训练。最近的一些工作，如 Mamba-2 和 Unified Implicit Attention Representation，将 SSM 和 线性注意力统一为静态稀疏注意力，而 Mamba-2 本身则是一种分块稀疏方法。尽管这些方法由于注意力中的稀疏冗余而显示出潜力，但在处理复杂任务中的动态语义关联时，静态稀疏注意力可能会遇到困难。相比之下，动态稀疏注意力更适合管理这些关系。\n\n**Q5**：在 `_prepare_4d_causal_attention_mask_with_cache_position` 中出现 CUDA 内存不足。\n\n_解决方案_：在模型初始化时添加以下参数，将 Hugging Face 模型的注意力后端设置为 FlashAttention-2：`_attn_implementation=\"flash_attention_2\"`。\n\n**Q6**：在 `logits = self.lm_head(hidden_states[:, -logits_to_keep:, :])` 中出现 CUDA 内存不足。\n\n_解决方案_：在模型前向传播中将 `logits_to_keep` 设置为 1。\n\n## 引用\n\n如果您认为 MInference 对您的项目和研究有用或相关，请您引用我们的论文：\n\n```bibtex\n@inproceedings{jiang2024minference,\n  author = {Huiqiang Jiang and Yucheng Li and Chengruidong Zhang and Qianhui Wu and Xufang Luo and Surin Ahn and Zhenhua Han and Amir H. Abdi and Dongsheng Li and Chin-Yew Lin and Yuqing Yang and Lili Qiu},\n  booktitle = {The Thirty-eighth Annual Conference on Neural Information Processing Systems},\n  title = {{MI}nference 1.0: Accelerating Pre-filling for Long-Context {LLM}s via Dynamic Sparse Attention},\n  url = {https:\u002F\u002Fopenreview.net\u002Fforum?id=fPBACAbqSN},\n  year = {2024}\n}\n\n@inproceedings{li2025scbench,\n  title={{SCB}ench: A {KV} Cache-Centric Analysis of Long-Context Methods},\n  author={Yucheng Li and Huiqiang Jiang and Qianhui Wu and Xufang Luo and Surin Ahn and Chengruidong Zhang and Amir H. Abdi and Dongsheng Li and Jianfeng Gao and Yuqing Yang and Lili Qiu},\n  booktitle={The Thirteenth International Conference on Learning Representations},\n  year={2025},\n  url={https:\u002F\u002Fopenreview.net\u002Fforum?id=gkUyYcY1W9}\n}\n\n@inproceedings{li2025mminference,\n    title={{MMI}ference: Accelerating Pre-filling for Long-Context VLMs via Modality-Aware Permutation Sparse Attention},\n    author={Li, Yucheng and Jiang, Huiqiang and Zhang, Chengruidong and Wu, Qianhui and Luo, Xufang and Ahn, Surin and Abdi, Amir H and Li, Dongsheng and Gao, Jianfeng and Yang, Yuqing and Qiu, Lili},\n    booktitle={Forty-second International Conference on Machine Learning},\n    year={2025},\n    url={https:\u002F\u002Fopenreview.net\u002Fforum?id=me6PfbATWM}\n}\n```\n\n## 贡献\n\n本项目欢迎各种贡献和建议。大多数贡献都需要您同意贡献者许可协议（CLA），以声明您有权并将您的贡献权利授予我们使用。有关详细信息，请访问 https:\u002F\u002Fcla.opensource.microsoft.com。\n\n当您提交拉取请求时，CLA 机器人会自动判断您是否需要提供 CLA，并相应地标记 PR（例如状态检查、评论）。请按照机器人提供的指示操作即可。对于所有使用我们 CLA 的仓库，您只需完成一次此步骤。\n\n本项目已采用 [微软开源行为准则](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F)。更多信息请参阅 [行为准则常见问题解答](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F) 或通过电子邮件 [opencode@microsoft.com](mailto:opencode@microsoft.com) 联系我们，以获取更多问题或意见。\n\n## 商标\n\n本项目可能包含项目、产品或服务的商标或徽标。未经授权使用微软商标或徽标必须遵守并遵循 [微软商标与品牌指南](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Flegal\u002Fintellectualproperty\u002Ftrademarks\u002Fusage\u002Fgeneral)。在本项目的修改版本中使用微软商标或徽标不得造成混淆或暗示微软的赞助。任何第三方商标或徽标的使用均受该第三方政策的约束。","# MInference 快速上手指南\n\nMInference 是一款专为长上下文大语言模型（LLM）设计的加速工具。它利用注意力机制的动态稀疏特性，在单张 A100 显卡上可实现高达 **10 倍** 的预填充（prefilling）速度提升，同时保持甚至提高模型准确率。支持处理百万级（1M）token 上下文。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐)\n*   **Python**: 3.8+\n*   **核心依赖**:\n    *   PyTorch\n    *   Triton\n    *   **Transformers >= 4.46.0**\n*   **可选优化依赖** (强烈推荐安装以获得最佳性能):\n    *   FlashAttention-2\n    *   **SGLang** 或 **vLLM** (用于启用优化的底层内核)\n\n> **提示**: 为了获得最快的推理速度，建议优先安装 `sglang` 或 `vllm`。\n\n## 安装步骤\n\n### 1. 安装基础包\n使用 pip 直接安装 MInference：\n\n```bash\npip install minference\n```\n\n### 2. 安装高性能后端（推荐）\n为了启用自定义稀疏注意力内核并实现最大加速比，请选择以下任一方案进行安装：\n\n**方案 A：安装 SGLang (推荐)**\n```bash\nuv pip install \"sglang[all]>=0.4.6.post4\"\n```\n\n**方案 B：安装 vLLM**\n```bash\nuv pip install \"vllm>=0.9.0\"\nuv pip install git+https:\u002F\u002Fgithub.com\u002Fvllm-project\u002Fflash-attention\n```\n\n## 基本使用\n\nMInference 支持 Hugging Face (`transformers`)、vLLM 和 SGLang 等多种框架。以下是基于 **Hugging Face** 的最简使用示例。\n\n### Hugging Face 集成示例\n\n只需几行代码即可将现有模型转换为支持 MInference 的模式：\n\n```python\nfrom transformers import pipeline\nfrom minference import MInference\n\n# 1. 初始化标准的 HF pipeline\nmodel_name = \"Qwen\u002FQwen2.5-7B-Instruct-1M\"  # 或其他支持的长上下文模型\npipe = pipeline(\"text-generation\", model=model_name, torch_dtype=\"auto\", device_map=\"auto\")\n\n# 2. 应用 MInference 补丁\n# 注意：如果使用本地路径加载模型，初始化 MInference 时请仍使用 HF 上的模型名称\nminference_patch = MInference(\"minference\", model_name)\npipe.model = minference_patch(pipe.model)\n\n# 3. 正常进行推理\nprompt = \"这是一段非常长的文本...\"\noutputs = pipe(prompt, max_length=10)\n\nprint(outputs)\n```\n\n### 进阶：结合稀疏 KV Cache 方法\nMInference 还支持结合多种 KV Cache 压缩与检索策略（如 SnapKV, Quest, RetrievalAttention 等）：\n\n```python\nfrom transformers import pipeline\nfrom minference import MInference\n\nmodel_name = \"Qwen\u002FQwen2.5-7B-Instruct-1M\"\npipe = pipeline(\"text-generation\", model=model_name, torch_dtype=\"auto\", device_map=\"auto\")\n\n# 指定注意力类型和 KV Cache 策略 (例如使用 Quest)\nminference_patch = MInference(attn_type=\"minference\", model_name=model_name, kv_type=\"quest\")\npipe.model = minference_patch(pipe.model)\n\noutputs = pipe(prompt, max_length=10)\n```\n\n### 查看支持列表\n您可以运行以下代码查看当前版本支持的所有高效方法和模型：\n\n```python\nfrom minference import MInferenceConfig, get_support_models\n\n# 查看支持的注意力类型和 KV 类型\nprint(MInferenceConfig.get_available_attn_types())\nprint(MInferenceConfig.get_available_kv_types())\n\n# 查看支持的模型列表\nprint(get_support_models())\n```\n\n> **注意**: 目前完美支持 Qwen2.5-1M, LLaMA-3-8B\u002F70B (Gradient 版本), GLM-4-1M 等主流长上下文开源模型。","某法律科技团队正在构建基于 LLaMA-3-8B-1M 的智能合同审查系统，需要一次性输入数百页的法律文档（约 50 万 token）以生成精准的风险分析报告。\n\n### 没有 MInference 时\n- **等待时间过长**：在单张 A100 显卡上，仅预处理（Pre-filling）超长上下文就需要数分钟，律师无法进行实时交互查询。\n- **硬件资源瓶颈**：巨大的计算量导致显存占用极高，难以在同一服务器上部署多个并发服务，扩容成本高昂。\n- **被迫牺牲精度**：为了追求响应速度，团队不得不将长文档强行截断或使用摘要替代全文，导致关键法律条款被遗漏，分析结果不可靠。\n- **用户体验断裂**：漫长的加载过程让用户频繁失去耐心，系统在实际业务场景中难以落地推广。\n\n### 使用 MInference 后\n- **推理速度飞跃**：利用动态稀疏注意力机制，预处理延迟降低了近 10 倍，原本几分钟的等待缩短至秒级，实现近乎实时的反馈。\n- **单机承载高并发**：计算效率的大幅提升使得单张 A100 即可流畅处理百万级 token 上下文，显著降低了硬件部署门槛和运营成本。\n- **全量信息无损分析**：无需再对文档进行截断或摘要，模型能直接“阅读”完整合同全文，确保了风险识别的准确性和完整性。\n- **交互体验流畅自然**：极速的响应让律师可以像日常对话一样连续追问细节，真正实现了长上下文大模型的实用化落地。\n\nMInference 通过动态稀疏计算打破了长上下文推理的速度壁垒，让百万级 token 的实时精准分析在单卡设备上成为可能。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_MInference_ed1620da.png","microsoft","Microsoft","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmicrosoft_4900709c.png","Open source projects and samples from Microsoft",null,"opensource@microsoft.com","OpenAtMicrosoft","https:\u002F\u002Fopensource.microsoft.com","https:\u002F\u002Fgithub.com\u002Fmicrosoft",[82,86,90,94,98],{"name":83,"color":84,"percentage":85},"Python","#3572A5",96.8,{"name":87,"color":88,"percentage":89},"Shell","#89e051",2.8,{"name":91,"color":92,"percentage":93},"Cuda","#3A4E3A",0.3,{"name":95,"color":96,"percentage":97},"C++","#f34b7d",0,{"name":99,"color":100,"percentage":97},"Makefile","#427819",1203,78,"2026-04-06T05:51:49","MIT","未说明","需要 NVIDIA GPU（文中示例提及单卡 A100），需安装 FlashAttention-2（可选但推荐以获得加速效果），具体显存大小取决于加载的模型参数量及上下文长度（如处理 1M 上下文需大显存）。",{"notes":108,"python":105,"dependencies":109},"该工具主要加速长上下文 LLM 的预填充阶段。虽然核心依赖仅需 Torch、Triton 和 Transformers，但为了获得显著的速度提升（最高 15 倍），强烈建议搭配 SGLang 或 vLLM 使用。支持多种长上下文优化方法（如 StreamingLLM, SnapKV 等）及多款主流开源模型（如 Qwen2.5, LLaMA-3, GLM-4 等）。若模型不在默认支持列表中，可手动生成稀疏头配置。",[110,111,112,113,114,115],"torch","transformers>=4.46.0","triton","flash-attn (可选)","sglang>=0.4.6.post4 (推荐用于加速)","vllm>=0.9.0 (推荐用于加速)",[35,14],"2026-03-27T02:49:30.150509","2026-04-07T08:08:49.132187",[120,125,130,135,139,143],{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},21318,"运行 benchmark_e2e.py 时遇到 'CUDA error: an illegal memory access was encountered' 或 'Triton Error' 怎么办？","该错误通常是因为未安装 `flash_attn` 包，导致代码回退到不稳定的 Triton 实现版本。解决方法是安装 flash_attn：\n\npip install flash-attn\n\n安装后，代码会自动从 `flash_attn` 包导入 `flash_attn_func`，从而避免调用内部容易出错的 `_flash_attn_triton_decoding` 函数。如果问题依旧，请检查是否在使用 `minference_with_dense` 模式时存在特定代码问题。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fissues\u002F86",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},21319,"评估 SCBench 数据集时出现 'Invalid task name: scbench_kv' 或 'BuilderConfig not found' 错误如何解决？","这通常是由于数据集加载方式不正确或本地数据文件结构问题导致的。请尝试以下两种方法：\n1. 确保已正确安装并启用 git lfs，且完整克隆了数据集仓库。\n2. 如果直接从 Hugging Face 下载了数据或在本地加载，请修改加载代码为：\n\nfrom datasets import load_dataset\ndata_name = \"scbench_kv\"\ndata = load_dataset(\".\u002FSCBench\", data_name, split=\"test\")\n\n注意：不要将 data_name 直接拼接到路径字符串中（如 \".\u002FSCBench\"+data_name），而应作为 `load_dataset` 的第二个参数传入。同时检查 `datasets` 库版本（推荐 3.2.0+）。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fissues\u002F103",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},21320,"运行 run_vllm.py 时遇到 'TypeError: type object is not subscriptable' 错误是什么原因？","该错误通常由 Python 版本过低或依赖包版本不兼容引起。确保您的环境满足以下要求：\n- Python 版本 >= 3.9（类型提示语法需要）\n- vLLM 版本 >= 0.4.1\n- Torch 版本 >= 2.2.1\n- Triton 版本 >= 2.2.0\n- Flash-Attn 版本 >= 2.5.9\n\n升级相关依赖后重试：\npip install --upgrade vllm torch triton flash-attn","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fissues\u002F13",{"id":136,"question_zh":137,"answer_zh":138,"source_url":134},21321,"在 Qwen2 模型上运行 vLLM 集成时报错，是否支持 Qwen2 系列模型？","MInference 的 vLLM 集成主要针对 Llama-3 等模型进行了充分测试。在 Qwen2-7B-Instruct 上运行时可能会遇到兼容性错误。建议：\n1. 确认使用的是最新版本的 MInference 和 vLLM。\n2. 检查模型配置中的 `trust_remote_code` 设置，Qwen2 可能需要设置为 True。\n3. 如果问题持续，暂时建议使用 `hf` 或 `minference` 原生模式而非 `run_vllm.py` 脚本进行推理，直到官方明确支持 Qwen2。",{"id":140,"question_zh":141,"answer_zh":142,"source_url":124},21322,"为什么 minference_with_dense 模式总是报错 'PassManager::run failed'，而其他模式正常？","`minference_with_dense` 模式在某些环境下（特别是未安装 flash_attn 时）会强制使用内部的 Triton 实现 (`_flash_attn_triton_decoding`)，该实现在特定 CUDA\u002FTriton 版本组合下不稳定。解决方案：\n1. 务必安装 `flash_attn` 以切换到更稳定的后端。\n2. 如果必须使用该模式且无法安装 flash_attn，尝试降低上下文窗口长度（context_window）或更新 Triton 到最新版本。\n3. 目前该模式仍在优化中，生产环境建议优先使用标准的 `minference` 模式。",{"id":144,"question_zh":145,"answer_zh":146,"source_url":129},21323,"如何正确加载本地下载的 SCBench 数据集以避免超时或配置错误？","如果服务器网络不稳定导致直接从 HF 加载超时，可以手动下载数据集到本地目录（例如 `.\u002FSCBench`），然后使用以下代码加载：\n\nfrom datasets import load_dataset\ndata = load_dataset(\".\u002FSCBench\", \"scbench_kv\", split=\"test\")\n\n关键点：\n- 第一个参数是本地文件夹路径。\n- 第二个参数是配置名称（config name），必须是数据集中实际存在的配置（如 \"scbench_kv\"），不能省略，否则会报 'BuilderConfig not found' 错误。\n- 确保本地文件夹结构完整，包含 `data` 子目录及对应的箭头文件。",[148,153,158,163,168,173,178,183,188,193,198],{"id":149,"version":150,"summary_zh":151,"released_at":152},127328,"v0.1.6","## 变更内容\n\n### 功能特性\n\n* [预发布]: SCBench，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F96 中实现\n* 功能(MInference): 支持 transformers>=4.46.0，新增分块 MLP，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F133 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F113 中实现\n* 功能(MInference): 更新发布的 CUDA 版本，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F134 中实现\n* 修复(MInference): 修复搜索模式功能，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F156 中修复\n\n#### 运维相关\n* 功能(FlexPrefill): 添加 flex-prefill 功能，由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F100 中实现\n* 功能(MInference): 添加 xAttention，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F149 中实现\n* 功能(MInference): 支持 SGLang 和 vLLM 的 vertical_and_slash flash attention 以及索引核函数，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F153 中实现\n\n### 模型支持\n\n* 功能(MInference): 支持 LLaMA-3-70B-1M 和多 GPU PP，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F59 中实现\n* 功能(MInference): 新增 Qwen-Turbo-1M，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F115、https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F117 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F135 中实现\n* 功能(MInference): 添加 kv_type 单元测试，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F132 中实现\n\n### Bug 修复\n\n* 修复(MInference): 修复端到端基准测试指南及 A 形多 GPU 问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F66 中修复\n* 修复(MInference): 修复 vs 模式下的损失 \u002F sqrt(dk) 问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F70 中修复\n* 修复(SCBench): 修复流水线和数据集加载问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F101 中修复\n* 修复(SCBench): 修复默认序列长度问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F104 中修复\n* 功能(SCBench): 更新 scbench 脚本，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F105 中实现\n* 修复(SCBench): 修复 `use_cache == False` 时的 bug，由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F106 中修复\n* 功能(MInference): 支持 streaming_kernel 的 192 维，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F125 中实现\n* 修复 model2path.py 中的 Qwen 配置路径问题，由 @GuoYiFantastic 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F130 中修复\n* 修复(MInference): 修复获取配置的问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F121 中修复\n* 修复(MInference): 修复残差问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F136 中修复\n* 修复(MInference): 修复多工作进程问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F152 中修复\n* 修复拼写错误，由 @DefTruth 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F141 中完成\n\n## 新贡献者\n* @GuoYiFantastic 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F130 中完成了首次贡献\n* @DefTruth 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F141 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMIn","2025-06-17T09:29:24",{"id":154,"version":155,"summary_zh":156,"released_at":157},127329,"v0.1.5.post1","## 变更内容\n* 功能(MInference)：支持 LLaMA-3-70B-1M 和多 GPU 并行处理，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F59 中实现。\n* 修复(MInference)：修复端到端基准测试指南，并修复 A 形多 GPU 配置问题，由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F66 中完成。\n* 修复(MInference)：修复 vs 模式下的损失 \u002F sqrt(dk) 问题，由 @PiotrNawrot 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F70 中解决。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.5...v0.1.5.post1","2024-08-13T09:17:39",{"id":159,"version":160,"summary_zh":161,"released_at":162},127330,"v0.1.5","## 变更内容 #27 \n* 由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F19 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F44 中添加 vllm>=0.4.1\n* 功能（MInference）：更新 Hugging Face 演示信息，感谢 @AK 的赞助，由 @iofu728 完成，见 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F22\n* 功能（MInference）：由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F31 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F32 中添加单元测试\n* 功能（MInference）：由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F35 中添加基于 Triton 的解码功能，以应对 flash_attn 不可用的情况\n* 功能（MInference）：由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F49 中添加使用 vllm 的端到端基准测试\n* 功能（MInference）：由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F54 中支持 Llama 3.1\n* 修复（MInference）：由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F30 中修复导入警告，并修正 apply_rotary_pos… 相关问题\n\n## 新贡献者\n* @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F19 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.4...v0.1.5","2024-07-24T11:25:33",{"id":164,"version":165,"summary_zh":166,"released_at":167},127331,"v0.1.4.post4","## 变更内容\n* 修复程序（MInference）：由 @iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F44 中修复 vllm>=0.4.1 的问题\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.4.post3...v0.1.4.post4","2024-07-16T07:41:20",{"id":169,"version":170,"summary_zh":171,"released_at":172},127332,"v0.1.4.post3","## 变更内容\n* 功能(MInference)：在 flash_attn 不可用的情况下，添加基于 Triton 的解码功能，由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F35 中实现。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.4.post2...v0.1.4.post3","2024-07-15T05:48:18",{"id":174,"version":175,"summary_zh":176,"released_at":177},127333,"v0.1.4.post2","## 变更内容\n* 功能(MInference)：更新 Hugging Face 演示信息，感谢 @AK 由 @iofu728 提供赞助，详见 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F22\n* 功能(MInference)：移除 pycuda；#20\n* 功能(MInference)：支持多 GPU；#25\n* 功能(MInference)：由 @iofu728 添加单元测试，详见 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F31 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F32\n\n- 修复 #28 中的导入警告；\n- 修复 #25 中的 apply_rotary_pos_emb_single 函数；\n- 修复 phi-3 与内核之间的兼容性问题；\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.4.post1...v0.1.4.post2","2024-07-12T07:41:06",{"id":179,"version":180,"summary_zh":181,"released_at":182},127334,"v0.1.4.post1","## 变更内容\n* 由 @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F19 中添加了对 vllm 0.4.2 和 0.4.3 的支持\n\n## 新贡献者\n* @liyucheng09 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F19 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.4...v0.1.4.post1","2024-07-07T07:55:02",{"id":184,"version":185,"summary_zh":186,"released_at":187},127335,"v0.1.4","## 变更内容\n* 修复程序（MInference）：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F14 和 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F15 中修复了 pip 包中的配置文件。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.3...v0.1.4","2024-07-05T08:01:56",{"id":189,"version":190,"summary_zh":191,"released_at":192},127336,"v0.1.3","## 变更内容\n* 功能(MInference)：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F4 中修复了单元测试。\n* 功能(MInference)：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F5 中添加了 arXiv 论文链接。\n* 修复(MInference)：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F6、https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F8、https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F9、https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F10 中修复了 pip 安装问题。\n* 功能(MInference)：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F11 中添加了 bdist 缓存。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.0...v0.1.3","2024-07-04T06:09:43",{"id":194,"version":195,"summary_zh":196,"released_at":197},127337,"v0.1.2","## 变更内容\n* 热修复（MInference）：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F8 中修复了 pip 安装问题。\n* 热修复（MInference）：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F9 中修复了 YAML 文件问题。\n* 热修复（Minference）：@iofu728 在 https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F10 中修复了 YAML 文件问题。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcompare\u002Fv0.1.1...v0.1.2","2024-07-04T05:29:09",{"id":199,"version":200,"summary_zh":201,"released_at":202},127338,"v0.1.0","## Features\r\n- release MInference Code, experiments scirpts, examples, pip package;\r\n- build the github action release pipeline;\r\n- add MInference experiments document @liyucheng09, FAQ;\r\n- add supported models, demo, demo video;\r\n- add project page;\r\n- add three dynamic sparse attention kernel @Starmys;\r\n\r\n## What's Changed\r\n* PreRelease: v0.1.0 by @iofu728 @liyucheng09 @Starmys in https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F2\r\n* Doc(MInference): update paper information by @iofu728 @liyucheng09 @Starmys  in https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F3\r\n\r\n## New Contributors\r\n* @iofu728 @liyucheng09 @Starmys made their first contribution in https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fpull\u002F2\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FMInference\u002Fcommits\u002Fv0.1.0\r\n","2024-07-03T01:47:46"]