[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-alibaba--Pai-Megatron-Patch":3,"tool-alibaba--Pai-Megatron-Patch":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 真正成长为懂上",143909,2,"2026-04-07T11:33:18",[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":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":77,"owner_website":78,"owner_url":79,"languages":80,"stars":89,"forks":90,"last_commit_at":91,"license":92,"difficulty_score":93,"env_os":94,"env_gpu":95,"env_ram":96,"env_deps":97,"category_tags":108,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":110,"updated_at":111,"faqs":112,"releases":142},5238,"alibaba\u002FPai-Megatron-Patch","Pai-Megatron-Patch","The official repo of Pai-Megatron-Patch for LLM & VLM large scale training developed by Alibaba Cloud.","Pai-Megatron-Patch 是阿里云官方推出的深度学习训练工具包，旨在帮助开发者基于 Megatron 框架高效地训练和推理大规模语言模型（LLM）与视觉语言模型（VLM）。随着模型结构日益复杂且参数量突破百亿级，传统使用 Transformers 或 DeepSpeed 的训练方式往往面临效率瓶颈。Pai-Megatron-Patch 正是为解决这一痛点而生，它充分挖掘 GPU 算力潜能，让主流大模型的训练过程更加便捷且高性能。\n\n该工具特别适合从事大模型预训练、微调及强化学习的算法工程师与研究人员。其核心亮点在于深度集成了 Megatron-LM 的各项加速技术，并率先支持了 Qwen3 系列、DeepSeek-V3\u002FR1 以及 Moonlight 等前沿模型的多种训练场景。无论是基础的预训练与监督微调（SFT），还是高难度的 GRPO 强化学习，Pai-Megatron-Patch 都能提供稳定支持。此外，它还创新性地引入了上下文并行（Context Parallel）和序列打包（Sequence Packing）等技术，显著提升了如 Moonlight 等采用 MLA","Pai-Megatron-Patch 是阿里云官方推出的深度学习训练工具包，旨在帮助开发者基于 Megatron 框架高效地训练和推理大规模语言模型（LLM）与视觉语言模型（VLM）。随着模型结构日益复杂且参数量突破百亿级，传统使用 Transformers 或 DeepSpeed 的训练方式往往面临效率瓶颈。Pai-Megatron-Patch 正是为解决这一痛点而生，它充分挖掘 GPU 算力潜能，让主流大模型的训练过程更加便捷且高性能。\n\n该工具特别适合从事大模型预训练、微调及强化学习的算法工程师与研究人员。其核心亮点在于深度集成了 Megatron-LM 的各项加速技术，并率先支持了 Qwen3 系列、DeepSeek-V3\u002FR1 以及 Moonlight 等前沿模型的多种训练场景。无论是基础的预训练与监督微调（SFT），还是高难度的 GRPO 强化学习，Pai-Megatron-Patch 都能提供稳定支持。此外，它还创新性地引入了上下文并行（Context Parallel）和序列打包（Sequence Packing）等技术，显著提升了如 Moonlight 等采用 MLA 架构模型的训练稳定性与效率，并实现了与 ChatLearn、Verl 等生态工具的无缝对接，是构建下一代超大规模模型的理想选择。","## Quick Start\n\n|             |                                                      Megatron-Core                                                       |                                                                                        ChatLearn                                                                                        |    verl     |\n|:------------|:------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------:|\n|Qwen3-Omni  |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_omni\u002FREADME.md)| N\u002FA | Coming Soon |\n|Qwen3-Next  |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_next\u002FREADME.md)| [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FChatLearn\u002Fblob\u002Fmain\u002Fdocs\u002Fzh\u002Ftutorial\u002Ftutorial_grpo_mcore_qwen3_next.md) | Coming Soon |\n|Qwen3       |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME.md)|[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME_chatlearn.md) | [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME_verl.md) |\n|Qwen3-VL  | [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_vl\u002FREADME.md)| N\u002FA | Coming Soon |\n|Qwen2.5-VL  |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen2_5_vl\u002FREADME.md)| [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FChatLearn\u002Fblob\u002Fmain\u002Fdocs\u002Fzh\u002Ftutorial\u002Ftutorial_grpo_mcore_qwenvl.md) | N\u002FA |\n|Moonlight   |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME.md)|[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME_chatlearn.md)| [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME_verl.md) |\n|DeepSeek-V3 |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME.md)| N\u002FA | N\u002FA |\n|DeepSeek-R1 | N\u002FA |[ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME_chatlearn.md)| [ReadMe](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME_verl.md) |\n\n\n## Introduction\nEnglish | [简体中文](.\u002FREADME_zh-CN.md)\n\nPai-Megatron-Patch (https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch) is a deep learning training toolkit built for developers to train and predict LLMs & VLMs by using Megatron framework easily. With the continuous development of LLMs, the model structure and scale are rapidly evolving. Although these models can be conveniently manufactured using Transformers or DeepSpeed training framework, the training efficiency is comparably low. This phenomenon becomes even severer when the model scale exceeds 10 billion. The primary objective of Pai-Megatron-Patch is to effectively utilize the computational power of GPUs for LLM. This tool allows convenient training of commonly used LLM with all the accelerating techniques provided by Megatron-LM.\n\nWhat's New:\n- **[Experimental]Support Qwen3-Omni-thinker SFT using Megatron-Core** [🔥🔥 2025.11.12]\n- **Support Qwen3-Next-80B-A3B Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.10.17]\n- **Support Qwen3-VL series Pre-Training using Megatron-Core** [🔥🔥 2025.10.17]\n- **Improve MLA models such as Moonlight\u002FDeepSeek-V3 RL Training Stability and Efficiency with Context Parallel and Sequence Packing** [🔥🔥 2025.10.10]\n- **[Experimental]Support Qwen3-Next-80B-A3B Pre-Training using Megatron-Core** [🔥🔥 2025.09.22]\n- **Support Qwen3 & DeepSeek-R1 GRPO Reinforcement Training using Megatron-Core and Verl** [🔥🔥 2025.09.19]\n- **Support Moonlight GRPO Reinforcement Training using Megatron-Core and Verl** [🔥🔥 2025.09.11]\n- **Support Verl smoothly load distributed checkpoints from Pai-Megatron-Patch High-Performance DistCKPT Convertor** [🔥🔥 2025.09.05]\n- **Support all Mcore Models Context Parallel Reinforcement Training via ChatLearn** [🔥🔥 2025.08.31]\n- **Support all Mcore Models GSPO Reinforcement Training via ChatLearn** [🔥🔥 2025.08.11]\n- **Support DeepSeek-V3-671B GRPO Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.07.31]\n- **Support Qwen3-235B GRPO Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.07.20]\n- **Support Moonlight GRPO Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.06.30]\n- **Support Qwen3 GRPO Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.06.03]\n- **Support Qwen2.5 GRPO Reinforcement Training using Megatron-Core and ChatLearn** [🔥🔥 2025.05.18]\n- **Support all Qwen3 Training with torch_dist checkpoint** [🔥🔥 2025.04.29]\n- **[Experimental]Support distributed checkpoint conversion for large LLM** [🔥🔥 2025.04.16]\n- **Upgrade DeepSeek-V3 SFT with fully Mcore implementation.** [🔥🔥 2025.03.31]\n- **Support training QwQ by using Megatron-Core.** [🔥🔥 2025.03.27]\n- **Support training Qwen2.5-VL by using Megatron-Core.** [🔥🔥 2025.03.21]\n- **Support training Moonlight-16B-A3B from Moonshot AI KIMI by using Megatron-Core.** [🔥🔥 2025.03.14]\n- **Optimize Checkpoint Conversion of DeepSeek-V3 and add support training with ETP** [🔥🔥 2025.03.14]\n- **Support training DeepSeek-V3 671B model by using Megatron-Core.** [🔥🔥 2025.02.21]\n- **Upgrade LLM SFT Training Process** [🔥🔥 2025.02.20]\n- **Upgrade DeepSeek-V2-MoE for facilitating a smooth transition to integrating the DeepSeek-V3-MoE.** [🔥🔥 2025.01.16]\n- **Upgrade Qwen2-VL models to support Sequence Parallel, VPP and TP-Comm-Overlap.** [🔥🔥 2025.01.15]\n- **Upgrade Qwen2-VL models to support MG2HF ckpts conversion and training with multi-turn complex multimodal samples.** [🔥🔥 2024.12.27]\n- **Support training Qwen2-VL models by using Megatron-Core.** [🔥🔥 2024.11.27]\n- **Support training LLaVA models by using Megatron-Core.** [🔥🔥 2024.11.20]\n- **Add llm auto configurator and apply per seq sft loss for qwen2\u002F2.5 models.** [🔥🔥 2024.10.30]\n- **Upgrade deepseek-v2-moe models to support MLA via transformer engine and pipeline ckpts conversion.** [🔥🔥 2024.09.26]\n- **Support training Qwen2.5 models by using Megatron-Core.** [🔥🔥 2024.09.20]\n- **Support Sequence Packing in SFT for Qwen2 and LLaMA 3.1 models.** [🔥🔥 2024.09.13]\n- **Upgrade qwen2 dense and moe models to support Flash-Attention 3, Offloading, Comm-Overlapping features.** [🔥🔥 2024.08.26]\n- **Support training LLaMA 3.1 dense models with Flash-Attention 3 backend.** [🔥🔥 2024.08.23]\n- **Support training LLaMA 3.1 dense models by using Megatron-Core.** [🔥🔥 2024.08.23]\n- **Support auto optimizer offloading in OffloadDistributedOptimizer.** [🔥🔥 2024.07.25]\n- **Support static optimizer offloading in OffloadDistributedOptimizer.** [🔥🔥 2024.07.15]\n- **Support training qwen2 moe models by using Megatron-Core.** [🔥🔥 2024.06.19]\n- **Support training qwen2 dense models by using Megatron-Core.** [🔥🔥 2024.06.12]\n- **Support training deepseek-v2-moe models by using Megatron-Core.** [🔥🔥 2024.05.30]\n- **Support training qwen1.5-moe models by using Megatron-Core.** [🔥🔥 2024.05.13]\n- **Support training llama3 models by using Megatron-LM and Megatron-Core.** [🔥🔥 2024.04.21]\n- **Support training qwen1.5 models by using Megatron-Core.** [🔥🔥 2024.03.20]\n- **Support training qwen1.5 models by using Megatron-LM.** [🔥🔥 2024.02.28]\n- **Support training mixtral-8x7b moe model by using Megatron-Core.** [🔥🔥 2024.01.26]\n- **Support training qwen-vl multimodel by using Megatron-LM.** [🔥🔥 2023.12.15]\n- **Support training LLava multimodel by using Megatron-LM.** [🔥🔥 2023.12.01]\n- **Support training deepseek model by using Megatron-LM.** [🔥🔥 2023.11.24]\n- **Support training qwen-72B model by using Megatron-LM.** [🔥🔥 2023.11.23]\n- **Support training Mistral-7B, Yi-6B and Codellama-34B** [🔥🔥 2023.11.16]\n- **Upgrade Megatron-LM for Llama2, qwen and baichuan2 to use transformer engine and fp8.** [🔥🔥 2023.10.19]\n- **Support training qwen-14B and baichuan2-13B model by using Megatron-LM.** [🔥🔥 2023.10.08]\n\n## Highlights\nPai-Megatron-Patch is developed by the Alibaba Cloud Machine Learning Platform (PAI) algorithm team.  The tool aims to assist developers in quickly getting started with Lingjun products and completing the entire development pipeline for LLM, including efficient distributed training, supervised fine-tuning, and offline model inference or verification. It has several merits as follows:\n\n- Support for multiple commonly used LLM such as llama, llama-2, codellama, deepseek, baichuan, qwen, Falcon, GLM, Starcoder, Bloom, chatglm, etc.\n- Support for model weight conversion: Mapping operator namespaces between Huggingface, Megatron, and Transformer Engine.\n- Support for FP8 training acceleration in Flash Attention 2.0 and Transformer Engine modes, ensuring training convergence.\n- Rich and user-friendly usage examples, offering best practices for the entire workflow of LLM pre-training, fine-tuning, evaluation, and inference, as well as reinforcement learning.\n\n## Framework\nThe design philosophy of Pai-Megatron-Patch is to avoid invasive modifications to the source code of Megatron-LM. In other words, it does not add new modules directly to Megatron-LM. Instead, the functions that need expansion and improvement are presented in the form of patch. This decoupling ensures that users can continue to embrace the best practices of LLM without being affected by upgrades of Megatron-LM.\n\nPai-Megatron-Patch includes key components for building LLM training, such as model library, tokenizers, model convertors, reinforcement learning , offline text generation, usages examples, and toolkits. The model library provides popular LLMs implemented in Megatron, such as baichuan, bloom, chatglm, falcon, galactica, glm, llama, qwen, and starcoder. More Megatron-based implementations of LLMs will be added as needed in the future. Additionally, the patch provides bidirectional conversion between Huggingface and Megatron model weights. This allows users to easily utilize Huggingface pretrained models for continued pre-training or fine-tuning in Megatron, as well as evaluating model quality using Huggingface's evaluation\u002Finference pipelines on trained Megatron models.\n\nIn the reinforcement learning section, the patch offers PPO training workflows, enabling users to perform reinforcement learning with SFT models and RM models. Finally, the patch provides numerous usage examples to help users quickly start LLMs training and offline inference. For specific usage processes within Alibaba Cloud Lingjun products, please refer to the following link: [PAI-Lingjun Intelligent Computing Service LLM solution](https:\u002F\u002Fwww.aliyun.com\u002Fsolution\u002Ftech-solution\u002Fpai_lingjun).\n\n\u003Cdiv align=center>\n\u003Cimg src=patch.png width=600 height=400 \u002F>\n\u003C\u002Fdiv>\n\n\n## Technical Reports\n- [基于PAI-ChatLearn的GSPO强化学习实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FODl1_yZk-cJdBdE7TwLAZA)\n- [基于 Megatron 的多模态大模型训练加速技术解析](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FUSMOkRuy-J5UpxyluqsBmg)\n- [Pai-Megatron-Patch：围绕Megatron-Core打造大模型训练加速生态](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FBGyiJ90ZB75s3EP74KogeA)\n- [Meta Llama3.1模型在PAI-Megatron-Patch的最佳实践](https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fpai\u002Fuse-cases\u002Fbest-practice-for-llama-3-1-in-pai-megatron-patch?spm=a2c4g.11186623.0.0.4cef730eqWHNY7)\n- [基于Megatron-Core的稀疏大模型训练工具：阿里云MoE大模型最佳实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FDkrWEEJ7IxirwWd3qB9Bng)\n- [Mixtral-8x7B在PAI灵骏的训练指南](https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fpai\u002Fuse-cases\u002Ftrain-fine-tune-and-deploy-mixtral-by-using-intelligent-computing-lingjun)\n- [通义千问开源模型在PAI灵骏的最佳实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs?__biz=Mzg4MzgxNDk2OA==&mid=2247491796&idx=1&sn=dc1d719313d794ae1aacdb07669a9545&chksm=cf430783f8348e950218bfcff861a2e6d2d92705807bf5b04f6e9268cc510ffa6e6aa2c87327#rd)\n- [阿里云机器学习PAI开源AI大模型训练工具Pai-Megatron-Patch, 助力大模型技术落地](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F655942437)\n- [基于单机最高能效270亿参数GPT模型的文本生成与理解](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F597652820)\n- [中文稀疏GPT大模型落地 — 通往低成本&高性能多任务通用自然语言理解的关键里程碑](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F561320982)\n- [预训练知识度量比赛夺冠！阿里云PAI发布知识预训练工具](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F449487792)\n- [阿里云PAI获得FewCLUE基于大模型的小样本学习双料冠军](https:\u002F\u002Fdeveloper.aliyun.com\u002Farticle\u002F788081?spm=a2c6h.12873639.article-detail.17.11c5383cHpFZks&tlog=yuekan_8)\n\n\n## Contact\nUse [Dingtalk](https:\u002F\u002Fwww.dingtalk.com\u002Fen) to scan blow QR code.\n\nNote: group 1 and 2 is full, please add group 3.  \n\u003Cdiv align=center>\n\u003Cimg src=qr.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=center>\n\u003Cimg src=qr2.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=center>\n\u003Cimg src=qr3.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n## License\nThis project is licensed under the [Apache License (Version 2.0)](https:\u002F\u002Fgithub.com\u002Falibaba\u002Fpai-megatron-patch\u002Fblob\u002Fmaster\u002FLICENSE). This toolkit also contains some code modified from other repos under other open-source licenses. See the [NOTICE](https:\u002F\u002Fgithub.com\u002Falibaba\u002Fpai-megatron-patch\u002Fblob\u002Fmaster\u002FNOTICE) file for more information.\n","## 快速入门\n\n|             |                                                      Megatron-Core                                                       |                                                                                        ChatLearn                                                                                        |    verl     |\n|:------------|:------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------:|\n|Qwen3-Omni  |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_omni\u002FREADME.md)| 无 | 即将推出 |\n|Qwen3-Next  |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_next\u002FREADME.md)| [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FChatLearn\u002Fblob\u002Fmain\u002Fdocs\u002Fzh\u002Ftutorial\u002Ftutorial_grpo_mcore_qwen3_next.md) | 即将推出 |\n|Qwen3       |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME.md)|[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME_chatlearn.md) | [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3\u002FREADME_verl.md) |\n|Qwen3-VL  | [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen3_vl\u002FREADME.md)| 无 | 即将推出 |\n|Qwen2.5-VL  |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fqwen2_5_vl\u002FREADME.md)| [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FChatLearn\u002Fblob\u002Fmain\u002Fdocs\u002Fzh\u002Ftutorial\u002Ftutorial_grpo_mcore_qwenvl.md) | 无 |\n|Moonlight   |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME.md)|[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME_chatlearn.md)| [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fmoonlight\u002FREADME_verl.md) |\n|DeepSeek-V3 |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME.md)| 无 | 无 |\n|DeepSeek-R1 | 无 |[使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME_chatlearn.md)| [使用说明](https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fblob\u002Fmain\u002Fexamples\u002Fdeepseek_v3\u002FREADME_verl.md) |\n\n## 简介\n英语 | [简体中文](.\u002FREADME_zh-CN.md)\n\nPai-Megatron-Patch（https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch）是一款专为开发者打造的深度学习训练工具包，旨在帮助用户轻松使用Megatron框架训练和预测大语言模型（LLM）及多模态模型（VLM）。随着大语言模型的不断发展，模型结构和规模也在迅速演进。尽管这些模型可以借助Transformers或DeepSpeed等训练框架便捷地构建，但其训练效率相对较低。当模型规模超过100亿参数时，这一问题尤为突出。Pai-Megatron-Patch的主要目标是高效利用GPU的计算资源来加速大语言模型的训练。该工具支持使用Megatron-LM提供的所有加速技术，方便用户训练常用的大语言模型。\n\n最新动态：\n- **[实验性] 支持使用Megatron-Core进行Qwen3-Omni-thinker SFT训练** [🔥🔥 2025.11.12]\n- **支持使用Megatron-Core和ChatLearn进行Qwen3-Next-80B-A3B强化训练** [🔥🔥 2025.10.17]\n- **支持使用Megatron-Core进行Qwen3-VL系列预训练** [🔥🔥 2025.10.17]\n- **通过上下文并行和序列打包技术，提升Moonlight\u002FDeepSeek-V3等MLA模型RL训练的稳定性和效率** [🔥🔥 2025.10.10]\n- **[实验性] 支持使用Megatron-Core进行Qwen3-Next-80B-A3B预训练** [🔥🔥 2025.09.22]\n- **支持使用Megatron-Core和Verl进行Qwen3及DeepSeek-R1 GRPO强化训练** [🔥🔥 2025.09.19]\n- **支持使用Megatron-Core和Verl进行Moonlight GRPO强化训练** [🔥🔥 2025.09.11]\n- **支持Verl无缝加载来自Pai-Megatron-Patch高性能DistCKPT转换器的分布式检查点** [🔥🔥 2025.09.05]\n- **支持所有Mcore模型通过ChatLearn进行上下文并行强化训练** [🔥🔥 2025.08.31]\n- **支持所有Mcore模型通过ChatLearn进行GSPO强化训练** [🔥🔥 2025.08.11]\n- **支持使用Megatron-Core和ChatLearn进行DeepSeek-V3-671B GRPO强化训练** [🔥🔥 2025.07.31]\n- **支持使用Megatron-Core和ChatLearn进行Qwen3-235B GRPO强化训练** [🔥🔥 2025.07.20]\n- **支持使用Megatron-Core和ChatLearn进行Moonlight GRPO强化训练** [🔥🔥 2025.06.30]\n- **支持使用Megatron-Core和ChatLearn进行Qwen3 GRPO强化训练** [🔥🔥 2025.06.03]\n- **支持使用Megatron-Core和ChatLearn进行Qwen2.5 GRPO强化训练** [🔥🔥 2025.05.18]\n- **支持所有Qwen3模型使用torch_dist检查点进行训练** [🔥🔥 2025.04.29]\n- **[实验性] 支持大型LLM的分布式检查点转换** [🔥🔥 2025.04.16]\n- **全面升级DeepSeek-V3 SFT，实现完全基于Mcore的实现。** [🔥🔥 2025.03.31]\n- **支持使用Megatron-Core训练QwQ模型。** [🔥🔥 2025.03.27]\n- **支持使用Megatron-Core训练Qwen2.5-VL模型。** [🔥🔥 2025.03.21]\n- **支持使用Megatron-Core从Moonshot AI KIMI处训练Moonlight-16B-A3B模型。** [🔥🔥 2025.03.14]\n- **优化DeepSeek-V3的检查点转换，并新增支持ETP训练的功能。** [🔥🔥 2025.03.14]\n- **支持使用Megatron-Core训练DeepSeek-V3 671B模型。** [🔥🔥 2025.02.21]\n- **升级LLM SFT训练流程** [🔥🔥 2025.02.20]\n- **升级DeepSeek-V2-MoE，以促进顺利过渡到集成DeepSeek-V3-MoE。** [🔥🔥 2025.01.16]\n- **升级Qwen2-VL模型，支持序列并行、VPP和TP通信重叠功能。** [🔥🔥 2025.01.15]\n- **升级Qwen2-VL模型，支持MG2HF检查点转换以及多轮复杂多模态样本的训练。** [🔥🔥 2024.12.27]\n- **支持使用Megatron-Core训练Qwen2-VL模型。** [🔥🔥 2024.11.27]\n- **支持使用Megatron-Core训练LLaVA模型。** [🔥🔥 2024.11.20]\n- **新增LLM自动配置器，并为qwen2\u002F2.5模型应用每序列SFT损失。** [🔥🔥 2024.10.30]\n- **升级deepseek-v2-moe模型，支持通过Transformer引擎和流水线检查点转换实现MLA。** [🔥🔥 2024.09.26]\n- **支持使用Megatron-Core训练Qwen2.5模型。** [🔥🔥 2024.09.20]\n- **支持在Qwen2和LLaMA 3.1模型的SFT中使用序列打包技术。** [🔥🔥 2024.09.13]\n- **升级qwen2密集型和Moe模型，支持Flash-Attention 3、卸载和通信重叠等功能。** [🔥🔥 2024.08.26]\n- **支持使用Flash-Attention 3后端训练LLaMA 3.1密集型模型。** [🔥🔥 2024.08.23]\n- **支持使用Megatron-Core训练LLaMA 3.1密集型模型。** [🔥🔥 2024.08.23]\n- **支持在OffloadDistributedOptimizer中启用自动优化器卸载功能。** [🔥🔥 2024.07.25]\n- **支持在OffloadDistributedOptimizer中启用静态优化器卸载功能。** [🔥🔥 2024.07.15]\n- **支持使用Megatron-Core训练qwen2 Moe模型。** [🔥🔥 2024.06.19]\n- **支持使用Megatron-Core训练qwen2密集型模型。** [🔥🔥 2024.06.12]\n- **支持使用Megatron-Core训练deepseek-v2-moe模型。** [🔥🔥 2024.05.30]\n- **支持使用Megatron-Core训练qwen1.5-Moe模型。** [🔥🔥 2024.05.13]\n- **支持使用Megatron-LM和Megatron-Core训练llama3模型。** [🔥🔥 2024.04.21]\n- **支持使用Megatron-Core训练qwen1.5模型。** [🔥🔥 2024.03.20]\n- **支持使用Megatron-LM训练qwen1.5模型。** [🔥🔥 2024.02.28]\n- **支持使用Megatron-Core训练mixtral-8x7b Moe模型。** [🔥🔥 2024.01.26]\n- **支持使用Megatron-LM训练qwen-VL多模态模型。** [🔥🔥 2023.12.15]\n- **支持使用Megatron-LM训练LLava多模态模型。** [🔥🔥 2023.12.01]\n- **支持使用Megatron-LM训练deepseek模型。** [🔥🔥 2023.11.24]\n- **支持使用Megatron-LM训练qwen-72B模型。** [🔥🔥 2023.11.23]\n- **支持训练Mistral-7B、Yi-6B和Codellama-34B模型。** [🔥🔥 2023.11.16]\n- **升级Megatron-LM，使Llama2、qwen和baichuan2能够使用Transformer引擎和FP8精度。** [🔥🔥 2023.10.19]\n- **支持使用Megatron-LM训练qwen-14B和baichuan2-13B模型。** [🔥🔥 2023.10.08]\n\n## 亮点\nPai-Megatron-Patch由阿里云机器学习平台（PAI）算法团队开发。该工具旨在帮助开发者快速上手Lingjun系列产品，并完成大语言模型的完整开发流程，包括高效的分布式训练、监督微调以及离线模型推理或验证。其主要优势如下：\n\n- 支持多种常用的大语言模型，如llama、llama-2、codellama、deepseek、baichuan、qwen、Falcon、GLM、Starcoder、Bloom、chatglm等。\n- 支持模型权重转换：实现Huggingface、Megatron和Transformer Engine之间算子命名空间的映射。\n- 支持在Flash Attention 2.0和Transformer Engine模式下进行FP8训练加速，确保训练收敛。\n- 提供丰富且易用的使用示例，涵盖大语言模型预训练、微调、评估、推理以及强化学习的全流程最佳实践。\n\n## 框架\nPai-Megatron-Patch 的设计理念是避免对 Megatron-LM 源代码进行侵入性修改。换言之，它不会直接向 Megatron-LM 添加新模块。相反，需要扩展和改进的功能以补丁的形式呈现。这种解耦设计确保用户在不受到 Megatron-LM 升级影响的情况下，仍能持续采用 LLM 领域的最佳实践。\n\nPai-Megatron-Patch 包含构建 LLM 训练所需的关键组件，例如模型库、分词器、模型转换工具、强化学习模块、离线文本生成工具、使用示例以及工具包。模型库提供了基于 Megatron 实现的热门 LLM，如 Baichuan、BLOOM、ChatGLM、Falcon、Galactica、GLM、Llama、Qwen 和 StarCoder 等。未来还将根据需求添加更多基于 Megatron 的 LLM 实现。此外，该补丁还支持 Hugging Face 和 Megatron 模型权重之间的双向转换。这使得用户能够轻松地将 Hugging Face 预训练模型用于 Megatron 中的继续预训练或微调，同时也可以利用 Hugging Face 的评估\u002F推理流水线对已训练的 Megatron 模型进行质量评估。\n\n在强化学习部分，该补丁提供了 PPO 训练工作流，使用户能够使用 SFT 模型和 RM 模型进行强化学习。最后，该补丁还提供了大量使用示例，帮助用户快速启动 LLM 训练和离线推理。关于阿里云灵骏产品中的具体使用流程，请参阅以下链接：[PAI-灵骏智能计算服务 LLM 解决方案](https:\u002F\u002Fwww.aliyun.com\u002Fsolution\u002Ftech-solution\u002Fpai_lingjun)。\n\n\u003Cdiv align=center>\n\u003Cimg src=patch.png width=600 height=400 \u002F>\n\u003C\u002Fdiv>\n\n\n## 技术报告\n- [基于PAI-ChatLearn的GSPO强化学习实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FODl1_yZk-cJdBdE7TwLAZA)\n- [基于 Megatron 的多模态大模型训练加速技术解析](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FUSMOkRuy-J5UpxyluqsBmg)\n- [Pai-Megatron-Patch：围绕Megatron-Core打造大模型训练加速生态](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FBGyiJ90ZB75s3EP74KogeA)\n- [Meta Llama3.1模型在PAI-Megatron-Patch的最佳实践](https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fpai\u002Fuse-cases\u002Fbest-practice-for-llama-3-1-in-pai-megatron-patch?spm=a2c4g.11186623.0.0.4cef730eqWHNY7)\n- [基于Megatron-Core的稀疏大模型训练工具：阿里云MoE大模型最佳实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FDkrWEEJ7IxirwWd3qB9Bng)\n- [Mixtral-8x7B在PAI灵骏的训练指南](https:\u002F\u002Fhelp.aliyun.com\u002Fzh\u002Fpai\u002Fuse-cases\u002Ftrain-fine-tune-and-deploy-mixtral-by-using-intelligent-computing-lingjun)\n- [通义千问开源模型在PAI灵骏的最佳实践](https:\u002F\u002Fmp.weixin.qq.com\u002Fs?__biz=Mzg4MzgxNDk2OA==&mid=2247491796&idx=1&sn=dc1d719313d794ae1aacdb07669a9545&chksm=cf430783f8348e950218bfcff861a2e6d2d92705807bf5b04f6e9268cc510ffa6e6aa2c87327#rd)\n- [阿里云机器学习PAI开源AI大模型训练工具Pai-Megatron-Patch, 助力大模型技术落地](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F655942437)\n- [基于单机最高能效270亿参数GPT模型的文本生成与理解](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F597652820)\n- [中文稀疏GPT大模型落地 — 通往低成本&高性能多任务通用自然语言理解的关键里程碑](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F561320982)\n- [预训练知识度量比赛夺冠！阿里云PAI发布知识预训练工具](https:\u002F\u002Fzhuanlan.zhihu.com\u002Fp\u002F449487792)\n- [阿里云PAI获得FewCLUE基于大模型的小样本学习双料冠军](https:\u002F\u002Fdeveloper.aliyun.com\u002Farticle\u002F788081?spm=a2c6h.12873639.article-detail.17.11c5383cHpFZks&tlog=yuekan_8)\n\n\n## 联系方式\n请使用 [钉钉](https:\u002F\u002Fwww.dingtalk.com\u002Fen) 扫描下方二维码加入群组。\n\n注意：群 1 和 2 已满员，请加入群 3。  \n\u003Cdiv align=center>\n\u003Cimg src=qr.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=center>\n\u003Cimg src=qr2.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=center>\n\u003Cimg src=qr3.png width=600 height=450 \u002F>\n\u003C\u002Fdiv>\n\n## 许可证\n本项目采用 [Apache License (Version 2.0)](https:\u002F\u002Fgithub.com\u002Falibaba\u002Fpai-megatron-patch\u002Fblob\u002Fmaster\u002FLICENSE) 许可证。此外，该工具包还包含从其他仓库基于不同开源许可证修改而来的部分代码。更多信息请参阅 [NOTICE](https:\u002F\u002Fgithub.com\u002Falibaba\u002Fpai-megatron-patch\u002Fblob\u002Fmaster\u002FNOTICE) 文件。","# Pai-Megatron-Patch 快速上手指南\n\nPai-Megatron-Patch 是由阿里云 PAI 团队开发的深度学习训练工具包，旨在帮助开发者基于 Megatron 框架高效地训练和推理大语言模型（LLM）及多模态大模型（VLM）。它支持 Qwen、DeepSeek、Llama 等主流模型，并提供从预训练、微调（SFT）到强化学习（RLHF\u002FGRPO）的全流程加速方案。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu 20.04\u002F22.04 或 CentOS 7+)\n*   **GPU**: NVIDIA GPU (建议显存充足以支持大模型分布式训练)\n*   **CUDA**: 根据显卡驱动版本安装对应的 CUDA Toolkit (通常建议 11.8 或 12.x)\n*   **Python**: 3.8 - 3.10\n*   **前置依赖**:\n    *   PyTorch (需与 CUDA 版本匹配)\n    *   NVIDIA Apex (可选，用于混合精度训练)\n    *   Transformer Engine (推荐，用于 FP8 加速)\n    *   Git\n\n> **提示**：推荐使用阿里云 PAI-DSW 或灵骏智算服务，这些环境已预装相关依赖并针对国内网络进行了优化。\n\n## 2. 安装步骤\n\n### 步骤一：克隆项目代码\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch.git\ncd Pai-Megatron-Patch\n```\n\n### 步骤二：安装核心依赖\n\n建议使用虚拟环境（如 conda）进行隔离。以下命令将安装 Megatron-Core 及项目所需的基础库。\n\n```bash\n# 创建并激活 conda 环境 (示例)\nconda create -n mpatch python=3.10 -y\nconda activate mpatch\n\n# 安装 PyTorch (请以官方推荐的与您 CUDA 版本匹配的命令为准)\n# pip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n\n# 安装项目依赖\npip install -r requirements.txt\n```\n\n### 步骤三：配置环境变量与路径\n\n为了方便调用，建议将项目根目录添加到 `PYTHONPATH`：\n\n```bash\nexport PYTHONPATH=$PWD:$PYTHONPATH\n```\n\n如果您需要使用特定的模型权重转换工具或强化学习框架（如 ChatLearn 或 Verl），请参考对应模型目录下的 `README` 安装额外依赖。\n\n## 3. 基本使用\n\nPai-Megatron-Patch 针对不同模型（如 Qwen3, DeepSeek-V3, Moonlight 等）和不同任务（预训练、SFT、RL）提供了独立的示例脚本。以下以 **Qwen3 模型的监督微调（SFT）** 为例展示最简使用流程。\n\n### 3.1 准备数据与权重\n\n确保您已准备好 HuggingFace 格式的模型权重和数据集。Pai-Megatron-Patch 支持自动将 HF 权重转换为 Megatron 格式。\n\n### 3.2 运行微调任务\n\n进入对应模型的示例目录（例如 `examples\u002Fqwen3`），使用提供的启动脚本运行任务。\n\n```bash\ncd examples\u002Fqwen3\n\n# 运行 SFT 训练脚本\n# 请根据实际机器配置修改 --nproc_per_node 和其他超参数\npython train_sft.py \\\n    --model-name-or-path \u002Fpath\u002Fto\u002Fqwen3-hf-model \\\n    --data-path \u002Fpath\u002Fto\u002Ftrain_data.jsonl \\\n    --output-dir .\u002Foutput_qwen3_sft \\\n    --per-device-train-batch-size 1 \\\n    --gradient-accumulation-steps 4 \\\n    --learning-rate 1e-5 \\\n    --num-train-epochs 3 \\\n    --fp16\n```\n\n### 3.3 进阶：使用强化学习 (GRPO)\n\n若需进行强化学习训练（如使用 ChatLearn 或 Verl 框架），请参考对应模型的专用文档。例如，对 Qwen3 使用 Verl 进行 GRPO 训练：\n\n```bash\n# 在 examples\u002Fqwen3 目录下\npython train_grpo_verl.py \\\n    --sft-model-path .\u002Foutput_qwen3_sft \\\n    --reward-model-path \u002Fpath\u002Fto\u002Frm-model \\\n    --prompt-data-path \u002Fpath\u002Fto\u002Fprompts.jsonl \\\n    --algo grpo\n```\n\n> **注意**：具体参数配置（如张量并行 TP、流水线并行 PP、序列并行 SP 等）需根据您的集群规模调整。详细参数说明请查阅各模型文件夹下的 `README.md` 文件（如 `examples\u002Fqwen3\u002FREADME.md`）。\n\n### 3.4 模型权重转换\n\n训练完成后，如需将 Megatron 格式的 checkpoint 转回 HuggingFace 格式以便推理或上传，可使用内置转换工具：\n\n```bash\npython tools\u002Fconvert_checkpoint\u002Fconvert_mcore_to_hf.py \\\n    --input-dir .\u002Foutput_qwen3_sft\u002Fcheckpoints\u002Fiter_XXX \\\n    --output-dir .\u002Fhf_qwen3_final \\\n    --model-type qwen3\n```","某大型科技公司算法团队正致力于基于 Qwen3-Next 架构训练一个 800 亿参数的行业垂直大模型，以应对复杂的金融推理任务。\n\n### 没有 Pai-Megatron-Patch 时\n- **训练效率低下**：直接使用原生 Transformers 或基础 DeepSpeed 框架，在处理超大规模参数时显存利用率不足，导致单卡吞吐量极低，训练周期被无限拉长。\n- **并行策略复杂**：面对 80B 量级模型，手动配置数据并行、张量并行及流水线并行极其繁琐，极易因配置错误导致显存溢出（OOM）或通信死锁。\n- **强化学习难落地**：想要引入 GRPO 等先进强化学习算法进行对齐优化时，缺乏与 Megatron 内核的高效集成，代码适配成本高且运行不稳定。\n- **新架构支持滞后**：对于 Qwen3-Next 等最新模型的稀疏注意力（MoE）或多查询注意力机制，开源社区通用方案往往支持滞后，需自行修改底层算子。\n\n### 使用 Pai-Megatron-Patch 后\n- **极致算力释放**：Pai-Megatron-Patch 内置了针对阿里云 GPU 优化的 Megatron-LM 加速技术，显著提升了千亿参数模型的训练吞吐，将预计训练时间从数周缩短至数天。\n- **一键式并行配置**：工具提供了开箱即用的混合并行模板，自动管理复杂的切分逻辑，团队无需关注底层通信细节即可稳定运行超大模型。\n- **无缝集成强化学习**：通过与 ChatLearn 和 Verl 的深度打通，直接支持 Qwen3-Next 的 GRPO 强化训练，让模型对齐流程变得流畅且高效。\n- **前沿模型即时可用**：官方持续更新对 Qwen3 系列及 DeepSeek-V3 等最新架构的支持，团队能立即利用最新的 MoE 结构特性，无需等待社区适配。\n\nPai-Megatron-Patch 通过屏蔽底层分布式训练的复杂性并最大化硬件效能，让企业能够以最低成本快速构建和迭代顶尖规模的行业大模型。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falibaba_Pai-Megatron-Patch_c8d9b40b.png","alibaba","Alibaba","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Falibaba_f65f7221.png","Alibaba Open Source",null,"https:\u002F\u002Fopensource.alibaba.com\u002F","https:\u002F\u002Fgithub.com\u002Falibaba",[81,85],{"name":82,"color":83,"percentage":84},"Python","#3572A5",97.2,{"name":86,"color":87,"percentage":88},"Shell","#89e051",2.8,1552,227,"2026-04-07T10:49:29","Apache-2.0",5,"Linux","必需 NVIDIA GPU。支持 FP8 训练需 Hopper 架构（如 H800\u002FH100）或配合 Transformer Engine；支持 Flash-Attention 2\u002F3。针对 DeepSeek-V3 (671B)、Qwen3 (235B) 等超大模型，需多卡分布式集群环境。","未说明（取决于模型规模，训练千亿参数模型通常需 TB 级系统内存）",{"notes":98,"python":99,"dependencies":100},"该工具主要面向阿里云 PAI-Lingjun 智能计算服务及大规模分布式训练场景。核心特性包括：1. 基于 Megatron-Core 的非侵入式补丁设计；2. 支持 DeepSeek-V3\u002FR1、Qwen3 系列等超大规模 MoE 模型的预训练、SFT 及强化学习（GRPO\u002FGSPO）；3. 提供 Huggingface 与 Megatron 权重双向转换工具；4. 支持 FP8 加速、序列并行、上下文并行及优化器卸载等高级特性。具体环境配置需参考各模型示例目录下的详细文档。","未说明",[101,102,103,104,105,106,107],"Megatron-Core","PyTorch","Transformer Engine","Flash-Attention","ChatLearn","Verl","Huggingface Transformers",[35,14,109],"其他","2026-03-27T02:49:30.150509","2026-04-08T03:54:47.250711",[113,118,123,128,133,138],{"id":114,"question_zh":115,"answer_zh":116,"source_url":117},23748,"在使用 TP > 1 进行训练时遇到 RuntimeError: device_supports_multicast 错误，如何解决？","该问题通常是由于显卡驱动版本过低，无法支持镜像中安装的 CUDA 版本导致的。解决方案是升级显卡驱动到能支持镜像中 CUDA 版本的版本（例如升级到 555.42.02）。此问题与 tp-comm-overlap 设置无关，只需确保驱动版本兼容即可。","https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fissues\u002F399",{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},23749,"DeepSeek V2\u002FV3 模型在保存 checkpoint 时报错或格式不兼容，如何处理？","如果遇到分布式 optimizer sharded state 相关的保存错误或格式问题，可以在训练脚本中添加参数 `--ckpt-format torch`。具体修改位置通常在运行脚本中（例如 `examples\u002Fdeepseek_v2\u002Frun_mcore_deepseek.sh`），将默认的 `torch_dist` 改为 `torch` 格式即可解决兼容性問題。","https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fissues\u002F441",{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},23750,"如何将 Megatron-LM 训练的分布式 checkpoint (torch_dist) 转换为 HuggingFace 格式？","目前社区大多数转换脚本不支持直接转换 `torch_dist` 格式。有两种变通方案：\n1. 在训练脚本中传入 `--ckpt-format torch`（而不是默认的 `torch_dist`），然后使用传统的 `model_checkpoints_convertor` 脚本进行转换。\n2. 基于 `distributed_ckpt_convertor` 编写特定模型（如 Mixtral-8x7B）的转换实现，以支持已保存的分布式 checkpoint 格式。","https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fissues\u002F590",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},23751,"转换 DeepSeek V2\u002FV3 等大模型 checkpoint 时内存占用过高（接近 2T），如何优化？","可以通过在转换命令中添加 `--no-initialization` 开关来避免在内存中初始化完整模型，从而大幅降低内存占用。此外，项目方已发布修复版本（PR #496），建议更新到最新版本或使用该参数进行分布式转换优化。","https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fissues\u002F482",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},23752,"增加 TP\u002FPP 并行度后，模型初始 Loss 异常升高且训练效果下降，是什么原因？","这通常是因为 PP（流水线并行）设置超过了模型层数的合法整除范围。例如 7B 模型共 28 层，不支持 PP=8 或 PP=16 这种无法均匀切分的设置。Megatron 仅在开启 VPP 时才会检查 PP 合法性。建议尝试使用能被层数整除的 PP 值（如 PP=4, PP=7, PP=14）来观察 Loss 是否恢复正常。","https:\u002F\u002Fgithub.com\u002Falibaba\u002FPai-Megatron-Patch\u002Fissues\u002F417",{"id":139,"question_zh":140,"answer_zh":141,"source_url":127},23753,"在转换或加载 checkpoint 时遇到 `_extra_state` 相关的 FP8 错误怎么办？","`_extra_state` 字段包含与 FP8 精度相关的权重信息。如果您没有使用 FP8 精度进行训练或推理，可以安全地移除该字段以解决报错。这通常发生在从不同精度格式转换模型时。",[143,148,153,158,163,168,173,178,183,188,193,198,203,208,213,218,223,228,233,238],{"id":144,"version":145,"summary_zh":146,"released_at":147},145261,"v0.12.3","-- 支持通义千问3-VL系列模型使用Mcore进行微调。  \n-- 支持通义千问3-Next-80B-A3B使用Chatlearn进行强化学习。  \n-- 通过上下文并行（Context Parallel）与序列打包（Sequence Packing）技术，提升Moonlight\u002FDeepSeek-V3等MLA模型强化学习训练的稳定性和效率。  \n-- 修复已知的问题。","2025-10-31T08:26:35",{"id":149,"version":150,"summary_zh":151,"released_at":152},145262,"v0.12.2","-- 支持通义千问3-next使用Mcore进行继续预训练。  \n-- 支持通义千问3、Moonlight和DeepSeek-R1模型通过Megatron-Patch使用Mcore+Verl进行强化学习GRPO训练。  \n-- 支持通义千问2.5-VL使用Chatlearn进行强化学习。  \n-- 优化通义千问2.5-VL多模态大模型训练链路。  \n-- 修复已知的问题。","2025-09-30T03:41:58",{"id":154,"version":155,"summary_zh":156,"released_at":157},145263,"v0.12.1","-- 支持使用 Mcore+ChatLearn 进行强化学习 GSPO 训练。  -- 支持使用 Mcore+ChatLearn 进行强化学习 Context Parallel 上下文并行训练。  -- 优化 Qwen2.5-VL 多模态大模型训练链路。  -- 优化分布式模型权重转换链路。  -- 修复已知的问题。","2025-09-03T03:19:55",{"id":159,"version":160,"summary_zh":161,"released_at":162},145264,"v0.12.0","-- 支持使用 Mcore+ChatLearn 对 DeepSeek-V3-671B 模型进行强化学习 GRPO 训练。  \n-- 验证并支持 Qwen3-235B 模型使用 Mcore+ChatLearn 进行强化学习 GRPO 训练的效果。  \n-- 优化 Qwen2.5-VL 多模态大模型的训练流程。  \n-- 修复已知的问题。","2025-08-01T02:16:46",{"id":164,"version":165,"summary_zh":166,"released_at":167},145265,"v0.11.3","--支持Moonlight MoE模型使用Mcore+ChatLearn进行强化学习GRPO训练。  \n--优化Qwen3 MoE模型使用Mcore+ChatLearn进行强化学习GRPO训练的效果。  \n--DSW调试模式支持自适应卡数感知。  \n--修复已知的issues。","2025-07-02T01:58:37",{"id":169,"version":170,"summary_zh":171,"released_at":172},145266,"v0.11.2","-- 支持使用 Qwen2.5 模型通过 Mcore+ChatLearn 进行强化学习 GRPO 训练\r\n-- 修复已知的问题。","2025-05-27T03:09:58",{"id":174,"version":175,"summary_zh":176,"released_at":177},145267,"v0.11.1","-- 支持通义千问3所有版本模型的最佳实践\n-- 持续优化DeepSeek-V3、通义千问2.5 VL等模型的最佳实践。\n-- 实现用于超大参数量模型的MG\u002FHF权重分布式转换。\n-- 修复已知的问题。","2025-04-30T02:27:33",{"id":179,"version":180,"summary_zh":181,"released_at":182},145268,"v0.11.0","-- 优化 DeepSeek-V3 最佳实践。 -- 升级 Qwen2-moe 最佳实践。 -- 新增 QwQ\u002FQwen2.5-VL\u002F月光模型。 -- 修复已知问题。","2025-03-31T06:43:00",{"id":184,"version":185,"summary_zh":186,"released_at":187},145269,"v0.10.3","-- 接入 DeepSeek-V3 并为其开发最佳实践。  \n-- 升级 SFT 微调流程，所有模型统一采用基于 Template 的微调逻辑。  \n-- 修复已知问题。","2025-02-28T06:40:38",{"id":189,"version":190,"summary_zh":191,"released_at":192},145270,"v0.10.2","-- 将DeepSeek-V2-MoE模型的最优实践升级为接入DeepSeek-V3-MoE的工程加速过渡方案。 -- 扩展Qwen2-VL模型，以支持序列并行、虚拟流水并行及TP-Comm-Overlap特性。 -- 修复已知的问题。","2025-01-24T03:22:35",{"id":194,"version":195,"summary_zh":196,"released_at":197},145271,"v0.10.1","--升级Qwen2-VL模型以支持MG2HF检查点转换，并能够使用多轮复杂的多模态样本进行训练。\r\n\r\n","2025-01-03T06:35:09",{"id":199,"version":200,"summary_zh":201,"released_at":202},145272,"v0.10.0","--添加Mcore版本的Qwen2-VL多模态大模型最佳实践。\r\n--添加Mcore版本的LLava多模态大模型最佳实践。\r\n--修复模型并行训练时hang等Issues。","2024-11-29T06:32:48",{"id":204,"version":205,"summary_zh":206,"released_at":207},145273,"v0.9.3","--优化Qwen2\u002F2.5模型的微调效果，解决梯度累计下的长短样本导致的loss计算问题。\r\n--添加预览版的大模型训练最优吞吐参数配置。\r\n--修复DeepSeekV2的Tokenizer的Issue。\r\n--修复Qwen2\u002F2.5的TE2HF转换Issue。\r\n--修复模型转换体积过大的Issue。","2024-10-30T06:35:30",{"id":209,"version":210,"summary_zh":211,"released_at":212},145274,"v0.9.2","--支持热门模型微调时采用Sequence Packing加速技术。\r\n--支持用Megatron-Core框架训练Qwen2.5系列模型。\r\n--升级Deepseek-V2-MoE系列模型支持TE版的MLA以及流水并行CKPT转换。\r\n--修复已知的Bugs。","2024-09-27T02:23:26",{"id":214,"version":215,"summary_zh":216,"released_at":217},145275,"v0.9.1","--添加LLama3.1最佳实践支持最新的Flash-Attention 3, Offloading, Comm-Overlapping等加速技术。\r\n--升级Qwen2最佳实践支持最新的Flash-Attention 3, Offloading, Comm-Overlapping等加速技术。\r\n--优化PAI算法团队自研的Optimizer Offloading的降显存效果以及吞吐性能。\r\n--修复已知的Bugs。","2024-08-30T03:00:02",{"id":219,"version":220,"summary_zh":221,"released_at":222},145276,"v0.9.0","--添加基于MPI的分布式训练方式，用以支持Mcore的tp-comm-overlap加速开关。\r\n--添加基于Distributed Optimizer改进的OffloadDistributedOptimizer，用以支持大模型&长序列训练时参数\u002F梯度Cpu Offload降显存。\r\n--添加微调训练使用IdxMap数据格式，用以支持70B大模型的打开TP\u002FPP时高效微调。\r\n--修复已知的Bugs。","2024-07-26T06:49:03",{"id":224,"version":225,"summary_zh":226,"released_at":227},145277,"v0.8.3","--添加Qwen-2-Dense\u002FMoE的Mcore实现的最佳实践。\r\n--添加Qwen2系列模型增强型基于Mcore算子赋值技术的模型转换（逐算子逐层前向精度比对，转换浮点控制，支持算子拆分\u002F专家并行\u002F流水并行）\r\n--优化Qwen-2-Dense\u002FMoE的Loss收敛可靠性。\r\n--优化DeepSeek-V2-MoE的收敛效果，支持模型并行的MLA的Loss收敛可靠性问题彻底解决。\r\n--Qwen2的Tokenizer重构支持对接新版Mcore0.7.0。\r\n--修复已知的Bugs。","2024-06-28T03:30:01",{"id":229,"version":230,"summary_zh":231,"released_at":232},145278,"v0.8.2","--添加Qwen-1.5-MoE的Mcore实现。\r\n--添加DeepSeek-V2-MoE的Mcore实现。\r\n--优化MoE的Quick Start使用教程\r\n--修复已知的Bugs。","2024-05-31T06:44:03",{"id":234,"version":235,"summary_zh":236,"released_at":237},145279,"v0.8.1","--添加LLama3，Mistral，Qwen1.5热门大模型在四种工具链模式上的11款Quick Starts。\r\n--接入llama3模型同时支持Megatron-LM和Megatron Core。\r\n--接入Qwen1.5 32B同时支持Megatron-LM和Megatron Core。\r\n--接入MegaBlocks MoE训练流程。\r\n--通过重新梳理整个训练流程，排查各个环节潜在出错并和HF进行精准对齐后继续预训练\u002F微调效果优化取得进展。\r\n--修复已知的Bugs。","2024-04-26T08:00:45",{"id":239,"version":240,"summary_zh":241,"released_at":242},145280,"v0.8.0","‒ 添加qwen1.5模型的Megatron LM和Megatron-Core Transformer Engine实现。\r\n‒ 完成Pai-Megatron-Patch工具基于Instruction Tuning的微调链路HFDS和Megatron引擎的下游任务效果对齐工作。\r\n‒ 基于Megatron-Patch的工具实施的MoE-Upcycled算法取得阶段性成果。\r\n‒ 修复已知的Bugs。","2024-03-21T07:34:23"]