ms-swift
Use ms-swift for LLM and multimodal training, inference, deployment, data/model customization, export, evaluation, RLHF, Ray, and Megatron workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- ms-swift
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use ms-swift for LLM and multimodal training, inference, deployment, data/model customization, export, evaluation, RLHF, Ray, and Megatron workflows.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/package-overview.md4.4 KB
- 参考文档references/repo-provenance.md1.5 KB
- 参考文档references/repo-routing-metadata.json561 B
- 参考文档references/troubleshooting.md3.8 KB
- 脚本scripts/check_ms_swift_install.py4.6 KB
- 脚本scripts/inspect_swift_cli.py2.6 KB
03 SKILL.md 正文
ms-swift
Use this repo skill when a task mentions ms-swift, swift, ModelScope SWIFT, swift sft, swift infer, swift deploy, swift eval, swift export, swift rlhf, GRPO, Ray, or Megatron-SWIFT.
ms-swift is a Python framework for large-model and multimodal fine-tuning, inference, evaluation, quantization, deployment, RLHF/GRPO, Ray scheduling, and Megatron-style distributed training.
First Checks
- Public package: install with
pip install ms-swift -U; from source usepip install -e .. - Import check:
python -c "import swift; print(swift.__version__)". - CLI check:
swift sft --help,swift infer --help,swift export --help, andswift rlhf --helpshould work in a base install. - Optional extras are workflow-specific: evaluation needs EvalScope, advanced Megatron needs Megatron packages, and accelerated serving needs vLLM/SGLang/LMDeploy as appropriate.
- Use local model and dataset paths plus offline flags when users cannot download from ModelScope or HuggingFace.
Route by User Goal
- Train or fine-tune models: read
sub-skills/training/SKILL.mdforswift pt,swift sft, LoRA/QLoRA/full tuning, multimodal training, checkpoints, YAML/JSON configs, and training-time evaluation flags. - Infer, serve, or call a local model: read
sub-skills/inference-deployment/SKILL.mdforswift infer,swift app,swift deploy, backend selection, OpenAI-compatible APIs, adapters, batch inference, logprobs, and multimodal requests. - Prepare data or register models/templates: read
sub-skills/data-model-customization/SKILL.mdfor dataset formats,--columns,--custom_dataset_info,--external_plugins, registry inspection, custom models, and templates. - Export, quantize, push, or evaluate: read
sub-skills/export-evaluation/SKILL.mdforswift export,swift merge-lora, quantization, hub pushes,swift eval, EvalScope backends, and custom eval datasets. - Use RLHF, GRPO, Ray, or Megatron: read
sub-skills/advanced-rl-distributed/SKILL.mdforswift rlhf,swift sample,swift rollout, reward plugins, Ray configs, Megatron-SWIFT, and distributed troubleshooting.
Shared References and Scripts
- Read
references/package-overview.mdfor package purpose, CLI route map, optional extras, and cross-skill terminology. - Read
references/troubleshooting.mdfor install/import, optional dependency, backend, hub/offline, CLI/config, and hardware issues that cut across workflows. - Read
references/repo-provenance.mdwhen checking whether this skill is stale against a newer ms-swift checkout. - Run
scripts/check_ms_swift_install.py --helpfor a safe installed-package and optional-dependency checker. - Run
scripts/inspect_swift_cli.py --helpfor a safe CLI route inventory and help-command planner.
Common Decision Points
- Use
--modelfor full checkpoints or model IDs; use--adaptersfor LoRA adapter checkpoints. - If a LoRA checkpoint must run on vLLM/SGLang/LMDeploy as a merged full model, route through export/merge guidance first; do not promise QLoRA merge support.
- If a task asks for dataset rows, schemas, media fields, or
loss_scale, solve that in data/model customization before constructing training or RLHF commands. - If a task asks for deployment performance, distinguish model support from package availability: base ms-swift may install while vLLM, SGLang, LMDeploy, EvalScope, Ray, or Megatron extras remain absent.
- If a task asks for GRPO or custom rewards, confirm the dataset fields and reward function signature before planning rollout placement or Ray/Megatron parallelism.
Runtime Safety
- The bundled scripts print diagnostics or command skeletons; they do not launch training, download models, start servers, or push to hubs unless their help explicitly says otherwise.
- Treat model downloads, hub pushes, long training, evaluation benchmarks, Ray/Megatron clusters, and accelerated serving as user-controlled side effects.
- Keep credentials in environment variables such as
MODELSCOPE_TOKEN,HF_TOKEN, or a user-provided shell environment; do not write tokens into command builders or config examples.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).