# Colossal-AI

**Colossal-AI** 是一个开源、基于 PyTorch 的深度学习系统，用于大规模并行模型训练，由 HPC-AI 科技公司与[新加坡国立大学](https://www.edgepedia.org/zh/national-university-of-singapore)（National University of Singapore）共同开发。它提供统一接口，可将串行训练代码扩展至分布式环境，支持数据并行、流水线并行、张量并行和[序列并行](https://www.edgepedia.org/zh/sequence-parallelism)，以及异构训练和零冗余优化器；据作者报告，在大规模模型上相比基线系统可实现最高 2.76 倍的训练加速。<sup>[1](https://arxiv.org/abs/2110.14883)</sup>

| 关键事实 | 详情 |
|---|---|
| 首次发布 | 2021 年 10 月开源；系统论文于 2021 年 10 月 28 日由李胜贵（Shenggui Li）、刘洪鑫（Hongxin Liu）、卞正达（Zhengda Bian）、方佳瑞（Jiarui Fang）、黄海辰（Haichen Huang）、刘玉良（Yuliang Liu）、王博翔（Boxiang Wang）和尤洋（Yang You）发布至 arXiv<sup>[1](https://arxiv.org/abs/2110.14883)</sup><sup> • </sup><sup>[2](https://company.hpc-ai.com/blog/colossal-ai-emerges-as-the-go-to-performance-optimization-solution-with-unmatched-community-momentum)</sup> |
| 并行方式 | 数据并行、流水线并行、张量并行（一维、二维、2.5维和三维）、序列并行和混合专家并行，可以混合配置组合使用<sup>[1](https://arxiv.org/abs/2110.14883)</sup><sup> • </sup><sup>[3](https://colossalai.org/docs/get_started/run_demo/)</sup> |
| 报告加速比 | 在大规模模型上相比基线系统最高 2.76 倍训练加速<sup>[1](https://arxiv.org/abs/2110.14883)</sup> |
| 内存管理 | ZeRO 风格的优化器状态、梯度和参数分片，ColossalAI v0.1.8 引入的基于块的内存管理，以及 Gemini 异构内存管理器<sup>[4](https://colossalai.org/docs/features/zero_with_chunk/)</sup><sup> • </sup><sup>[5](https://colossalai.org/docs/advanced_tutorials/meet_gemini/)</sup> |
| 发表 | 发表于 ICPP 2023（第52届国际并行处理会议论文集，第766至775页）<sup>[6](https://github.com/hpcaitech/ColossalAI)</sup> |
| 许可证与版本 | Apache 软件许可证 2.0；PyPI 包名 `colossalai`，最新版本 0.5.0 于 2025 年 6 月 4 日发布<sup>[7](https://pypi.org/project/colossalai/)</sup> |
| 认可 | 2023 年 2 月 GitHub 趋势榜第一，超过 17,000 星标；PyTorch 生态合作伙伴；被 NeurIPS、SC、AAAI、PPoPP、CVPR、ISC 和 NVIDIA GTC 接纳为官方教程<sup>[2](https://company.hpc-ai.com/blog/colossal-ai-emerges-as-the-go-to-performance-optimization-solution-with-unmatched-community-momentum)</sup><sup> • </sup><sup>[6](https://github.com/hpcaitech/ColossalAI)</sup> |

## 目的与设计

训练具有数十亿参数的模型超出了单个 GPU 的内存容量，而选择最优并行策略需要深度学习和并行计算两方面的专业知识。Colossal-AI 通过将一系列训练加速技术统一在一个系统中来解决这一问题，使用户的串行模型训练代码只需少量修改即可扩展至分布式环境。<sup>[1](https://arxiv.org/abs/2110.14883)</sup>

预期的工作流程刻意保持简单：准备一个指定所需功能和参数的配置文件，用 `colossalai.launch` 初始化分布式后端，用 `colossalai.booster` 将训练功能注入模型和优化器组件，然后运行训练。混合精度训练和[梯度累积](https://www.edgepedia.org/zh/gradient-accumulation)等常用工具与并行方法一并提供。<sup>[8](https://colossalai.org/docs/concepts/colossalai_overview/)</sup> 该系统也可在单个 GPU 上运行，并达到基线性能，例如在 CIFAR-10 上训练 ResNet。<sup>[3](https://colossalai.org/docs/get_started/run_demo/)</sup>

## 并行方法

**张量并行。** Colossal-AI 通过多维分布式矩阵-矩阵乘法算法优化张量并行，提供一维、二维、2.5维和三维变体，可通过修改配置文件切换。<sup>[8](https://colossalai.org/docs/concepts/colossalai_overview/)</sup><sup> • </sup><sup>[3](https://colossalai.org/docs/get_started/run_demo/)</sup> 在项目已发布的基准测试中，GPT-2 训练在使用张量并行时 GPU 内存消耗降至原来的十一分之一，并展现出超线性扩展效率；ViT 训练在张量并行规模为 64 时批量大小达到原来的 14 倍，训练速度达到原来的 5 倍。<sup>[6](https://github.com/hpcaitech/ColossalAI)</sup>

**流水线、序列和 MoE 并行。** 多种流水线并行方法使模型能够高效地跨节点扩展。<sup>[8](https://colossalai.org/docs/concepts/colossalai_overview/)</sup> 序列并行针对 NLP 任务中的内存效率和序列长度限制；以线性复杂度注意力模块替代二次复杂度的自注意力后，可实现最大序列长度随 GPU 数量线性扩展。<sup>[3](https://colossalai.org/docs/get_started/run_demo/)</sup><sup> • </sup><sup>[9](https://openreview.net/pdf?id=WO3qJC2TOG)</sup> 对于混合专家（MoE）模型，Colossal-AI 提供的并行方案旨在将 MoE 与模型并行和数据并行便捷地结合，不过文档指出该早期访问实现在大批量、长序列训练方面存在缺陷，且与张量并行不兼容。<sup>[10](https://colossalai.org/docs/advanced_tutorials/integrate_mixture_of_experts_into_your_model/)</sup>

**Shardformer。** 对于 LLaMA-2 70B 或 OPT 175B 等大型 [Transformer](https://www.edgepedia.org/zh/transformer) 模型，Shardformer 可为流行的 [Hugging Face](https://www.edgepedia.org/zh/hugging-face) 模型自动准备张量并行和流水线并行。它用分布式等价模块替换原生 PyTorch 模块，调整注意力头数等层属性，重写前向方法以在流水线阶段之间传递隐藏状态，并仅保留分配给当前设备的参数分片，释放其余部分以节省内存。<sup>[11](https://colossalai.org/docs/features/shardformer/)</sup>

## 内存管理

零冗余优化器（ZeRO）通过分片三种模型状态——优化器状态、梯度和参数——而非复制它们，消除数据并行进程间的内存冗余，同时保留计算粒度和通信效率。<sup>[4](https://colossalai.org/docs/features/zero_with_chunk/)</sup> Colossal-AI 增加了 v0.1.8 引入的 Chunk 机制，将一组连续参数存储在等大小的连续内存空间中，减少通信，高效利用 PCI-e 和 GPU 间带宽，并避免内存碎片化。<sup>[4](https://colossalai.org/docs/features/zero_with_chunk/)</sup>

**Gemini** 是该系统的异构内存管理器，与 ZeRO 配合使用，在 GPU 和 CPU 内存之间放置模型数据、参数、梯度和优化器状态。<sup>[5](https://colossalai.org/docs/advanced_tutorials/meet_gemini/)</sup> 在单块 A100 80 GB GPU 上对 OPT-13B 与 [DeepSpeed](https://www.edgepedia.org/zh/deepspeed) 的正面对比基准中，Colossal-AI 的自动放置策略录得每步 41.50 秒，而 DeepSpeed ZeRO3 为 51.74 秒；在八块 GPU 上训练 OPT-30B 时，Colossal-AI 达到每秒 3.41 个样本，而 DeepSpeed 为 1.73 个。<sup>[12](https://github.com/hpcaitech/OPT-Benchmark)</sup>

## 自动并行

Colossal-Auto 自动化并行策略的选择：用户无需手动配置并行策略和修改模型，只需提供一行代码加上集群信息和模型配置，系统即可与 Hugging Face 和 Timm 等框架集成。<sup>[13](https://colossalai.org/docs/Colossal-Auto/get_started/introduction/)</sup> 它被描述为首个在 PyTorch（动态图框架）上使用静态图分析的自动并行系统；它用 ColoTracer（torch.FX Tracer 的一个分支版本）追踪模型，记录形状、维度和数据类型等张量元数据以指导搜索。<sup>[13](https://colossalai.org/docs/Colossal-Auto/get_started/introduction/)</sup>

搜索对每个操作执行细粒度策略选择，选择张量切分策略、通信算子和算子替换，以在内存预算约束下最小化运行时间。NVIDIA Megatron-LM 及类似系统中使用的张量并行、数据并行和混合并行，都是 Colossal-Auto 可搜索策略的子集，逐操作的选择原则上可以找到比人类专家提供的更优策略。<sup>[13](https://colossalai.org/docs/Colossal-Auto/get_started/introduction/)</sup> 配套论文 Colossal-Auto（arXiv，2023 年 2 月）联合优化分布式执行和梯度检查点计划，并增加了一个符号分析器，可为任何 PyTorch 模型生成内存和计算统计数据。<sup>[14](https://arxiv.org/abs/2302.02599)</sup>

## 生态项目与应用

团队已使用该系统复现和扩展了若干知名模型。

## 采用与地位

Colossal-AI 是与微软 DeepSpeed 和 NVIDIA Megatron-LM 并列的、被广泛采用的开源大型 Transformer 模型训练原型之一。<sup>[15](https://researchmgt.monash.edu/ws/portalfiles/portal/593688345/592668178_oa.pdf)</sup> 各项比较将这些系统置于不同的优势位置：一份 2026 年的调查给 Colossal-AI 的并行覆盖度评分为 88，其 HybridParallel 插件结合了数据并行、ZeRO、张量并行、流水线并行和序列并行，并为部分 MoE 模型提供专家并行，同时将其文档评分定为 55，并指出 DeepSpeed 在成熟度和稳定性方面领先，且被 Hugging Face Trainer、Accelerate 和 [PyTorch Lightning](https://www.edgepedia.org/zh/pytorch-lightning) 作为后端暴露。<sup>[16](https://www.faun.dev/toolbox/colossal-ai-vs-deepspeed/)</sup>

[软件质量](https://www.edgepedia.org/zh/software-quality)已引起研究关注：一项 2025 年的实证研究分析了 DeepSpeed、Megatron-LM 和 Colossal-AI 中 308 个已修复的缺陷，发现 48% 的缺陷修复只需十行或更少的极小代码改动，且分布式框架引入了独特的根因，如分配策略错误和分布式通信错误。<sup>[17](https://arxiv.org/abs/2506.10426)</sup>

开发保持活跃。PyPI 发布历史显示 2024 年和 2025 年节奏稳定，从 2023 年 5 月的 0.3.0 到 2025 年 6 月 4 日的 0.5.0，近期版本包括 Shardformer 序列并行、LoRA 加载修复和 Colossal-LLaMA 重构等工作。<sup>[7](https://pypi.org/project/colossalai/)</sup><sup> • </sup><sup>[18](https://github.com/hpcaitech/ColossalAI/releases)</sup>

## References

1. [Colossal-AI: A Unified Deep Learning System For Large-Scale Parallel Training, arXiv:2110.14883](https://arxiv.org/abs/2110.14883)
2. [Colossal-AI Emerges as the Go-To Performance Optimization Solution with Unmatched Community Momentum, HPC-AI Tech blog, March 8, 2023](https://company.hpc-ai.com/blog/colossal-ai-emerges-as-the-go-to-performance-optimization-solution-with-unmatched-community-momentum)
3. [Quick Demo, Colossal-AI documentation](https://colossalai.org/docs/get_started/run_demo/)
4. [Zero Redundancy Optimizer with chunk-based memory management, Colossal-AI documentation](https://colossalai.org/docs/features/zero_with_chunk/)
5. [Meet Gemini: The Heterogeneous Memory Manager of Colossal-AI, Colossal-AI documentation](https://colossalai.org/docs/advanced_tutorials/meet_gemini/)
6. [Colossal-AI GitHub repository (hpcaitech/ColossalAI)](https://github.com/hpcaitech/ColossalAI)
7. [colossalai, PyPI](https://pypi.org/project/colossalai/)
8. [Colossal-AI Overview, Colossal-AI documentation](https://colossalai.org/docs/concepts/colossalai_overview/)
9. [Colossal-AI: A Unified Deep Learning System For Large-Scale Parallel Training, OpenReview PDF](https://openreview.net/pdf?id=WO3qJC2TOG)
10. [Integrate Mixture-of-Experts Into Your Model, Colossal-AI documentation](https://colossalai.org/docs/advanced_tutorials/integrate_mixture_of_experts_into_your_model/)
11. [Shardformer, Colossal-AI documentation](https://colossalai.org/docs/features/shardformer/)
12. [OPT-Benchmark, hpcaitech GitHub](https://github.com/hpcaitech/OPT-Benchmark)
13. [Introduction, Colossal-Auto documentation](https://colossalai.org/docs/Colossal-Auto/get_started/introduction/)
14. [Colossal-Auto: Unified Automation of Parallelization and Activation Checkpoint for Large-scale Models, arXiv:2302.02599](https://arxiv.org/abs/2302.02599)
15. [Proceedings of the Thirty-Second International Joint Conference on Artificial Intelligence (IJCAI-23)](https://researchmgt.monash.edu/ws/portalfiles/portal/593688345/592668178_oa.pdf)
16. [Colossal-AI vs DeepSpeed: Distributed Training Libraries Comparison (2026), Faun](https://www.faun.dev/toolbox/colossal-ai-vs-deepspeed/)
17. [Towards Understanding Bugs in Distributed Training and Inference Frameworks for Large Language Models, arXiv:2506.10426](https://arxiv.org/abs/2506.10426)
18. [Releases, hpcaitech/ColossalAI GitHub](https://github.com/hpcaitech/ColossalAI/releases)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/colossal-ai

English original: https://www.edgepedia.org/colossal-ai
