@@ -39,7 +39,7 @@ API 定义以及使用方式详见 [`InfiniCore文档`](https://github.com/Infin
3939
4040### 一、克隆项目
4141
42- 由于仓库中含有子模块,所以在克隆时请添加 ` --recursive ` 或 ` --recurse-submodules ` ,如:
42+ 由于仓库中含有子模块(如 ` spdlog ` / ` nlohmann_json ` ) ,所以在克隆时请添加 ` --recursive ` 或 ` --recurse-submodules ` ,如:
4343
4444``` shell
4545git clone --recursive https://github.com/InfiniTensor/InfiniCore.git
@@ -51,6 +51,10 @@ git clone --recursive https://github.com/InfiniTensor/InfiniCore.git
5151git submodule update --init --recursive
5252```
5353
54+ > 注:InfLLM-V2 CUDA kernels(` infllmv2_cuda_impl ` )为** 可选依赖** ,不会随仓库子模块默认拉取。
55+ > 如需启用 ` --infllmv2 ` (见下文),请自行在任意目录克隆/编译该项目,并将生成的 ` infllm_v2/*.so ` 路径传给 xmake;
56+ > 或者将其手动放到 ` InfiniCore/third_party/infllmv2_cuda_impl ` 后再使用 ` --infllmv2=y ` 走自动探测。
57+
5458配置` INFINI_ROOT ` 和 ` LD_LIBRARY_PATH ` 环境变量。
5559默认` INFINI_ROOT ` 为` $HOME/.infini ` ,可以使用以下命令自动配置:
5660
@@ -108,6 +112,8 @@ python scripts/install.py [XMAKE_CONFIG_FLAGS]
108112| ` --ninetoothed=[y\|n] ` | 是否编译九齿实现 | n
109113| ` --ccl=[y\|n] ` | 是否编译 InfiniCCL 通信库接口实现 | n
110114| ` --graph=[y\|n] ` | 是否编译 cuda graph 接口实现 | n
115+ | ` --aten=[y\|n] ` | 是否链接 ATen / PyTorch(用于部分算子/对比测试) | n
116+ | ` --infllmv2=[y\|PATH] ` | ** 可选** :启用 InfLLM-V2 attention(需 ` --aten=y ` )。值为 ` y ` (探测 ` third_party/infllmv2_cuda_impl ` )或指向 ` libinfllm_v2.so ` / ` infllmv2_cuda_impl ` 根目录 | (空)
111117
112118##### 手动安装底层库
113119
@@ -174,6 +180,64 @@ python scripts/install.py [XMAKE_CONFIG_FLAGS]
174180
175181 ` ` `
176182
183+ # #### 试验功能 -- 使用 InfLLM-V2 CUDA kernels(可选)
184+
185+ InfLLM-V2 的 varlen/kvcache attention 需要额外的 CUDA kernels(` infllm_v2/* .so` )。该依赖为** 可选** ,需要你自行克隆并编译。
186+
187+ 如果你希望将 ` infllmv2_cuda_impl` 放在本仓库 ` third_party/` 下(但不作为子模块管理),可以按以下方式拉取并编译,然后使用 ` --infllmv2=y` 让 xmake 自动探测:
188+
189+ ` ` ` bash
190+ cd InfiniCore
191+
192+ # Core submodules only (InfLLM-v2 不作为子模块强制拉取)
193+ git submodule sync third_party/spdlog third_party/nlohmann_json
194+ git submodule update --init third_party/spdlog third_party/nlohmann_json
195+
196+ # Fetch InfLLM-v2 into third_party if missing (NOT a git submodule).
197+ INFLLMV2_DIR=" $PWD /third_party/infllmv2_cuda_impl"
198+ if [ ! -d " $INFLLMV2_DIR /.git" ]; then
199+ rm -rf " $INFLLMV2_DIR "
200+ git clone --depth 1 -b minicpm_sala_patches --recurse-submodules \
201+ https://github.com/Ceng23333/infllmv2_cuda_impl.git " $INFLLMV2_DIR "
202+ fi
203+
204+ cd " $INFLLMV2_DIR "
205+ git submodule update --init --recursive
206+ python3 setup.py install
207+
208+ cd ..
209+ python3 scripts/install.py --root --nv-gpu=y --cuda_arch=sm_80 --aten=y --infllmv2=y --ccl=y
210+ xmake build -r _infinicore
211+ xmake install _infinicore
212+
213+ export PYTHONPATH=" $PWD /test/infinicore:$PWD /python:${PYTHONPATH:- } "
214+ python3 " $PWD /test/infinicore/ops/infllmv2_attention.py" --nvidia
215+ python3 " $PWD /test/infinicore/ops/simple_gla_prefill.py" --nvidia
216+ python3 " $PWD /test/infinicore/ops/simple_gla_decode_recurrent.py" --nvidia
217+ ` ` `
218+
219+ 1. 构建 ` infllmv2_cuda_impl` (示例,路径可自定义):
220+
221+ ` ` ` shell
222+ git clone < your infllmv2_cuda_impl repo url> /abs/path/to/infllmv2_cuda_impl
223+ cd /abs/path/to/infllmv2_cuda_impl
224+ python setup.py install
225+ ` ` `
226+
227+ 2. 配置并编译 InfiniCore(需要 ` --aten=y` ):
228+
229+ ` ` ` shell
230+ # 方式 A:直接给 .so 的绝对路径(推荐,更明确)
231+ xmake f --nv-gpu=y --aten=y --infllmv2=/abs/path/to/libinfllm_v2.so -cv
232+ xmake build && xmake install
233+
234+ # 方式 B:给 infllmv2_cuda_impl 根目录(会探测 build/lib.*/infllm_v2/*.so)
235+ xmake f --nv-gpu=y --aten=y --infllmv2=/abs/path/to/infllmv2_cuda_impl -cv
236+ xmake build && xmake install
237+ ` ` `
238+
239+ 运行时需要能找到该 ` libinfllm_v2.so` (例如它的目录已在 rpath / ` LD_LIBRARY_PATH` 中)。本项目在链接时会尝试写入 rpath 到对应目录,因此通常无需 ` LD_PRELOAD` 。
240+
1772412. 编译安装
178242
179243 默认安装路径为 ` $HOME /.infini` 。
0 commit comments