๐ฆ Installation and Hardware Support
๐ฆ Wheel installation
๐๏ธ Local training
pip install 'ms-swift>=5.0.0'
# Optional dependencies
pip install 'ms-swift[megatron]' # Megatron backend: installs mcore-bridge and megatron-core; must match the local CUDA environment, so it is not included in all
pip install 'ms-swift[eval]' # For evaluation; installs evalscope and the opencompass / vlmeval backends
# Install with uv, which selects the PyTorch build matching the current device automatically
pip install uv
uv pip install 'ms-swift>=5.0.0' --torch-backend=auto๐ Deploying the SaaS training service
Install on a machine that provides GPU compute. The server is in charge of the model, the sampler, and resource configuration, and the client submits training operations through it. When starting the service with swift deploy, ms-swift needs to be installed on the same machine:
pip install twinkle-server ms-swift>=5.0.0For the full deployment steps see Training service (twinkle-server).
๐ก Client for remote training
Install on the machine that submits training jobs. The client does not need a local GPU:
pip install twinkle-client
# The `--mode remote` argument of swift switches training smoothly to the training service; install ms-swift to use it:
pip install ms-swift>=5.0.0๐ฆ Source installation
To use the development branch or modify the code, clone the repository and install into the same Python environment:
git clone https://github.com/modelscope/ms-swift.git
cd ms-swift
pip install -e .
uv pip install -e . --torch-backend=auto # with uv๐งฐ Supported hardware
| Hardware | Notes | Reference |
|---|---|---|
| NVIDIA GPU | Supported by default. Examples on this site use NVIDIA GPU with BF16 | โ |
| AMD GPU | Use the ROCm build of PyTorch | AMD GPU support |
| Ascend NPU | Install torch-npu matching CANN, and prepare the Ascend extensions according to the inference engine | Ascend NPU support |
| Kunlunxin XPU | Use the torch_xmlir and vLLM image provided by Kunlunxin. twinkle detects the device through xpu-smi, and multi-GPU communication uses BKCL | โ |
| MetaX GPU | Use the MACA build of PyTorch and the official prebuilt image | MetaX support |
| Moore Threads MUSA GPU | Supported through torch_musa and torchada. Use the official training image | Moore Threads MUSA support |
| Apple MPS | Usable for local inference or small-scale training of compatible models | issue |
| CPU | Usable for local inference or small-scale training of compatible models | โ |
โ Supported model frameworks
The first three are selected by --backend, which defaults to transformers when left empty. sentence_transformers has no switch and is selected automatically only under the embedding task.
| Capability | transformers | megatron | unsloth | sentence_transformers |
|---|---|---|---|---|
| Install | โ | pip install 'ms-swift[megatron]' | pip install unsloth | pip install sentence-transformers |
| Task types | All | All | causal_lm | embedding |
| Training method | Full-parameter / LoRA | Full-parameter / LoRA | Full-parameter / LoRA | Full-parameter / LoRA |
| TP / PP / CP / EP | Partially supported | Supported | Not supported | Not supported |
| DeepSpeed | Supported | Not supported | Not supported | Not supported |
| FSDP | Supported | Supported | Not supported | Supported |
| Quantized training | Supported | Not supported | BNB only | Not supported |
unsloth does not support evaluation during training.
โ Supported samplers
The sampler backend has three options: vllm, sglang, and transformers. The tables below list only the limits on the ms-swift side. Whether a model can run also depends on whether the engine itself supports it.
โ Task types
| Task type | vllm | sglang | transformers |
|---|---|---|---|
Text / multimodal generation (causal_lm) | Supported | Supported | Supported |
generative_reranker | Supported | Supported | Supported |
embedding, seq_cls, reranker | Supported | Supported | Not supported |
decision | Not supported | kev and clef only. --adapters not supported | Not supported |
โ Training support
| Capability | vllm | sglang | transformers |
|---|---|---|---|
Quantization at model load (--quant_method) | Not supported | Not supported | Supported |
Quantization at engine load (--vllm_quantization / --sglang_quantization) | Supported | Supported | N/A |
| Low-precision weight sync | FP8, MXFP4 for some models | Not supported | โ |
LoRA serving (--adapters) | Supported | Supported | Supported |
| Online RL rollout and weight sync | Supported | Supported | Not supported |
delta sync | Supported, not for MoE and quantized models | Supported | N/A |
colocate mode | Supported, requires --parameter_sync_step 1 | Same as vllm | N/A |