feat: support server-side PPO loss on Tinker-compatible backends - #629
Merged
pan-x-c merged 2 commits intoSep 30, 2026
Merged
Conversation
Collaborator
Author
|
/unittest-module-trainer |
Collaborator
Author
|
/unittest-pattern-ServerLoss |
unittest: Run #1884
🎉 All tests passed!Github Test Reporter by CTRF 💚 |
Collaborator
Author
|
/unittest-all |
nashjojo
force-pushed
the
codex/tinker-server-ppo-loss
branch
from
September 29, 2026 10:16
5f488a2 to
260fe43
Compare
Collaborator
Author
|
/unittest-all |
unittest: Run #1889
🎉 All tests passed!Github Test Reporter by CTRF 💚 |
pan-x-c
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Tinker custom-loss path transfers model logprobs to the client, evaluates the objective, then sends gradients back for another forward/backward request. Add an opt-in
model.tinker.server_loss_fn: trinity_ppopath for compatible servers to calculate dual-clipped PPO with optional K2 KL in one server-side forward/backward operation. The default client callback remains unchanged.The client aligns old logprobs, advantages and optional reference logprobs with shifted target tokens, preserves masked response tokens in the weights, and supplies the full optimizer-batch datum count to every SDK request. This preserves the per-datum masked-token mean when the SDK splits a batch. One optimizer step follows the complete batch; a failed server result does not trigger it. Zero KL skips reference-logprob requests, and diagnostics use additive token counts rather than averaging request means.
Unsupported objectives fail during trainer initialization: asymmetric clipping, sequence masking, fallback policy gradient, non-K2 KL, adaptive KL, entropy loss, alternative reductions, or microbatch rescaling. The server-loss parameters come from the configured algorithm; there is no separate override that can silently change the objective.
Dependencies and scope
trinity_ppoextension; TuFT support is proposed in agentscope-ai/TuFT#163. This is not a built-in loss on all Tinker services.Validation
8dc6a68). With KL 0 and 0.001, unequal sequence lengths, a fully masked datum, and uneven 1+2 request splits, loss and gradients matched Trinity's PPO/K2 implementation; maximum gradient difference was zero.git diff --checkpassed for the changed code.vllm.inputs.MultiModalDataDicttype alias imported by current main, so the test process supplied that type-only alias before collection.Checklist