Ref
https://github.com/PyO3/maturin
Rust 程序設計語言
代碼庫:
https://github.com/ai-dynamo/dynamo
https://github.com/ai-dynamo/nixl
dynamo/container/Dockerfile.vllm
相關whl包
官方提供了4個whl包
ai_dynamo # 這個包ubuntu 22.04也可以用,ubuntu 24.04可以直接安裝不用重新編譯。包含的是sdk部分。絕大多數是Python,少量bin。
ai_dynamo_runtime # 包含llm和runtime部分
ai_dynamo_vllm # VLLM的修改版本,有DynamoNixlConnector作為kv_connector, 還有KvMetrics的發送。apply container/deps/vllm/vllm_v0.7.2-dynamo-kv-disagg-patch.patch to vLLM[v0.7.2] source code
nixl # 通信庫
上述包可以直接基于pip install在pypi上下載和安裝。但是需要ubuntu 24.04系統。
構建ai_dynamo
Install?uv
:?uv
curl -LsSf https://astral.sh/uv/install.sh | sh
在頂層目錄:
uv build --wheel --out-dir /workspace/dist
構建ai_dynamo_runtime
參考https://github.com/ai-dynamo/dynamo/tree/main/lib/bindings/python
下載rust環境:
國內服務器最好設置環境變量,否則rustup-init.sh運行時的下載極其慢:
export RUSTUP_DIST_SERVER='https://mirrors.ustc.edu.cn/rust-static'
export RUSTUP_UPDATE_ROOT='https://mirrors.ustc.edu.cn/rust-static/rustup'
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
wget https://static.rust-lang.org/rustup/rustup-init.sh
./rustup-init.sh
安裝依賴:
這里假設你已經有一個Python conda環境,否則可以安裝miniconda設置環境,或者按照推薦使用uv環境。
pip install maturin
apt install protobuf-compiler
下載源碼:
git clone --recursive?https://github.com/ai-dynamo/dynamo.git
git clone --recursive?https://github.com/ai-dynamo/nixl.git
在目錄dynamo/lib/bindings/python運行
maturin build
即可在target/wheels/生成whl包。
或者:
uv build --wheel --out-dir /workspace/dist
構建nixl
依賴安裝
sudo apt install -y build-essential cmake pkg-config
pip install meson ninja pybind11
在nixl源碼目錄執行(路徑根據你的需求修改):
INSTALL_DIR=/root/nixl
UCX_INSTALL_DIR=/root/ucx./util/build.sh $INSTALL_DIR $UCX_INSTALL_DIR
或者參考readme.md和util/build.sh分別構建ucx和nixl
首先構建ucx
wget https://github.com/openucx/ucx/releases/download/v1.18.0/ucx-1.18.0.tar.gz
tar xzf ucx-1.18.0.tar.gz
cd ucx-1.18.0
./contrib/configure-release --prefix=/root/ucx
make -j8
make install
構建nixl wheel包
在nixl源碼路徑,設置編譯好的ucx路徑
ref?https://mesonbuild.com/meson-python/how-to-guides/meson-args.html
python -m pip wheel --config-settings=setup-args="-Ducx_path=/root/ucx" .
# or
pip install build
python -m build -Csetup-args="-Ducx_path=/root/ucx" .
?或者:
uv build --wheel --out-dir /workspace/dist
構建ai_dynamo_vllm
下載VLLM 0.7.2的分支,然后打patch?dynamo\container\deps\vllm\vllm_v0.7.2-dynamo-kv-disagg-patch.patch,然后源碼編譯VLLM。
相當于直接編譯VLLM,參考vllm doc和其他博客
Installation — vLLM
https://github.com/vllm-project/vllm/blob/main/.github/workflows/scripts/build.sh?
https://zhuanlan.zhihu.com/p/692200573
# for cuda12.1, pytorch 2.5.1
# v0.0.28.post3 build for PyTorch 2.5.1
pip3 install -U xformers==v0.0.28.post3 --index-url https://download.pytorch.org/whl/cu121
git clone --recursive -b v0.7.2 https://github.com/vllm-project/vllm.git
git apply dynamo/container/deps/vllm/vllm_v0.7.2-dynamo-kv-disagg-patch.patchpython setup.py bdist_wheel
注意事項
需要確保你的網絡通暢,否則編譯過程下載各種代碼庫和軟件包失敗導致編譯失敗。