Skip to content

feat: add Kunlunxin XPU support - #289

Open
loveleaves wants to merge 4 commits into
modelscope:mainfrom
loveleaves:feat/xpu-support
Open

loveleaves wants to merge 4 commits into
modelscope:mainfrom
loveleaves:feat/xpu-support

Conversation

@loveleaves

Copy link
Copy Markdown

Summary

Adds Kunlunxin XPU (P800) support to Twinkle via the cuda-alike route (torch_xmlir rewrites torch.cuda, BKCL mounted as the nccl/XCCL backend). The XPU platform inherits from GPU, so most GPU code paths work unchanged; only a few CUDA-specific assumptions are adapted.

Commits follow the adaptation order:

  • Platform detection (XPU platform, xpu-smi detection, ensure_xpu_compat, vLLM device-UUID fallback)
  • Ray scheduling (register cuda-alike GPU count via ray.init(num_gpus=N))
  • XCCLCheckpointEngine for weight sync (stateless ProcessGroupXCCL + relay for duplicate local device indices)
  • Documentation (EN/ZH XPU support guide + XCCLCheckpointEngine docs, toctree/hardware/engine tables)

Verified on P800 (single-host, 8-card)

  • FSDP2 LoRA SFT (transformers)
  • vLLM sampling TP=1 / TP=2 (enforce_eager=True, text models)
  • GRPO colocate with full-weight sync (merge_and_sync=True), relay ~0.7 GB/s
  • Megatron LoRA TP=2 (zero code change)

Known limitations (vendor stack, not Twinkle)

  • LoRA sampling blocked (fp16-only LoRA kernels on 0.21)
  • Some models require fp16 (GDN FLA kernels)
  • CUDA graph disabled (enforce_eager=True)
  • Multimodal (Qwen-VL) blocked by ViT SDPA kernel crash
  • XCCLCheckpointEngine multi-host not yet validated (single-host relay verified)

See docs/.../XPU-Support.md for details.

changbo01 added 4 commits September 17, 2026 20:34
Introduce the XPU platform (inherits GPU for the cuda-alike route),
detect it via xpu-smi, and neutralize torch's native Intel-XPU stub
through ensure_xpu_compat(). Provide a device-UUID fallback chain for
vLLM (current_platform -> xpu-smi -q Bus Id -> xpu-smi -L UUID -> sha1).
Ray cannot autodetect XPUs (no nvidia-smi), so register the cuda-alike
GPU count through ray.init(num_gpus=N) instead of the resources= dict,
which rejects the reserved 'GPU' key.
Direct ProcessGroupNCCL deadlocks on XPU when ranks share a local
device index. XCCLCheckpointEngine exchanges (host, local_dev_idx) via
the store, builds a stateless ProcessGroupXCCL, and relays colliding
ranks over TCP sockets. Manager/mixin route XPU to this engine.
Add user-facing XPU-Support guide (EN/ZH) and XCCLCheckpointEngine docs,
register them in the toctrees, and list Kunlunxin XPU in the hardware
and checkpoint-engine tables.
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