advanced-rl-distributed
Plan and debug advanced ms-swift RLHF, GRPO/GKD, rollout, Ray, and Megatron distributed workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- advanced-rl-distributed
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Plan and debug advanced ms-swift RLHF, GRPO/GKD, rollout, Ray, and Megatron distributed workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/ray-megatron-workflows.md12.2 KB
- 参考文档references/rlhf-grpo-workflows.md11.5 KB
- 参考文档references/troubleshooting.md11.0 KB
- 脚本scripts/build_rlhf_command.py13.8 KB
- 脚本scripts/check_optional_backends.py7.4 KB
03 SKILL.md 正文
Advanced RL and Distributed Execution
Use this sub-skill when the task involves advanced preference optimization, GRPO rollout orchestration, custom rewards/plugins, Ray scheduling, or Megatron-SWIFT distributed execution in ms-swift.
Route Here For
swift rlhfwith--rlhf_type grpo,gkd,ppo,dpo,kto,rm,cpo,simpo, ororpowhen the task asks for RLHF mechanics, reward behavior, rollout placement, or advanced algorithm options.swift sampleandswift rolloutwhen sampling, PRM/ORM filtering, rollout servers, vLLM weight sync, or multi-turn rollout servers are part of an RL plan.megatron rlhf,megatron sft,megatron export, Ray YAML configs, Mcore-Bridge, TP/PP/CP/EP/VPP, sequence parallel, and multi-node launch debugging.- Custom GRPO reward functions, async rewards, reward models, multi-turn schedulers, gym environments, and plugin registration.
Reroute Instead
- Basic SFT/pretraining command construction belongs in the sibling training sub-skill.
- Dataset field conversion, custom data schemas, and template/data registration belong in the sibling data-model-customization sub-skill.
- Inference, serving, and deployment belong in the sibling inference-deployment sub-skill, except when the server is a GRPO rollout server.
- Export and standalone evaluation belong in the sibling export-evaluation sub-skill, except Megatron conversion choices needed for RL training.
Required Reads
- RLHF and GRPO workflows for algorithm choice,
swift rlhf, reward/plugin patterns, sampling, rollout servers, and multi-turn guidance. - Ray and Megatron workflows for Megatron-SWIFT, Ray configs, Mcore-Bridge, parallelism dimensions, and hardware placement.
- Troubleshooting for missing extras, reward field pass-through, rollout placement, Ray JSON/YAML, torchrun variables, and Megatron shape/parallel errors.
- RLHF command builder to produce safe command or Ray YAML skeletons without executing training.
- Optional backend checker to report CLI/module availability for Ray, Megatron, Mcore-Bridge, vLLM, LMDeploy, SGLang, evalscope, and CUDA without requiring GPUs.
Fast Decision Guide
| User Need | Start With | Key Checks |
|---|---|---|
| GRPO with custom rewards | swift rlhf --rlhf_type grpo |
num_generations >= 2, reward names registered, required dataset columns passed through |
| External rollout server | swift rollout plus swift rlhf --vllm_mode server |
host/port/base URL, --vllm_server_pass_dataset true for multi-turn/env rows |
| Megatron GRPO/GKD | megatron rlhf |
optional Megatron stack, TP×PP×CP divisibility, completion-level batch formulas |
| Ray Megatron GRPO/GKD | megatron rlhf --use_ray true --config CONFIG.yaml |
train, rollout, optional teacher GPU groups, colocate vs separate mode |
| Sampling/RFT data generation | swift sample |
sampler engine, PRM/ORM memory split, cache file pass, plugin registration |
Optional Dependency Caveats
A minimal ms-swift install can expose the base swift routes while advanced backends remain absent. Treat missing ray, megatron-core, mcore-bridge, transformer-engine, apex, flash-attn, vllm, lmdeploy, sglang, or evalscope as optional capability gaps to solve only for the requested workflow. For Megatron-SWIFT, install the Megatron extra and a compatible Megatron-style stack such as pip install "ms-swift[megatron]" -U, then validate with the backend checker before planning GPU-heavy commands.
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).