Repository navigation
feat(ppo): support non-colocated generation - #3262
Conversation
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
…ed-clean Signed-off-by: bg51717 <[email protected]>
|
/ok to test 4fe31a4 |
Signed-off-by: bg51717 <[email protected]>
|
/ok to test 5910124 |
|
/ok to test 5910124 |
Signed-off-by: bg51717 <[email protected]>
…ed-clean Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
|
/ok to test 6767e6d |
yuki-97
left a comment
There was a problem hiding this comment.
Overall LGTM on the non-colocated surface after auditing offload/onload sequencing and node allocation against the GRPO reference on main.
Offload/onload — parity verified. All 3 refit sites (ppo.py:1163-1170 initial-val, 1227-1269 loop, 1574-1587 val-in-loop) correctly add an explicit if not colocated_inference: policy.offload_to_cpu() after refit_policy_generation returns, mirroring the fact that the shared refit helper intentionally skips policy offload in non-colocated mode (weights transfer via NCCL, vLLM stays resident). Value ↔ policy time-share the training GPUs via explicit finish_training / finish_inference boundaries — no double-resident window. Checkpoint save at ppo.py:1796-1831 does the same policy → save → offload → value → save dance.
Node allocation — parity verified. RayVirtualCluster construction, all 4 assert guards (train-gpus-per-node > 0, inference_nodes explicit for multi-node, gpus_per_node full-node for multi-node, nodes_per_instance divisibility), and cluster.segment_size handling all mirror grpo.py on main, with two intentional PPO-specific divergences:
max_colocated_worker_groups=2ontrain_cluster— necessary since PPO hosts bothpolicyandvalue_modelworker groups on the same train cluster (GRPO has policy only, uses=1).required_nodesfor the segment_size check usestrain_nodeswhen shared-node non-colocated (single node hosts both train and inference),train_nodes + inference_nodesotherwise. Stricter-correct than GRPO's always-sum for the rare single-node + segment_size combo.
Comments below are the remaining findings.
Signed-off-by: bg51717 <[email protected]>
8689b05 to
e4e64e8
Compare
|
/ok to test e4e64e8 |
Signed-off-by: bg51717 <[email protected]>
|
/ok to test 08c888c |
Signed-off-by: bg51717 <[email protected]>
|
/ok to test fbcfbe3 |
yuki-97
left a comment
There was a problem hiding this comment.
overall LGTM, just one small comment. @terrykong could you take a review as well?
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
|
/ok to test 6f176b3 |
terrykong
left a comment
There was a problem hiding this comment.
Re-review at 6f176b3b4. Six agents (RL/domain, bug-finder, test, design, comment, adversarial) went over this.
All 7 prior review threads are fixed. I verified each against the code at head rather than on the replies — including that the four assert branches each hit their intended branch (not a sibling), and that the topology port-back in 6f176b3b4 is faithful to grpo.py:816-878. Replies are on the individual threads.
No correctness bug was found in the new non-colocated path. Three agents diffed it line-by-line against grpo.py: the GPU-resource arithmetic (including the reward-model x node-count boundaries), the policy/value offload coordination, and the token_mask * sample_mask change all came back clean — every mask consumer is consistent, with no sibling left on the old mask, and PPO is actually more consistent here than GRPO, which still uses bare token_loss_mask for its own response_advantages metric. The required_nodes shared-node refinement is a genuine improvement over grpo's version. Nice work; the five comments below are all low-severity.
Everything here is static analysis only. pre-commit and pytest could not be run (the lockfile supports Linux x86_64/aarch64 only and this review ran on macOS), so nothing below is a passing result and the suggested tests are syntax-checked, not executed.
Twelve candidate findings were dropped during the adversarial pass, several of which are worth naming so they don't get re-raised later:
- A proposed
.get()change to theseq_logprob_error_thresholdread — PPO's bare subscript is convention-correct for a required TypedDict field, and.get(key, default)is the forbidden hidden-default pattern. - A suggestion to delete the unreachable trtllm/sglang branches in the topology block — those were added at a reviewer's explicit request in the previous round.
- A
gpu_memory_utilization: 0.4concern, withdrawn once the right peer group was checked: 0.4 is what every 1.5B PPO recipe uses, colocated included, so the new recipes follow house style rather than diverging from it. - The new
RuntimeErroron a fully-masked batch: it does change PPO's prior behavior (previously a benign zero-gradient no-op —masked_meandivides bysum(mask) + 1e-8, so there was never a NaN), but firing it needs all 1024 samples in a step truncated simultaneously, and the 40-step runs on both recipes are empirical evidence it doesn't happen. Fail-loud there is a defensible choice.
Two design observations belong with the already-tracked #3464 rather than this PR, and I'll add them there: the non-colocated layout arithmetic is inlined in setup(), which is why ~450 of the 1043 new test lines are Ray mock scaffolding (a pure plan_noncolocated_layout(...) helper would make those validation tests ~3 lines each); and the post-refit policy.offload_to_cpu() is now a caller obligation duplicated at three sites.
Generated by Claude Code
Signed-off-by: bg51717 <[email protected]>
Signed-off-by: bg51717 <[email protected]>
|
/ok to test f298610 |
Signed-off-by: bg51717 <[email protected]>
…KL pairing
Sync PPO and sync GRPO both guard skip_reference_policy_logprobs_calculation
against a non-zero reference_policy_kl_penalty with a bare, message-less
assert master_config.loss_fn.reference_policy_kl_penalty == 0
python -O removes it entirely, so the run proceeds to train against a KL term
whose reference logprobs were never computed. Even with asserts enabled, a
message-less one says nothing about which two settings conflict.
async_ppo_train already does this as an if + ValueError. This is the same
defect class yuki-97 raised on NVIDIA-NeMo#3262 ("assert backend == 'vllm' gets stripped
under python -O"), which was converted there but left in these two siblings.
Both now use the async form, verbatim, so the three read alike.
Tests run under python -O as well as normally, which is what separates this
from a cosmetic change: with the assert restored, both modes fail.
Signed-off-by: Tianyi Zhang <[email protected]>
Signed-off-by: Tianyi Zhang <[email protected]>
What does this PR do ?
Adds synchronous non-colocated PPO, with the policy and value model sharing a training cluster while vLLM generation runs on a separate inference cluster.
Design
The main changes are:
RayVirtualClusters whenpolicy.generation.colocated.enabled=false.cluster.segment_sizeis configured.Related correctness fixes
token_mask * sample_mask, matching GRPO, so samples removed byoverlong_filteringdo not affect GAE or advantage normalization. When truncated samples are present, this changes the previous PPO advantage numerics even if the optional sequence-level threshold is disabled.env_namefrom every dict or list entry underdata.train,data.validation, anddata.default. Previously, list-shaped dataset configs were skipped, which could prevent PPO from reserving resources for an active reward-model environment.Usage
Set
policy.generation.colocated.enabled=falseand reserve resources for vLLM generation:For a single-node run,
gpus_per_nodereserves that many GPUs for generation on the node. For a multi-node run, generation uses complete nodes, so setnum_nodesand keepgpus_per_nodeequal tocluster.gpus_per_node.Before your PR is "Ready for review"
Pre checks:
Test
The following test matrix passed:
0.8408, validation accuracy0.7500, median token probability error1.0076, and median maximum sequence probability error1.0261.0.8467, validation accuracy0.7383, median token probability error1.0087, and median maximum sequence probability error1.0270.