Skip to Content
MS-SWIFT ร— TWINKLE
๐Ÿš€ Get Started
DOCUMENTATION5.0.0.dev

๐Ÿ“ฆ 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

Dependencies of ms-swift and twinkle

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.0

For 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

HardwareNotesReference
NVIDIA GPUSupported by default. Examples on this site use NVIDIA GPU with BF16โ€”
AMD GPUUse the ROCm build of PyTorchAMD GPU support
Ascend NPUInstall torch-npu matching CANN, and prepare the Ascend extensions according to the inference engineAscend NPU support
Kunlunxin XPUUse the torch_xmlir and vLLM image provided by Kunlunxin. twinkle detects the device through xpu-smi, and multi-GPU communication uses BKCLโ€”
MetaX GPUUse the MACA build of PyTorch and the official prebuilt imageMetaX support
Moore Threads MUSA GPUSupported through torch_musa and torchada. Use the official training imageMoore Threads MUSA support
Apple MPSUsable for local inference or small-scale training of compatible modelsissue
CPUUsable 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.

Capabilitytransformersmegatronunslothsentence_transformers
Installโ€”pip install 'ms-swift[megatron]'pip install unslothpip install sentence-transformers
Task typesAllAllcausal_lmembedding
Training methodFull-parameter / LoRAFull-parameter / LoRAFull-parameter / LoRAFull-parameter / LoRA
TP / PP / CP / EPPartially supportedSupportedNot supportedNot supported
DeepSpeedSupportedNot supportedNot supportedNot supported
FSDPSupportedSupportedNot supportedSupported
Quantized trainingSupportedNot supportedBNB onlyNot 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 typevllmsglangtransformers
Text / multimodal generation (causal_lm)SupportedSupportedSupported
generative_rerankerSupportedSupportedSupported
embedding, seq_cls, rerankerSupportedSupportedNot supported
decisionNot supportedkev and clef only. --adapters not supportedNot supported

โœ… Training support

Capabilityvllmsglangtransformers
Quantization at model load (--quant_method)Not supportedNot supportedSupported
Quantization at engine load (--vllm_quantization / --sglang_quantization)SupportedSupportedN/A
Low-precision weight syncFP8, MXFP4 for some modelsNot supportedโ€”
LoRA serving (--adapters)SupportedSupportedSupported
Online RL rollout and weight syncSupportedSupportedNot supported
delta syncSupported, not for MoE and quantized modelsSupportedN/A
colocate modeSupported, requires --parameter_sync_step 1Same as vllmN/A