# xLLM

> An LLM inference engine purpose-built and deeply optimised for Chinese AI accelerators

- Category: Models & Inference / Serving & Deployment
- Language: C++
- Licence: Apache-2.0
- Repository: https://github.com/xLLM-AI/xllm
- Website: https://xllm-ai.com/
- Canonical page: https://ai-tldr.dev/tools/xllm/

## In short

xLLM is an efficient LLM inference framework, specifically optimised for Chinese AI accelerators and aimed at enterprise-grade deployment with higher efficiency and lower cost. Beyond text LLMs it also targets VLM (vision-language), DiT (diffusion) and REC (recommendation) models. It sits in the Serving & Deployment category of the Models & Inference tools and is open-source, written in C++ and licensed Apache-2.0.

## Overview

xLLM is an efficient LLM inference framework, specifically optimised for Chinese AI accelerators and aimed at enterprise-grade deployment with higher efficiency and lower cost. Beyond text LLMs it also targets VLM (vision-language), DiT (diffusion) and REC (recommendation) models. The project originated at JD.com, where the README describes it as battle-tested at scale across the company's core retail business, and in July 2026 it was officially donated to the OpenAtom Foundation.

Its design centre is a service-engine decoupled architecture: an `xLLM Service` layer owns scheduling and availability (a global scheduler with prefill/decode and encode-prefill-decode disaggregation, on/offline co-location, fault recovery and a global cache manager), while the `xLLM Engine` layer owns computation (adaptive graph execution, operator optimisation, a tensor memory manager and a multi-layer pipeline, co-optimised with algorithm-driven techniques such as hierarchical load balancing, speculative inference, dynamic EPLB and a batching scheduler). The two layers communicate through prefill and decode instances that each hold a local KV cache and support KV-cache transfer.

xLLM exposes OpenAI-compatible HTTP endpoints (chat completions, models, vision and embeddings) plus an Anthropic-compatible API, so existing clients can point at it without rewriting their request code. It is written mainly in C++ with a Python model layer, and is distributed both as source built with `setup.py` and as prebuilt container images on Quay.

## What it does

- Serves LLM, VLM, DiT and recommendation (REC) models from one engine, behind OpenAI-compatible and Anthropic-compatible APIs
- Service-engine decoupled architecture: the service layer handles scheduling, availability and fault recovery while the engine layer handles computation
- Prefill/decode and encode-prefill-decode disaggregation, on/offline co-location, prefix caching and a global KV-cache manager
- Engine-level optimisations: adaptive graph execution, operator optimisation, a tensor memory manager and a multi-layer compute pipeline
- Algorithm-driven throughput techniques including hierarchical load balancing, dynamic expert-parallel load balancing (EPLB), speculative inference and a batching scheduler
- Purpose-built for a range of Chinese AI accelerators — Ascend NPU, Cambricon MLU, Hygon DCU, MetaX MACA, Moore Threads MUSA and Iluvatar CoreX — as well as NVIDIA GPU

## Getting started

xLLM runs from a container image that carries the toolchain for your accelerator; you install the wheel from source inside it, then launch the unified `xllm serve` command. The commands below follow the Ascend NPU guide; other backends swap the image and the device flags.

1. Start the development container

   On a host with the vendor driver and Docker installed (for Ascend, confirm `npu-smi info` sees the NPUs), pull an image matching your hardware and CPU architecture from `quay.io/jd_xllm/xllm-ai` and run it with the accelerator devices and driver paths mounted in. The container persists after exit; re-enter it with `docker start -ai xllm-npu`.

```bash
XLLM_IMAGE="quay.io/jd_xllm/xllm-ai:xllm-dev-a3-arm-cann9-20260911"
docker pull "$XLLM_IMAGE"

docker run -it \
  --name xllm-npu --ipc=host -u 0 --privileged --network=host \
  --device=/dev/davinci0 --device=/dev/davinci_manager \
  --device=/dev/devmm_svm --device=/dev/hisi_hdc \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
  -v /usr/local/sbin/:/usr/local/sbin/ \
  -v "$HOME:$HOME" -w "$HOME" \
  "$XLLM_IMAGE" /bin/bash
```

2. Install xLLM from source

   Inside the container, clone the repository, initialise its submodules and build and install the wheel for the backend. `--device` selects the backend (`npu`, `mlu`, `dcu`, `maca`, `musa` or `cuda`); omit it and the installer detects the backend from the current PyTorch environment. Skip this step if your image already ships the wheel and `xllm serve`.

```bash
git clone https://github.com/xLLM-AI/xllm.git
cd xllm

pip install pre-commit
pre-commit install

git submodule update --init --recursive
python setup.py install --device npu

command -v xllm
xllm serve --help
```

3. Launch the service

   Point `MODEL_PATH` at your weights and run the unified `xllm serve`. For a single-machine deployment, set `NNODES` to the number of selected devices (one device per node); the launcher assigns ranks and per-rank ports itself, so run the command once rather than looping per device.

```bash
#!/bin/bash
set -e
export ASCEND_RT_VISIBLE_DEVICES=0

MODEL_PATH="/path/to/model/Qwen3-8B"
PORT=8010
MASTER_NODE_ADDR="127.0.0.1:9748"
NNODES=1

xllm serve \
  --model="$MODEL_PATH" \
  --model_id=Qwen3-8B \
  --port="$PORT" \
  --nnodes="$NNODES" \
  --master_node_addr="$MASTER_NODE_ADDR" \
  --block_size=128 \
  --communication_backend=hccl \
  --max_memory_utilization=0.86 \
  --enable_chunked_prefill=true \
  --enable_schedule_overlap=true \
  --enable_graph=true
```

4. Verify and send a request

   From another shell, wait for the model to load, then query the rank-0 endpoints and send an OpenAI-style chat request. Use the id returned by `/v1/models` (here set by `--model_id`) as the request's `model`.

```bash
curl http://127.0.0.1:8010/health
curl http://127.0.0.1:8010/v1/models

curl http://127.0.0.1:8010/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "Qwen3-8B",
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 64,
    "stream": false
  }'
```

## When to use it

- Reach for it to serve LLMs, vision-language, diffusion or recommendation models on Chinese AI accelerators such as Ascend, Cambricon, Hygon, MetaX, Moore Threads or Iluvatar
- Reach for it when you want prefill/decode disaggregation, prefix caching and a global KV-cache manager for high-throughput, low-latency enterprise serving
- Reach for it when existing clients speak the OpenAI or Anthropic API and you want a drop-in compatible endpoint on non-NVIDIA hardware
- Reach for it for large multi-machine deployments where the service layer must handle scheduling, co-location and fault recovery across a cluster
