Skip to content

Commit 68b5ef7

Browse files
yeahdongcnXiaodong Yeclaude
authored
docs: document the two pip indexes and pin Python to 3.10 (#107)
* docs: document the two pip indexes and pin Python to 3.10 The source install told users to run pip install -r requirements/build.txt -r requirements/musa.txt with pip's default index. requirements/musa.txt pulls in requirements/musa_private.txt, whose MUSA wheels are published on the Moore Threads index, so 12 of its 14 pins cannot resolve and the install dies with No matching distribution found for torch==2.9.1.post1+musa5.2.0s5000 Document the two indexes and mirror docker/musa.Dockerfile's three-pass install in both READMEs: the MUSA wheels first from the Moore Threads index alone and with --no-deps, then the ordinary wheels from public PyPI, then the MUSA wheels' own dependencies. The indexes stay in separate invocations because triton and torch_c_dlpack_ext exist on both at the same version with different contents, and pip has no index priority. Pin Python to 3.10. The pinned MUSA wheels ship cp310 for x86_64 only, so requires-python = ">=3.9" let pip start an install on 3.9/3.11/3.12 that could only fail in dependency resolution; ==3.10.* makes it a clear error instead. Also correct the docs against the code: the patch section described the build-time series as runtime patching, the project structure omitted the directories the install steps reference, docker/README.md redacted the wheel index and claimed 3.12 support that these pins do not have, and README_CN.md was missing the ccache section and its environment variables. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: scope the merged-index warning to MUSA wheel resolution The warning said not to merge the indexes with --extra-index-url, while pass 3 of the same instructions passes both, which reads as a contradiction. State the rule the passes actually follow: MUSA wheels must be resolved with the Moore Threads index alone, and a merged index is only safe once pass 1 has installed them, because nothing MUSA is re-resolved afterwards. Name the mechanism while here. pip ranks candidates by wheel tag, and the public triton (manylinux_2_17_x86_64) outranks the Moore Threads one (linux_x86_64), so a merged resolve does not just risk the public build, it selects it. Correct the index description in requirements/musa_private.txt: the index is not MT-network-internal, and it carries ordinary packages too — it simply lacks torchada and mirrors the rest at versions that miss the common.txt pins, which is the actual reason an index directive in this file would break the install. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: state that index order does not decide the MUSA wheel --extra-index-url reads like the right tool for a vendor index alongside PyPI, so say why it is not: pip pools candidates from every index and has no index priority. Passing the Moore Threads index as --index-url and public PyPI as --extra-index-url resolves triton to the public build exactly as the reverse order does, because the choice is made on wheel tag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: drop the --extra-index-url explanation from the index section The rule the install follows is already stated: MUSA wheels resolve with the Moore Threads index as the sole --index-url. The rationale for why a merged index misresolves them does not need to live in the README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: match the documented Mooncake default to build_image.sh The configuration table describes docker/build_image.sh, which defaults BUILD_MOONCAKE to 1, but documented 0. Correct the row and the two places that only made sense while the documented default was 0: the worked example now shows how to skip Mooncake rather than how to ask for what is already on, and the image contents list names it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * build: build Mooncake by default in the Dockerfile docker/build_image.sh already passes BUILD_MOONCAKE=1, so a bare docker build was the only path that produced an image without Mooncake. Default the ARG to 1 so both paths agree, and state in the stage list that the stage builds unless BUILD_MOONCAKE=0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Xiaodong Ye <yexiaodong60@mthreads.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 363ad88 commit 68b5ef7

7 files changed

Lines changed: 208 additions & 51 deletions

File tree

README.md

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ vLLM Hardware Plugin for Moore Threads MUSA
1212

1313
<p align="center">
1414
<a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
15-
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="Python 3.9+"></a>
15+
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10-blue.svg" alt="Python 3.10"></a>
1616
</p>
1717

1818
---
@@ -30,7 +30,8 @@ The plugin leverages the following key components:
3030

3131
## Requirements
3232

33-
- **Python**: 3.9 or higher
33+
- **Python**: 3.10 — the pinned MUSA wheels are published for CPython 3.10 on
34+
x86_64, so other versions cannot resolve them
3435
- **Hardware**: Moore Threads (MUSA) GPU with MUSA toolkit installed
3536
- **Dependencies**:
3637
- [torchada](https://github.com/MooreThreads/torchada) — CUDA→MUSA compatibility layer
@@ -48,6 +49,40 @@ The plugin leverages the following key components:
4849

4950
> **Note**: This plugin uses vLLM's V1 engine architecture (the V0 engine is not supported). Within the V1 engine, vLLM v0.24.0 auto-selects its **Model Runner V2** for certain architectures (e.g. Qwen3, DeepSeek-V2, Llama) and the V1 model runner for others; both are supported on MUSA. Set `VLLM_USE_V2_MODEL_RUNNER=1` or `0` to force one.
5051
52+
### Docker image
53+
54+
The Docker flow installs the MUSA SDK, the MUSA wheels, `vllm-musa`, and the
55+
vendored vLLM into one image, and is the least error-prone way to get a working
56+
environment:
57+
58+
```bash
59+
bash docker/build_image.sh
60+
```
61+
62+
See [docker/README.md](docker/README.md) for the build options. To install onto
63+
a host that already has the MUSA SDK, use the source install below.
64+
65+
### Package indexes
66+
67+
`vllm-musa` resolves its dependencies from **two** indexes:
68+
69+
| Index | URL | Provides |
70+
|---|---|---|
71+
| Moore Threads | `https://dl.mthreads.com/repo/api/pypi/pypi/simple` | the MUSA wheels pinned in `requirements/musa_private.txt``torch`, `torch_musa`, `mate`, `flash_attn_3`, `flash_mla`, `deep-gemm`, `tilelang_musa`, `triton`, `apache-tvm-ffi`, … |
72+
| Public PyPI | `https://pypi.org/simple`, or a mirror | the ordinary third-party wheels in `requirements/build.txt` and `requirements/common.txt` |
73+
74+
Most of the MUSA wheels are not published on public PyPI, so installing
75+
`requirements/musa.txt` with pip's default index fails with
76+
`No matching distribution found for torch==2.9.1.post1+musa5.2.0s5000`.
77+
78+
The MUSA wheels must be **resolved** with the Moore Threads index as the sole
79+
`--index-url`, which is why the install below starts with a pass that installs
80+
only them.
81+
82+
Pass 3 below does pass both indexes. That is safe only because pass 1 has already
83+
installed every MUSA wheel at its pinned version, so nothing MUSA is re-resolved
84+
there and the merged index only supplies the ordinary dependencies.
85+
5186
### Install from Source
5287

5388
1. Clone the repository:
@@ -57,25 +92,49 @@ The plugin leverages the following key components:
5792
cd vllm-musa
5893
```
5994

60-
2. Install Python dependencies before installing `vllm-musa`. The MUSA
61-
requirements entrypoint includes common dependencies and MUSA-private pins
62-
such as `torch` and `torch_musa`.
95+
2. Select the two indexes:
96+
97+
```bash
98+
export MUSA_PIP_INDEX_URL=https://dl.mthreads.com/repo/api/pypi/pypi/simple
99+
export PYPI_INDEX_URL=https://pypi.org/simple
100+
```
101+
102+
3. Install the Python dependencies in three passes:
63103

64104
```bash
65-
pip install -r requirements/build.txt -r requirements/musa.txt
105+
# 1. The MUSA wheels, from the Moore Threads index only. This pass runs
106+
# first and with --no-deps because torchada and transformers declare an
107+
# unpinned `torch`: resolving them first would pull the public CUDA torch
108+
# and the multi-GB nvidia-cuda-* stack over the MUSA one.
109+
pip install --no-deps --index-url "${MUSA_PIP_INDEX_URL}" \
110+
-r requirements/musa_private.txt
111+
112+
# 2. The ordinary third-party wheels, from public PyPI. Pass 1 already
113+
# satisfies `torch`.
114+
pip install --index-url "${PYPI_INDEX_URL}" \
115+
-r requirements/build.txt -r requirements/common.txt
116+
117+
# 3. The MUSA wheels' own ordinary dependencies (sympy, networkx, ...).
118+
# Pass 1 pinned every MUSA wheel, so none are re-resolved here.
119+
pip install --index-url "${MUSA_PIP_INDEX_URL}" \
120+
--extra-index-url "${PYPI_INDEX_URL}" \
121+
-r requirements/musa_private.txt
66122
```
67123

68-
3. Install vLLM Hardware Plugin for Moore Threads MUSA:
124+
4. Install vLLM Hardware Plugin for Moore Threads MUSA. The vendored vLLM takes
125+
its dependencies from public PyPI, so keep that index selected here:
69126

70127
```bash
128+
export PIP_INDEX_URL="${PYPI_INDEX_URL}"
129+
71130
# Standard installation (installs vLLM MUSA plugin and vLLM)
72131
pip install . --no-build-isolation -v
73132
74133
# Or editable installation for development
75134
pip install -e . --no-build-isolation -v
76135
```
77136

78-
4. Verify the installation:
137+
5. Verify the installation:
79138

80139
```bash
81140
# Check plugin registration
@@ -113,7 +172,6 @@ Useful commands:
113172

114173
```bash
115174
ccache --zero-stats
116-
pip install -r requirements/build.txt -r requirements/musa.txt
117175
pip install -e . --no-build-isolation -v
118176
ccache --show-stats
119177
```
@@ -176,24 +234,36 @@ vllm-musa/
176234
├── README.md # Documentation (English)
177235
├── README_CN.md # Documentation (中文)
178236
├── LICENSE # Apache 2.0 License
237+
├── requirements/ # Dependency pins (build, common, musa_private)
238+
├── docker/ # Image build flow (musa.Dockerfile, build_image.sh)
239+
├── third_party/ # PINS + the upstream vLLM cloned at build time
240+
├── build_utils/ # Build helpers (ccache wrapper)
241+
├── tools/ # Sync, verify, and patch-validation utilities
179242
├── example/ # Usage examples
180243
├── csrc/ # C/C++ source files
181244
├── docs/ # Additional documentation
182245
├── vllm_musa/ # Main package
183246
│ ├── __init__.py # Plugin entry point
184247
│ ├── platform.py # MUSA platform implementation
185-
│ └── patches/ # Runtime compatibility patches
248+
│ └── patches/ # Patches against upstream vLLM
186249
│ ├── __init__.py # Patch application logic
187-
│ └── *.patch.py # Individual patch files
250+
│ ├── series/ # Build-time source patch series
251+
│ └── *.patch.py # Import-time object patches
188252
└── tests/ # Test suite
189253
├── conftest.py # Pytest fixtures
190254
├── test_musa.py # Platform tests
191255
└── test_patches.py # Patch system tests
192256
```
193257
194-
## Runtime Patches
258+
## Patches
195259
196-
The plugin includes runtime patches to ensure compatibility with upstream vLLM. For details on the patching mechanism, see [patches/README.md](vllm_musa/patches/README.md).
260+
The plugin carries two kinds of change to upstream vLLM. Source edits — the vast
261+
majority — are applied to the pinned vLLM clone **at build time** as a
262+
`git format-patch` series under `vllm_musa/patches/series/`, so the installed
263+
vLLM is already patched. A small set of live-object monkey-patches that have no
264+
source-diff form run **at import time** (`vllm_musa/patches/*.patch.py`); these
265+
are the only runtime patches. For details on both mechanisms, see
266+
[patches/README.md](vllm_musa/patches/README.md).
197267
198268
## Contributing
199269

README_CN.md

Lines changed: 99 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<p align="center">
1414
<a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
15-
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="Python 3.9+"></a>
15+
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10-blue.svg" alt="Python 3.10"></a>
1616
</p>
1717

1818
---
@@ -30,7 +30,8 @@
3030

3131
## 环境要求
3232

33-
- **Python**:3.9 或更高版本
33+
- **Python**:3.10 — 本套件所固定的 MUSA wheel 仅发布了 x86_64 上的 CPython 3.10
34+
版本,其他 Python 版本无法解析这些依赖
3435
- **硬件**:安装了 MUSA 工具包的摩尔线程 (MUSA) GPU
3536
- **依赖项**
3637
- [torchada](https://github.com/MooreThreads/torchada) — CUDA→MUSA 兼容层
@@ -48,6 +49,37 @@
4849

4950
> **注意**:本插件使用 vLLM 的 V1 引擎架构(不支持 V0 引擎)。在 V1 引擎内部,vLLM v0.24.0 会为部分架构(如 Qwen3、DeepSeek-V2、Llama)自动选用 **Model Runner V2**,其余架构使用 V1 model runner;两者在 MUSA 上均受支持。设置 `VLLM_USE_V2_MODEL_RUNNER=1``0` 可强制指定其一。
5051
52+
### Docker 镜像
53+
54+
Docker 流程会把 MUSA SDK、MUSA wheel、`vllm-musa` 以及内置的 vLLM 一次性装入同一
55+
镜像,是最不容易出错的方式:
56+
57+
```bash
58+
bash docker/build_image.sh
59+
```
60+
61+
构建选项参见 [docker/README.md](docker/README.md)。若要安装到已具备 MUSA SDK 的
62+
主机上,请使用下面的源码安装。
63+
64+
### 软件包索引
65+
66+
`vllm-musa` 的依赖来自**两个**索引:
67+
68+
| 索引 | URL | 提供内容 |
69+
|---|---|---|
70+
| 摩尔线程 | `https://dl.mthreads.com/repo/api/pypi/pypi/simple` | `requirements/musa_private.txt` 中约束的 MUSA wheel — `torch``torch_musa``mate``flash_attn_3``flash_mla``deep-gemm``tilelang_musa``triton``apache-tvm-ffi`|
71+
| 公共 PyPI | `https://pypi.org/simple` 或其镜像 | `requirements/build.txt``requirements/common.txt` 中的普通第三方 wheel |
72+
73+
大部分 MUSA wheel 并未发布到公共 PyPI,因此用 pip 默认索引安装
74+
`requirements/musa.txt` 会失败并报
75+
`No matching distribution found for torch==2.9.1.post1+musa5.2.0s5000`
76+
77+
MUSA wheel 必须在摩尔线程索引作为**唯一** `--index-url` 的前提下解析,因此下面的
78+
安装步骤以“只装 MUSA wheel”的一步开始。
79+
80+
下面的第 3 步确实同时传入了两个索引。这样做是安全的,因为第 1 步已经按固定版本装好
81+
了所有 MUSA wheel,该步不会重新解析任何 MUSA wheel,合并索引只用于补齐普通依赖。
82+
5183
### 从源码安装
5284

5385
1. 克隆仓库:
@@ -57,24 +89,47 @@
5789
cd vllm-musa
5890
```
5991

60-
2. 安装 `vllm-musa` 前先安装 Python 依赖。MUSA requirements 入口包含通用依赖
61-
`torch``torch_musa` 等 MUSA private 版本约束:
92+
2. 选定两个索引:
6293

6394
```bash
64-
pip install -r requirements/build.txt -r requirements/musa.txt
95+
export MUSA_PIP_INDEX_URL=https://dl.mthreads.com/repo/api/pypi/pypi/simple
96+
export PYPI_INDEX_URL=https://pypi.org/simple
6597
```
6698

67-
3. 安装摩尔线程 MUSA 的 vLLM 硬件插件
99+
3. 分三步安装 Python 依赖
68100

69101
```bash
102+
# 1. MUSA wheel,仅从摩尔线程索引安装。该步必须最先执行且带 --no-deps:
103+
# torchada 和 transformers 声明的 `torch` 没有版本约束,若先解析它们会拉取
104+
# 公共 CUDA 版 torch 及数 GB 的 nvidia-cuda-* 依赖,覆盖 MUSA 版。
105+
pip install --no-deps --index-url "${MUSA_PIP_INDEX_URL}" \
106+
-r requirements/musa_private.txt
107+
108+
# 2. 普通第三方 wheel,从公共 PyPI 安装。第 1 步已满足 `torch`。
109+
pip install --index-url "${PYPI_INDEX_URL}" \
110+
-r requirements/build.txt -r requirements/common.txt
111+
112+
# 3. 补齐 MUSA wheel 自身的普通依赖(sympy、networkx 等)。第 1 步已固定所有
113+
# MUSA wheel,这里不会重新解析它们。
114+
pip install --index-url "${MUSA_PIP_INDEX_URL}" \
115+
--extra-index-url "${PYPI_INDEX_URL}" \
116+
-r requirements/musa_private.txt
117+
```
118+
119+
4. 安装摩尔线程 MUSA 的 vLLM 硬件插件。内置 vLLM 的依赖来自公共 PyPI,因此这里
120+
保持选用该索引:
121+
122+
```bash
123+
export PIP_INDEX_URL="${PYPI_INDEX_URL}"
124+
70125
# 标准安装(安装 vLLM MUSA 插件和 vLLM)
71126
pip install . --no-build-isolation -v
72127
73128
# 或可编辑安装(用于开发)
74129
pip install -e . --no-build-isolation -v
75130
```
76131

77-
4. 验证安装:
132+
5. 验证安装:
78133

79134
```bash
80135
# 检查插件注册
@@ -92,6 +147,28 @@
92147
| `VLLM_WORKER_MULTIPROC_METHOD=spawn` | 多进程 worker 推荐设置 |
93148
| `VLLM_MUSA_CUSTOM_OP_USE_NATIVE` | 使用 vLLM 自定义算子的原生实现(默认:`False`|
94149
| `VLLM_MUSA_WORKER_TERMINATION_TIMEOUT_S` | 控制 vLLM v1 worker 关闭超时时间(默认: `4s`|
150+
| `VLLM_MUSA_USE_CCACHE` | 当系统安装了 `ccache` 时,为原生扩展构建启用 ccache(默认:`1`|
151+
| `VLLM_MUSA_CCACHE` | 覆盖 `setup.py` 所使用的 ccache 可执行文件(默认:`PATH` 中的第一个 `ccache`|
152+
| `VLLM_MUSA_CCACHE_DIR` | 覆盖 `setup.py` 所使用的 ccache 目录(默认:`<repo>/.ccache`|
153+
| `VLLM_MUSA_CCACHE_MAXSIZE` | 可选的 ccache 最大容量,将作为 `CCACHE_MAXSIZE` 透传 |
154+
| `VLLM_MUSA_REAL_MCC` | 覆盖被 ccache 包装的真实 MUSA 编译器(默认:自动探测到的 `mcc`|
155+
156+
### 用于原生重新构建的 ccache
157+
158+
`PATH` 中存在 `ccache` 时,源码安装会自动让宿主 C++ 编译器和 MUSA `mcc`
159+
ccache。生成的 `mcc` wrapper 会把 `.mu` 等 MUSA 专有输入规范化为可缓存的 `.cu`
160+
副本,并对 ccache 隐藏 `-x musa`,同时仍将其传给 `mcc`。默认缓存目录为
161+
`<repo>/.ccache`,因此在同一份检出中第二次执行
162+
`pip install -e . --no-build-isolation -v` 可以复用已缓存的 `.cu``.mu` 和 C++
163+
目标文件。
164+
165+
常用命令:
166+
167+
```bash
168+
ccache --zero-stats
169+
pip install -e . --no-build-isolation -v
170+
ccache --show-stats
171+
```
95172

96173
## 使用方法
97174

@@ -151,24 +228,35 @@ vllm-musa/
151228
├── README.md # 文档(英文)
152229
├── README_CN.md # 文档(中文)
153230
├── LICENSE # Apache 2.0 许可证
231+
├── requirements/ # 依赖版本约束(build、common、musa_private)
232+
├── docker/ # 镜像构建流程(musa.Dockerfile、build_image.sh)
233+
├── third_party/ # PINS 及构建时克隆的上游 vLLM
234+
├── build_utils/ # 构建辅助(ccache wrapper)
235+
├── tools/ # 同步、校验与补丁验证工具
154236
├── example/ # 使用示例
155237
├── csrc/ # C/C++ 源文件
156238
├── docs/ # 附加文档
157239
├── vllm_musa/ # 主包
158240
│ ├── __init__.py # 插件入口
159241
│ ├── platform.py # MUSA 平台实现
160-
│ └── patches/ # 运行时兼容性补丁
242+
│ └── patches/ # 针对上游 vLLM 的补丁
161243
│ ├── __init__.py # 补丁应用逻辑
162-
│ └── *.patch.py # 单独的补丁文件
244+
│ ├── series/ # 构建时的源码补丁序列
245+
│ └── *.patch.py # 导入时的对象补丁
163246
└── tests/ # 测试套件
164247
├── conftest.py # Pytest fixtures
165248
├── test_musa.py # 平台测试
166249
└── test_patches.py # 补丁系统测试
167250
```
168251
169-
## 运行时补丁
252+
## 补丁
170253
171-
本插件包含运行时补丁以确保与上游 vLLM 的兼容性。有关补丁机制的详情,请参阅 [patches/README.md](vllm_musa/patches/README.md)。
254+
本插件对上游 vLLM 的改动分为两类。绝大多数是源码改动,它们以
255+
`git format-patch` 序列的形式存放在 `vllm_musa/patches/series/`,并在**构建时**
256+
应用到固定版本的 vLLM 克隆上,因此安装完成的 vLLM 已经是打好补丁的。另有少量无法
257+
表示为源码 diff 的实时对象 monkey-patch,在**导入时**运行
258+
`vllm_musa/patches/*.patch.py`),它们是仅有的运行时补丁。两种机制的详情请参阅
259+
[patches/README.md](vllm_musa/patches/README.md)。
172260
173261
## 贡献
174262

0 commit comments

Comments
 (0)