Skip to content

Commit 4713ba8

Browse files
mispa-msclaude
andcommitted
feat(kimik3): add Kimi-K3 B300 AgentX on the DSXE EFA cluster
Port the GB300 #4516 DCP8 points to 8-GPU B300 nodes over EFA: 1P3D and 1P2D specdecode, 1P2D cap128 c48/c64, 2P3D and 3P4D cap128 c240, and the aggregated c1 point as TP8/DCP8 on one node. The disaggregated prefill runs in eager mode, as in #4304; the aggregated worker uses FULL_DECODE_ONLY and runs the pinned image as shipped. The disaggregated setup installs the EFA transport at container start without source patches: EFA installer 1.51.0 as vLLM docker/Dockerfile.efa installs it, the NIXL 1.5.2 wheel, and Mooncake v0.3.14-pre built from source. The version binder now passes the master config's Mooncake version to the script, which checks it against the version it builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0e2edc2 commit 4713ba8

7 files changed

Lines changed: 903 additions & 1 deletion

File tree

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
trap 'echo "[kimi-k3-efa] FATAL: setup failed at line $LINENO: $BASH_COMMAND" >&2' ERR
4+
5+
source /infmax-workspace/benchmarks/check_env.sh
6+
check_env_vars KIMI_EFA_BUILD_CACHE LD_LIBRARY_PATH KV_OFFLOAD_BACKEND_VERSION
7+
8+
efa_version=1.51.0
9+
# Same digest as vLLM docker/Dockerfile.efa EFA_INSTALLER_SHA256.
10+
efa_sha256=83993044fa4df3dc2f8b5c2f7051d61b9689441be023a2c92ea51d3f53f2465c
11+
mc_rev=b46254dea9515ea6cc05fe4ec220545835582edd # commit of kvcache-ai/Mooncake tag v0.3.14-pre
12+
13+
mc_version="0.3.14.dev0+g${mc_rev:0:8}"
14+
if [[ "$KV_OFFLOAD_BACKEND_VERSION" != "$mc_version" ]]; then
15+
echo "[kimi-k3-efa] FATAL: the master config's Mooncake ${KV_OFFLOAD_BACKEND_VERSION} is not the built ${mc_version}" >&2
16+
exit 1
17+
fi
18+
cache="$KIMI_EFA_BUILD_CACHE/mooncake-${mc_rev:0:8}-efa${efa_version}-v1"
19+
echo "[kimi-k3-efa] Mooncake ${mc_version}, cache ${cache}"
20+
21+
export DEBIAN_FRONTEND=noninteractive
22+
# Mooncake build dependencies, plus the runtime libraries its wheel leaves to the system
23+
# (libibverbs, libnuma, libhwloc, libcurl, libnl). libibverbs-dev also brings libnl-3 and
24+
# libnl-route-3, which the installer's dpkg-only libfabric install needs, and libhwloc15 is the
25+
# only dependency of the NGC aws-ofi-nccl package. The NVIDIA CUDA apt mirror is intermittently
26+
# mid-sync (index size mismatch), so both the index update and the install are retried.
27+
apt_ok=0
28+
for attempt in 1 2 3 4 5; do
29+
if apt-get update -qq &&
30+
apt-get install -y -qq --no-install-recommends \
31+
build-essential ca-certificates curl git libboost-filesystem-dev libboost-system-dev \
32+
libcurl4-openssl-dev libgflags-dev libgoogle-glog-dev libhwloc15 libhwloc-dev libibverbs-dev \
33+
libjsoncpp-dev libmsgpack-dev libnuma-dev libprotobuf-dev libssl-dev libxxhash-dev \
34+
libyaml-cpp-dev libzstd-dev numactl patchelf pkg-config protobuf-compiler \
35+
python-is-python3 cuda-nvml-dev-13-0; then
36+
apt_ok=1
37+
break
38+
fi
39+
echo "[kimi-k3-efa] apt attempt $attempt failed" >&2
40+
sleep $((attempt * 15))
41+
done
42+
if [[ "$apt_ok" != 1 ]]; then
43+
echo "[kimi-k3-efa] FATAL: apt-get failed 5 times" >&2
44+
exit 1
45+
fi
46+
47+
task_dir=$(mktemp -d /tmp/kimi-k3-efa.XXXXXX)
48+
49+
# cached_wheel <url> <sha256>: one container downloads the wheel into the shared cache under a lock and keeps it
50+
# once its digest matches; the others wait and find the verified file. Prints the cached path.
51+
cached_wheel() {
52+
local url=$1 sha256=$2
53+
local name=${url##*/}
54+
local dir="$KIMI_EFA_BUILD_CACHE/wheels"
55+
mkdir -p "$dir"
56+
exec 6>"$dir/$name.lock"
57+
flock 6
58+
for attempt in 1 2 3 4 5; do
59+
if printf '%s %s\n' "$sha256" "$dir/$name" | sha256sum -c --status - 2>/dev/null; then
60+
break
61+
fi
62+
curl -fsSL --retry 3 --retry-all-errors "$url" -o "$task_dir/$name" || true
63+
if printf '%s %s\n' "$sha256" "$task_dir/$name" | sha256sum -c --status -; then
64+
mv -f "$task_dir/$name" "$dir/$name.tmp.${HOSTNAME}.$$"
65+
mv -f "$dir/$name.tmp.${HOSTNAME}.$$" "$dir/$name"
66+
else
67+
echo "[kimi-k3-efa] $name failed SHA256 check (attempt $attempt)" >&2
68+
sleep $((attempt * 10))
69+
fi
70+
done
71+
printf '%s %s\n' "$sha256" "$dir/$name" | sha256sum -c - >&2 || return 1
72+
flock -u 6
73+
echo "$dir/$name"
74+
}
75+
# The installer tarball is kept in the shared cache once its digest matches. One container downloads it
76+
# under the lock; the others wait and then find the verified file, which is never replaced afterwards.
77+
efa_dl="$KIMI_EFA_BUILD_CACHE/dl"
78+
efa_tgz="$efa_dl/aws-efa-installer-${efa_version}.tar.gz"
79+
mkdir -p "$efa_dl"
80+
exec 7>"$efa_dl/aws-efa-installer-${efa_version}.lock"
81+
flock 7
82+
if ! printf '%s %s\n' "$efa_sha256" "$efa_tgz" | sha256sum -c --status - 2>/dev/null; then
83+
curl -fsSL --retry 5 --retry-all-errors \
84+
"https://efa-installer.amazonaws.com/aws-efa-installer-${efa_version}.tar.gz" \
85+
-o "$task_dir/efa.tar.gz"
86+
printf '%s %s\n' "$efa_sha256" "$task_dir/efa.tar.gz" | sha256sum -c -
87+
mv -f "$task_dir/efa.tar.gz" "$efa_tgz.tmp.${HOSTNAME}.$$"
88+
mv -f "$efa_tgz.tmp.${HOSTNAME}.$$" "$efa_tgz"
89+
fi
90+
flock -u 7
91+
printf '%s %s\n' "$efa_sha256" "$efa_tgz" | sha256sum -c -
92+
tar -xzf "$efa_tgz" -C "$task_dir"
93+
# Same flags as vLLM docker/Dockerfile.efa: libfabric (with headers and fi_info), the NGC
94+
# aws-ofi-nccl plugin, no rdma-core, no MPI. --build-ngc implies --skip-kmod --skip-limit-conf
95+
# --no-verify --yes.
96+
(
97+
cd "$task_dir/aws-efa-installer"
98+
./efa_installer.sh --skip-mpi --skip-rdma-core --build-ngc
99+
)
100+
ldconfig
101+
# The NGC plugin package has no libnccl-net.so alias; the disaggregated recipe sets NCCL_NET_PLUGIN=none.
102+
echo "[kimi-k3-efa] /opt/amazon/ofi-nccl/lib: $(ls /opt/amazon/ofi-nccl/lib 2>/dev/null | paste -sd' ' -)"
103+
104+
mkdir -p "$cache"
105+
exec 9>"$cache/build.lock"
106+
flock 9
107+
if [ ! -f "$cache/ready" ]; then
108+
python3 -m pip install --no-cache-dir \
109+
'cmake==4.4.4' 'build==1.6.1' 'auditwheel==6.8.2' \
110+
'wheel==0.48.0' 'setuptools==84.0.0' 'pybind11==3.1.0'
111+
git clone https://github.com/kvcache-ai/Mooncake.git "$task_dir/Mooncake"
112+
git -C "$task_dir/Mooncake" checkout --detach "$mc_rev"
113+
git -C "$task_dir/Mooncake" submodule update --init --recursive
114+
(
115+
cd "$task_dir/Mooncake"
116+
# Since this tag the EFA transport dlopens libfabric at run time, so the build only needs the
117+
# installer's headers.
118+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
119+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON '-DCMAKE_INSTALL_RPATH=$ORIGIN' \
120+
-DCMAKE_PREFIX_PATH=/opt/amazon/efa \
121+
-DPython3_EXECUTABLE="$(command -v python3)" \
122+
-DUSE_EFA=ON -DUSE_CUDA=ON -DUSE_ETCD=OFF \
123+
-DWITH_STORE_RUST=OFF -DWITH_EP=OFF -DBUILD_UNIT_TESTS=OFF \
124+
-DBUILD_BENCHMARK=OFF -DBUILD_EXAMPLES=ON
125+
cmake --build build --parallel 12 --target \
126+
engine store mooncake_master mooncake_client transfer_engine_bench build_nvlink_allocator
127+
sed -i "s/^version = .*/version = \"${mc_version}\"/" mooncake-wheel/pyproject.toml
128+
mkdir -p "$task_dir/wheels"
129+
EFA_CU13_BUILD=1 OUTPUT_DIR="$task_dir/wheels" bash scripts/build_wheel.sh
130+
)
131+
# Exactly one wheel, and nothing left over from an earlier failed attempt in this cache.
132+
wheels=("$task_dir/wheels/"*.whl)
133+
if [[ ${#wheels[@]} -ne 1 || ! -f "${wheels[0]}" ]]; then
134+
echo "[kimi-k3-efa] FATAL: expected one wheel, got: ${wheels[*]}" >&2
135+
exit 1
136+
fi
137+
rm -f "$cache/"*.whl
138+
cp "${wheels[0]}" "$cache/"
139+
touch "$cache/ready"
140+
fi
141+
python3 -m pip uninstall -y \
142+
mooncake-transfer-engine mooncake-transfer-engine-cuda13 mooncake-transfer-engine-efa-cuda13
143+
python3 -m pip install --no-deps "$cache/"*.whl
144+
flock -u 9
145+
146+
nixl_version=1.5.2
147+
# The cp312 wheel matches the image's Python 3.12.
148+
py_tag=$(python3 -c 'import sys; print(f"cp{sys.version_info[0]}{sys.version_info[1]}")')
149+
if [[ "$py_tag" != cp312 ]]; then
150+
echo "[kimi-k3-efa] FATAL: Python ${py_tag}, the pinned nixl-cu13 wheel is cp312" >&2
151+
exit 1
152+
fi
153+
nixl_whl=$(cached_wheel \
154+
"https://files.pythonhosted.org/packages/31/90/cfcad1475c05c759a47f14f8edd30ebe77db2b7fae31bcdfa098fa2cfa46/nixl_cu13-${nixl_version}-cp312-cp312-manylinux_2_28_x86_64.whl" \
155+
591eda3f14b72769590cd71b6b46fc5e483ef1b5a90a29a8ff464310c9cf6af2)
156+
echo "[kimi-k3-efa] NIXL ${nixl_version} from PyPI ($(basename "$nixl_whl"))"
157+
python3 -m pip uninstall -y nixl-cu13
158+
python3 -m pip install --no-deps "$nixl_whl"
159+
160+
fi_version=$(/opt/amazon/efa/bin/fi_info --version)
161+
echo "$fi_version"
162+
if ! grep -qx 'libfabric: 2.7.0amzn2.0' <<<"$fi_version"; then
163+
echo "[kimi-k3-efa] FATAL: expected libfabric 2.7.0amzn2.0 from EFA installer ${efa_version}" >&2
164+
exit 1
165+
fi
166+
/opt/amazon/efa/bin/fi_info -p efa -t FI_EP_RDM
167+
168+
# The libraries the Mooncake wheel leaves to the system must resolve. libcuda comes from the
169+
# driver and is absent in containers without a GPU, so it is not checked here.
170+
mc_dir=$(python3 -c 'import mooncake, os; print(os.path.dirname(mooncake.__file__))')
171+
missing=$(
172+
for so in "$mc_dir"/engine*.so "$mc_dir"/_store*.so "$mc_dir"/mooncake_master; do
173+
if [[ ! -e "$so" ]]; then
174+
echo "$(basename "$so"): not in the wheel"
175+
continue
176+
fi
177+
ldd "$so" | grep 'not found' | grep -v 'libcuda\.so' | sed "s|^|$(basename "$so"): |"
178+
done || true
179+
)
180+
if [[ -n "$missing" ]]; then
181+
echo "[kimi-k3-efa] FATAL: Mooncake wheel files or libraries missing:" >&2
182+
echo "$missing" >&2
183+
exit 1
184+
fi
185+
# vLLM Dockerfile.efa checks that NIXL's LIBFABRIC plugin loads the EFA libfabric.
186+
nixl_plugin=$(find /usr/local/lib -path "*nixl_cu13*" -name libplugin_LIBFABRIC.so -print -quit)
187+
nixl_fabric=""
188+
if [[ -n "$nixl_plugin" ]]; then
189+
nixl_fabric=$(ldd "$nixl_plugin" | awk '$1 == "libfabric.so.1" {print $3}')
190+
fi
191+
if [[ -z "$nixl_plugin" || "$nixl_fabric" != /opt/amazon/efa/lib/* ]]; then
192+
echo "[kimi-k3-efa] FATAL: NIXL LIBFABRIC plugin ${nixl_plugin:-<none>} does not load the EFA libfabric (${nixl_fabric:-<none>})" >&2
193+
exit 1
194+
fi
195+
echo "[kimi-k3-efa] NIXL LIBFABRIC plugin ${nixl_plugin:-<none under /usr/local/lib>} -> ${nixl_fabric:-<no libfabric.so.1 entry>}"
196+
197+
python3 - "$mc_version" "$cache" "$efa_version" "$nixl_version" <<'PY'
198+
import ctypes
199+
import importlib.metadata
200+
import sys
201+
202+
mc_version, cache, efa_version, nixl_version = sys.argv[1:]
203+
fabric = ctypes.CDLL("libfabric.so.1")
204+
fabric.fi_version.restype = ctypes.c_uint32
205+
api = fabric.fi_version()
206+
assert api == (2 << 16 | 7), f"libfabric API {api >> 16}.{api & 0xFFFF}, expected 2.7"
207+
with open("/proc/self/maps") as maps:
208+
path = next(line.split()[-1] for line in maps if "libfabric.so" in line)
209+
assert path.startswith("/opt/amazon/efa/lib/"), f"libfabric.so.1 loaded from {path}"
210+
with open(path, "rb") as lib:
211+
# libfabric 2.7.0amzn2.0 sets CU_CTX_SYNC_MEMOPS on the primary context when a VMM
212+
# allocation rejects the pointer attribute; 2.6 had neither the string nor the call.
213+
assert b"CU_CTX_SYNC_MEMOPS" in lib.read(), f"{path} lacks the CUDA VMM sync-memops fallback"
214+
installed = importlib.metadata.version("mooncake-transfer-engine-efa-cuda13")
215+
assert installed == mc_version, f"mooncake-transfer-engine-efa-cuda13 {installed}, expected {mc_version}"
216+
from mooncake.store import MooncakeDistributedStore, ReplicateConfig # noqa: E402,F401
217+
import mooncake.engine # noqa: E402,F401
218+
219+
nixl = importlib.metadata.version("nixl-cu13")
220+
assert nixl == nixl_version, f"nixl-cu13 {nixl}, expected {nixl_version}"
221+
from nixl._api import nixl_agent, nixl_agent_config # noqa: E402,F401
222+
print(f"[kimi-k3-efa] ACTIVE efa-installer {efa_version} libfabric 2.7 ({path}) "
223+
f"mooncake {installed} nixl {nixl} cache {cache}", flush=True)
224+
PY
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
schema: 2
2+
base:
3+
identity:
4+
model: {}
5+
container: {}
6+
frameworks:
7+
vllm: e4a5b5537344b103ed10de7764378ef09604ef3d
8+
dynamo:
9+
install: false
10+
11+
# srtctl's Tachometer exporters slow these workers, and InferenceX does not read their output.
12+
observability:
13+
tachometer:
14+
enabled: false
15+
16+
slurm:
17+
time_limit: 04:00:00
18+
health_check:
19+
max_attempts: 720
20+
interval_seconds: 10
21+
resources:
22+
gpu_type: "b300"
23+
gpus_per_node: 8
24+
frontend:
25+
type: vllm
26+
enable_multiple_frontends: false
27+
engine:
28+
type: vllm
29+
connector: null
30+
roles:
31+
agg:
32+
nodes: 1
33+
workers: 1
34+
gpus: 8
35+
env:
36+
VLLM_FASTSAFETENSORS_QUEUE_SIZE: '-1'
37+
VLLM_ALLREDUCE_USE_FLASHINFER: '1'
38+
VLLM_USE_DIRECT_DCP_A2A: '1'
39+
VLLM_USE_DIRECT_DCP_Q_GATHER: '1'
40+
VLLM_USE_DIRECT_DCP_KV_GATHER: '1'
41+
VLLM_RPC_TIMEOUT: '600000'
42+
VLLM_USE_V2_MODEL_RUNNER: '1'
43+
VLLM_USE_RUST_FRONTEND: '0'
44+
VLLM_PREFIX_CACHE_RETENTION_INTERVAL: '0'
45+
VLLM_LOG_STATS_INTERVAL: '1'
46+
VLLM_ENGINE_READY_TIMEOUT_S: '3600'
47+
args:
48+
served-model-name: moonshotai/Kimi-K3
49+
enable-auto-tool-choice: true
50+
tool-call-parser: kimi_k3
51+
reasoning-parser: kimi_k3
52+
load-format: fastsafetensors
53+
kv-cache-dtype: fp8
54+
mamba-ssm-cache-dtype: float32
55+
gpu-memory-utilization: 0.92
56+
tensor-parallel-size: 8
57+
decode-context-parallel-size: 8
58+
dcp-comm-backend: a2a
59+
trust-remote-code: true
60+
stream-interval: 10
61+
language-model-only: true
62+
moe-backend: auto
63+
no-enable-flashinfer-autotune: true
64+
attention-backend: TOKENSPEED_MLA
65+
attention-config: '{"mla_prefill_backend":"TRTLLM_RAGGED","use_prefill_query_quantization":true}'
66+
enable-prefix-caching: true
67+
prefix-match-unit: 128
68+
max-num-seqs: 8
69+
max-num-batched-tokens: 16384
70+
additional-config: '{"decode_backend":"latency_specialized"}'
71+
sbatch_directives:
72+
# A hung worker can take its host down; never requeue onto fresh nodes.
73+
no-requeue: ""
74+
mem: '0'
75+
comment: '''{"OccupiedIdleGPUsJobReaper":{"exemptIdleTimeMins":"60","reason":"model_loading","description":"Very large model will take extra loading time."}}'''
76+
srun_options:
77+
mem: '0'
78+
container-remap-root: ''
79+
telemetry:
80+
collector_join_timeout_seconds: 12
81+
benchmark:
82+
env:
83+
AIPERF_USE_DYNAMO_CONV_AWARE_ROUTING: '0'
84+
placement:
85+
node: head
86+
override_tp8_dspark7:
87+
roles:
88+
agg:
89+
args:
90+
max-cudagraph-capture-size: 64
91+
# Prefill and mixed steps run without CUDA graphs (the aggregated form of eager prefill); pure decode
92+
# steps keep full CUDA graphs.
93+
compilation-config: '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[7,8,14,16,28,32,56,64]}'
94+
speculative-config: '{"model":"Inferact/Kimi-K3-DSpark","attention_backend":"TOKENSPEED_MLA","method":"dspark","num_speculative_tokens":7,"draft_sample_method":"probabilistic","rejection_sample_method":"block"}'

0 commit comments

Comments
 (0)