Skip to content
xLLM xLLM PR preview
EN

Build and run

Build service in a Linux development environment with CMake 3.26 or later, a compiler supporting C++20, Rust/Cargo, Python with PyTorch, Git and the native build tools required by its dependencies. For Ascend engines, prepare the compatible xLLM/CANN environment using Quick start. Install the etcd server separately using the official releases.

Service uses vcpkg for dependencies including Boost, gRPC, Protobuf, OpenSSL and ZeroMQ. CMake detects PyTorch’s C++ ABI; use a consistent build environment.

Terminal window
git clone https://github.com/xLLM-AI/xllm.git
cd xllm
git submodule update --init third_party/brpc third_party/cpprestsdk third_party/etcd_cpp_apiv3 \
third_party/minja third_party/sentencepiece third_party/smhasher third_party/xxHash
cd xllm-service
cmake -S . -B build
cmake --build build --target xllm_master_serving --parallel 8

If Boost locale/interprocess headers are missing when reusing a vcpkg installation, repair those packages with the triplet matching your architecture (arm64-linux or x64-linux) and rerun CMake. Avoid copying a vcpkg build from a different architecture or ABI.

From xllm-service/, configure a Ninja build with tests enabled. The tests/all target builds the service’s test binaries.

Terminal window
cmake -S . -B build-tests -G Ninja -DBUILD_TESTING=ON
cmake --build build-tests --target tests/all --parallel 8
ctest --test-dir build-tests/tests --output-on-failure

Run the following in a separate terminal. The loopback addresses below describe a single-host example; for multiple hosts, use addresses reachable by every participant.

Terminal window
/path/to/etcd --name=default --data-dir=/path/to/etcd-data \
--listen-client-urls=http://127.0.0.1:2379 \
--advertise-client-urls=http://127.0.0.1:2379 \
--listen-peer-urls=http://127.0.0.1:2380 \
--initial-advertise-peer-urls=http://127.0.0.1:2380 \
--initial-cluster=default=http://127.0.0.1:2380

From the xllm-service/ directory, start the combined HTTP/RPC entry point:

Terminal window
./build/xllm_service/xllm_master_serving \
--etcd_addr=127.0.0.1:2379 \
--etcd_namespace=demo \
--http_server_port=8888 \
--rpc_server_port=8889 \
--load_balance_policy=RR --block_size=128 \
--tokenizer_path=/path/to/Qwen3.8-27B

tokenizer_path must contain the tokenizer configuration for the engines’ model. HTTP accepts client requests; RPC communicates with engines. The HTTP port may remain closed until a complete instance group registers. Engines must be able to reach the RPC port; in PD mode, Decode returns all generated tokens, including the first, through this port.

For a P/D deployment, follow the Qwen3.8-27B image chat example. It starts one four-device Prefill instance and one four-device Decode instance, then sends a generated image and a question through this gateway.

For an instance that performs both phases locally, start your model as described in Launch xLLM and add --enable_service_routing=true --instance_role=DEFAULT --etcd_addr=127.0.0.1:2379 --etcd_namespace=demo. Additional DEFAULT instances use separate devices and ports.

Once the group has registered, check the model ID with curl -fsS http://127.0.0.1:8888/v1/models. Run the image and text request against this same gateway. It generates a red PNG locally and asks Qwen3.8-27B to identify its color.

The gateway returns parsed reasoning in message.reasoning or, when streaming, delta.reasoning, just like the direct xLLM endpoint. You can include the returned assistant message in the next request’s messages.

FlagDefaultPurpose
server_hostemptyBind address shared by HTTP and RPC listeners
http_server_port / rpc_server_port8888 / 8889Client and engine-facing ports
http_server_num_threads / rpc_server_num_threads32 / 32Listener thread counts
http_server_max_concurrency / rpc_server_max_concurrency128 / 128Request concurrency limits
http_server_idle_timeout_s / rpc_server_idle_timeout_s-1 / -1Idle connection timeout; -1 disables it
etcd_namespaceemptyIsolates registration and coordination keys
load_balance_policyRRScheduling policy

Set ENABLE_XLLM_DEBUG_LOG=1 when starting service to enable its debug logs.

For optional cache-aware routing, continue with KV events and CAR.

Report issue