Build and run
Prepare dependencies
Section titled “Prepare dependencies”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.
Build service
Section titled “Build service”git clone https://github.com/xLLM-AI/xllm.gitcd xllmgit 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/xxHashcd xllm-servicecmake -S . -B buildcmake --build build --target xllm_master_serving --parallel 8If 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.
Run the service tests
Section titled “Run the service tests”From xllm-service/, configure a Ninja build with tests enabled. The tests/all target builds the service’s test binaries.
cmake -S . -B build-tests -G Ninja -DBUILD_TESTING=ONcmake --build build-tests --target tests/all --parallel 8ctest --test-dir build-tests/tests --output-on-failureStart etcd
Section titled “Start etcd”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.
/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:2380Start service
Section titled “Start service”From the xllm-service/ directory, start the combined HTTP/RPC entry point:
./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-27Btokenizer_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.
Start engines
Section titled “Start engines”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.
Send a request
Section titled “Send a request”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.
Useful service flags
Section titled “Useful service flags”| Flag | Default | Purpose |
|---|---|---|
server_host | empty | Bind address shared by HTTP and RPC listeners |
http_server_port / rpc_server_port | 8888 / 8889 | Client and engine-facing ports |
http_server_num_threads / rpc_server_num_threads | 32 / 32 | Listener thread counts |
http_server_max_concurrency / rpc_server_max_concurrency | 128 / 128 | Request concurrency limits |
http_server_idle_timeout_s / rpc_server_idle_timeout_s | -1 / -1 | Idle connection timeout; -1 disables it |
etcd_namespace | empty | Isolates registration and coordination keys |
load_balance_policy | RR | Scheduling 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.