policy-optimization
Guide PPO, GRPO, TPO, and FlowRL post-training loops for palm-rlhf-pytorch, including bounded RLHF smoke checks.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- policy-optimization
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guide PPO, GRPO, TPO, and FlowRL post-training loops for palm-rlhf-pytorch, including bounded RLHF smoke checks.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md5.8 KB
- 参考文档references/trainer-selection.md2.5 KB
- 参考文档references/troubleshooting.md2.7 KB
- 参考文档references/workflows.md2.2 KB
- 脚本scripts/tiny_rlhf_smoke.py3.4 KB
03 SKILL.md 正文
Policy Optimization
Use this sub-skill when a task is about post-training a PaLM policy with the package trainers: PPO RLHFTrainer, ActorCritic, GRPO, TPO, or FlowRL.
Route Here For
- Default PPO RLHF workflows that use the root exports
RLHFTrainerandActorCritic. - Trainer selection questions: PPO vs GRPO vs TPO vs FlowRL.
- Bounded tiny smoke checks that verify trainer construction, prompt token id handling, and a single short training or generation step.
- Side-effect awareness for replay buffers, partition functions, and Accelerate-wrapped modules.
Do Not Use This For
- Base PaLM construction, generation, or LoRA scope wiring; route those to
palm-modeling. - Reward training or implicit process reward workflows; route those to
reward-modeling. - Long training, benchmarks, or full RLHF scaling runs. This sub-skill covers mechanics and smoke checks, not expensive experiments.
Start Here
- For API facts, read
references/api-reference.md. - For trainer choice, read
references/trainer-selection.md. - For bounded recipes and the tiny smoke workflow, read
references/workflows.md. - For known failures and source footguns, read
references/troubleshooting.md. - To verify the installed package, run the bundled helper instead of the source example script:
python sub-skills/policy-optimization/scripts/tiny_rlhf_smoke.py --device auto --train-smoke
If you only want a construction check first, add --construct-only.
Operating Notes
- The root export
from palm_rlhf_pytorch import RLHFTrainer, ActorCriticis the PPO path. - GRPO, TPO, and FlowRL are module-qualified trainers and should be selected intentionally.
- Every trainer expects exactly one prompt input style:
prompts,prompts_path, orprompt_token_ids. - Raw text prompts require a tokenizer that returns padded token-id tensors.
- Keep smoke runs tiny. The source defaults are much larger than a verification check needs.
examples.pyis useful evidence, but it is not the preferred runtime path for this sub-skill because it depends on an undeclaredlion_pytorchextra and uses expensive defaults.- PPO updates actor and critic/value parameters; the newer trainer variants change the training state and storage pattern in different ways.
Common Prompt Patterns
- "Which trainer should I use?" → start with
trainer-selection.md. - "Need a tiny RLHF smoke test" → use
scripts/tiny_rlhf_smoke.pywith--construct-onlyor--train-smoke. - "Using raw prompts" → provide a tokenizer and confirm padding.
- "Need prompt-token-id wiring" → use the root PPO path first because it matches the README example shape.
- "Need a critic-free variant" → compare GRPO with TPO and FlowRL before choosing.
Quick Decision Points
- If the request says "RLHF" without extra qualifiers, use the root PPO path first.
- If the request says "group-relative" or "critic-free", compare GRPO next.
- If the request says "target policy optimization" or mentions replay buffers, compare TPO.
- If the request says "flow balance" or "reward distribution matching", compare FlowRL.
- If the request only needs importability or a minimal construction check, use the bundled smoke helper with
--construct-only.
Tiny Verification Checklist
A correct tiny check should:
- build a tiny PaLM and scalar RewardModel;
- create
prompt_token_idsas a padded integer tensor; - instantiate the PPO trainer with tiny hyperparameters;
- optionally run one bounded update and one generate call;
- keep
max_norm=Nonefor the smoke path; - avoid the source example's large defaults and extra dependency.
Related Files
references/api-reference.mdfor constructor signatures and method shapes.references/trainer-selection.mdfor PPO vs GRPO vs TPO vs FlowRL choice guidance.references/workflows.mdfor bounded recipes and smoke-script usage.references/troubleshooting.mdfor prompt assertions, replay-buffer side effects, and known source footguns.scripts/tiny_rlhf_smoke.pyfor the safe runnable PPO smoke check.
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).