Files
project_6/upstream_ref/xllm/xllm/c_api
EX Engine 002f9879b2 ref(upstream): FULL TREE — Deep-Spark xllm (1470) + ds_vllm csrc/models (703)
Replaces cherry-picked upstream_ref with complete source trees.

xllm/ — Iluvatar official C++ inference engine (15MB, 1470 files)
  Complete: kernels → layers → models → runtime → scheduler → api
  Excluded: .git, binary images, third_party submodule checkouts

ds_vllm/ — Iluvatar official vllm fork (8MB, 703 files)
  Included: csrc/ (ALL CUDA kernels), fused_moe/, qwen3_5 model, _custom_ops
  Excluded: tests, benchmarks, docs, examples (not needed for reference)

Critical call chains now fully traceable:
  MoE: moe_topk_softmax_kernels.cuh → ixformer.h → fused_moe.cpp → layer
  GDN: qwen3_gated_delta_net_base.cpp → qwen3_5_gated_delta_net.cpp
  Attention: ixformer.h → xllm_paged_attention → attention.cpp
2026-08-10 02:54:03 +00:00
..

How to compile xllm dynamic library

Run the following command in root directory:

python setup.py build --generate-so true

If you want to debug, it needs to set DEBUG environment variable.

export DEBUG=1

How to install dynamic library

Run installation script xllm/c_api/install.sh, headers and dynamic library will be installed in /usr/local/xllm directory.

cd xllm/c_api/tools

sh install.sh

You will see the following files in /usr/local/xllm directory:

[root@A03-R40-I189-101-4100046]# tree /usr/local/xllm
/usr/local/xllm
|-- include
|   |-- llm.h
|   |-- default.h
|   |-- rec.h
|   `-- types.h
`-- lib
    `-- libxllm.so

3 directories, 5 files

How to compile c_api examples

GPU builds and NPU builds use different link commands. Replace <example>.cpp and <example> with the example source file and output binary name you want to build.

GPU

cd xllm/c_api/examples
g++ <example>.cpp -o <example> \
  -std=c++17 \
  -DUSE_CUDA \
  -I/usr/local/xllm/include \
  -L/usr/local/xllm/lib \
  -lxllm \
  -Wl,-rpath=/usr/local/xllm/lib

NPU

Before compiling or running examples, source the Ascend environment first:

source /usr/local/Ascend/ascend-toolkit/set_env.sh

Then compile with the extra custom op library used by the NPU build:

cd xllm/c_api/examples
g++ <example>.cpp -o <example> \
  -std=c++17 \
  -DUSE_NPU \
  -I/usr/local/xllm/include \
  -L/usr/local/xllm/lib \
  -L/usr/local/Ascend/ascend-toolkit/latest/opp/vendors/xllm/op_api/lib \
  -lxllm \
  -lcust_opapi \
  -Wl,-rpath=/usr/local/xllm/lib \
  -Wl,-rpath=/usr/local/Ascend/ascend-toolkit/latest/opp/vendors/xllm/op_api/lib

If -lcust_opapi is missing from the NPU link command, the linker may report undefined references to symbols such as aclnnBeamSearchGroup and aclnnXAttention.

How to run c_api examples

Some examples, such as simple_rec_completions, support overriding the target device from argv[1].

NPU

./simple_rec_completions npu:14

GPU

./simple_rec_completions cuda:0