post-training-rlhf
Guide the train-llm-from-scratch post-training alignment pipeline: SFT, reward modeling, DPO/ORPO/KTO, PPO, GRPO/RLVR, rollout/log-prob mechanics, metrics, and troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- post-training-rlhf
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guide the train-llm-from-scratch post-training alignment pipeline: SFT, reward modeling, DPO/ORPO/KTO, PPO, GRPO/RLVR, rollout/log-prob mechanics, metrics, and troubleshooting.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/algorithm-reference.md9.2 KB
- 参考文档references/stage-workflows.md9.3 KB
- 参考文档references/troubleshooting.md8.4 KB
- 脚本scripts/build_stage_command.py6.5 KB
- 脚本scripts/inspect_metrics_jsonl.py4.9 KB
- 脚本scripts/plan_posttraining_pipeline.py7.1 KB
03 SKILL.md 正文
Post-Training RLHF Router
Use this sub-skill when the task is about turning a pretrained base checkpoint into aligned instruction/reasoning checkpoints with this repo's from-scratch post-training stack.
Use this for
- Running or debugging SFT, reward-model training, DPO/ORPO/KTO, PPO, and GRPO/RLVR stages.
- Understanding masked SFT loss, Bradley-Terry reward modeling, preference objectives, PPO GAE/clipping/KL, GRPO group-relative advantages, rollout generation, log-prob recomputation, and verifier rewards.
- Planning checkpoint/data dependencies across
base_pretrained.pt -> sft.pt -> reward.pt / dpo.pt / ppo.pt / grpo.pt. - Interpreting stage JSONL metrics and deciding safe recovery actions.
- Building dry-run stage commands before launching expensive training.
Route elsewhere
- Prepare or validate raw Pile/SFT/preference/RL prompt files:
../data-preparation/SKILL.md. - Pretrain the base Transformer or inspect model architecture:
../model-pretraining/SKILL.md. - Run GSM8K table evaluation, parse answers for evaluation, or chat with a checkpoint:
../evaluation-chat/SKILL.md. - Edit config files through forms, use the Streamlit UI, or explain config merge precedence:
../configuration-ui/SKILL.md.
Fast operating path
- Identify the requested stage and verify its upstream checkpoint/data dependencies with references/stage-workflows.md.
- Use scripts/build_stage_command.py or scripts/plan_posttraining_pipeline.py to print a dry-run command. Inspect it before running anything expensive.
- For algorithm-specific questions, use references/algorithm-reference.md to map metrics and function names to the underlying loss/reward/log-prob mechanics.
- For failures, start with references/troubleshooting.md, then route to data/model/eval/UI sub-skills when the root cause is outside post-training.
- Inspect JSONL metrics with scripts/inspect_metrics_jsonl.py before changing hyperparameters; prefer the smallest recovery that matches the observed metric failure.
Safety and scope notes
- The bundled scripts are dry-run or read-only helpers. They do not download data, train, delete checkpoints, or modify configs.
- Training commands assume the user is in their own repo checkout or compatible workspace and has already prepared data/checkpoints.
- Keep log-prob math in fp32 when comparing policy/reference/old log-probs; do not "optimize" this away under bf16.
- Treat Weights & Biases as optional. JSONL metrics are the source of truth.
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).