Skip to content

feat: add xlite as third npu backend (support qwen3-dense/qwen3-moe/glm-4.7/glm-5.1/glm-5.2) - #2282

Open
banxiaduhuo wants to merge 1 commit into
xLLM-AI:mainfrom
banxiaduhuo:main
Open

feat: add xlite as third npu backend (support qwen3-dense/qwen3-moe/glm-4.7/glm-5.1/glm-5.2)#2282
banxiaduhuo wants to merge 1 commit into
xLLM-AI:mainfrom
banxiaduhuo:main

Conversation

@banxiaduhuo

@banxiaduhuo banxiaduhuo commented Aug 23, 2026

Copy link
Copy Markdown

Description

This PR adds xlite as a third NPU backend for xLLM, alongside the existing ATB backend. xlite is a lightweight NPU inference runtime that directly calls CANN ops without the aclgraph abstraction layer, providing lower launch overhead and higher TTFT.

The adapter integrates xlite into xLLM's model layer through a thin C++ adapter (xlite/core/layers/xlite/), supporting five model architectures out of the box:

  • Qwen3-Dense
  • Qwen3-MoE
  • GLM-4.7
  • GLM-5.1
  • GLM-5.2

About xlite

xlite is a lightweight XPU virtualization frontend and backend inference runtime. It provides a minimalist and efficient heterogeneous computing environment, supporting diverse computing power collaboration. See https://gitcode.com/openeuler/GVirt/blob/master/README.en.md.

Key changes

  • Adapter layer (xllm/core/layers/xlite/, 9 files ~1700 lines): xlite_causal_lm_base / xlite_config_builder / xlite_weight_utils / xlite_attn_meta_builder / xlite_freqs_cis / xlite_init_utils / xlite_model_adapter / xlite_register_macros. Bridges xlite's XModel runtime into xLLM's CausalLMBase lifecycle (load → init → forward), mapping xLLM weight tensors to xlite MatmulWeight/MoEWeight with per-model quantization field binding.
  • Per-model adapters (xllm/models/llm/xlite/adapters/, 5 files): qwen3_adapter / qwen3_moe_adapter / glm4_moe_adapter / glm5_adapter / deepseek_v3_adapter + register_all.h (299 lines, model registry wiring).
  • Runtime (xlite_executor_impl.cpp/h): XliteExecutorImpl implements init/forward/sync over xlite's XModel::Forward, with node_rank % device_count auto device selection (no --devices needed).
  • Build (cmake/xlite.cmake, CMakeLists.txt): USE_XLITE=ON links libxlite.so from site-packages, propagates -L/-rpath-link to all executables.
  • W8A8 quantization support: IsW8A8(context) guard (derived from quant_model_description.json) replaces hardcoded quantAttnWeightTrans=true, fixing a BF16 shared-expert layout regression (_isSharedExpertWeightFull is read unconditionally at construction). MLA four STATIC projections (mlaQKVA/mlaQB/attnOut/indexQB) + down_proj deqScale + shared indexer binding for GLM-5.2.

Verification

功能验证

All milestones verified by smoke (script/smoke/verify.sh, EP8 减层 functional) + EvalScope perf + msprof per-step 算子级对比 vs ATB:

  • Functional: Qwen3-0.6B TP1 / Qwen3-32B TP2 / Qwen3-30B-A3B MoE EP4 / GLM-4.7-W8A8 EP8 / GLM-5.1 BF16 / GLM-5.2-W8A8 EP8+DP2×EP8 — all pass.
  • Correctness: 三方对比 (ref_xlite / xllm / ATB), L0 input 完全匹配 ref; 三方 (ref_xlite / xllm / ATB) 逐 token 完全一致.
  • Performance: 28 层减层 GLM-5.2-W8A8 EP8 vs ATB graph (各自最优可用配置), 见下方性能对比数据.
EvalScope perf — input_32 (decode 为主, prompt=32tok, output=128tok)
并发 指标 xlite ATB graph 差异
1 TPOT(ms) P50/Avg 12.3 / 12.3 11.9 / 11.9 +3% (持平)
1 TTFT(ms) P50/Avg 30.2 / 30.5 71.9 / 75.4 -58% / -59%
1 Gen/s 80.40 61.50 +31%
4 TPOT(ms) P50/Avg 14.6 / 14.6 15.1 / 15.1 -3% (xlite 略优)
4 TTFT(ms) P50/Avg 55.2 / 51.2 98.0 / 115.6 -44% / -56%
4 Gen/s 269.35 250.86 +7%
16 TPOT(ms) P50/Avg 20.0 / 20.0 20.2 / 20.4 -1% / -2% (持平)
16 TTFT(ms) P50/Avg 78.2 / 74.0 214.8 / 196.8 -64% / -62%
16 Gen/s 782.44 730.40 +7%
EvalScope perf — input_2000 (prefill 重 + DSA 稀疏, prompt=2000tok, output=128tok)
并发 指标 xlite ATB graph 差异
1 TPOT(ms) P50/Avg 13.8 / 13.8 13.9 / 13.9 -1% (持平)
1 TTFT(ms) P50/Avg 128.7 / 129.0 319.4 / 319.5 -60%
1 Gen/s 68.01 49.59 +37%
4 TPOT(ms) P50/Avg 17.3 / 17.6 20.9 / 19.4 -17% / -9%
4 TTFT(ms) P50/Avg 314.9 / 278.2 1144.9 / 809.3 -73% / -66%
4 Gen/s 204.20 155.50 +31%
16 TPOT(ms) P50/Avg 31.8 / 31.8 41.3 / 42.8 -23% / -26%
16 TTFT(ms) P50/Avg 421.8 / 421.8 1678.7 / 1444.1 -75% / -71%
16 Gen/s 458.94 284.03 +62%

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

@banxiaduhuo banxiaduhuo changed the title [WIP]feat: add xlite as third npu backend (support qwen3-dense/qwen3-moe/glm-4.7/glm-5.1/glm-5.2) feat: add xlite as third npu backend (support qwen3-dense/qwen3-moe/glm-4.7/glm-5.1/glm-5.2) Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant