Repository navigation
Allow score centering through compatible SGLang routers - #3732
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review always |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🔴
miles/utils/score_centering.py— Removing this check drops the only fail-fast guard for large score-centering candidate counts on an incompatible SGLang router, so misconfigured runs now silently corrupt training data instead of erroring at launch. If the installed router still caps chat top_logprobs at 20 (the doc at docs/examples/infra-features/score-centering.md now just asks users to "verify" this manually), append_score_centering_topk in miles/rollout/generate_utils/score_centering.py truncates entries to fewer than k with no length check in "selected" mode, and fills the rest of the row with -1/-inf, so score centering trains on silently incomplete candidate sets rather than failing loudly. …Why this was flagged
…Fix: keep an argument- or response-time check that rejects (or detects) fewer than score_centering_top_k candidates for chat/session rollouts, not just documentation advice.
Trigger: --use-session-server with default top_p/top_k, score_centering_top_k>20, use_miles_router=False, and an SGLang router build that still caps top_logprobs at 20 (pre sglang PR #41373). Previously validate_score_centering_args (miles/utils/score_centering.py, removed lines) raised ValueError at startup. Now nothing checks the router's actual capability. In miles/rollout/generate_utils/score_centering.py append_score_centering_topk, for sampling_logprobs_mode=='selected', 'entries = entries[:k]' just truncates; there is no check that len(entries)==k (unlike the support-mode branch, which does check 'len(entries) != len(token_ids)'). Rows short of k are padded with -1/-inf, so training silently proceeds on partial candidate sets with no error, only a documentation suggestion to manually verify before launch.
Verification: normal — acknowledged in diff. Base branch fail-fast guard removed at miles/utils/score_centering.py (deleted lines 76-84 in the diff) previously raised ValueError at startup for exactly: score_centering_top_k>20, rollout_top_p==1.0, rollout_top_k==-1, use_session_server, and not use_miles_router — because the SGLang Rust router "caps OpenAI top_logprobs at 20" (the removed message's own…
-
🟡
docs/examples/infra-features/score-centering.md— This doc is generated from examples/infra_features/score_centering/README.md (see the file's own header), but the PR hand-edits only the generated doc's later paragraph (line 68) and never touches the README source or the doc's own earlier line 27, which still says "For session-server rollouts using more than 20 candidates, also set --use-miles-router." Readers now see contradictory guidance in the same page, and the next run of scripts/tools/sync_example_docs.py (or its --check mode) will detect drift or silently overwrite the line-68 fix with the stale README text. Fix: edit examples/infra_features/score_centering/README.md (the actual source) and regenerate the doc via the sync script, updating both the "Enable it" mention and the later paragraph so they agree.Why this was flagged
A user reading only the "Enable it" section at docs/examples/infra-features/score-centering.md:27 still sees "more than 20 candidates, also set --use-miles-router", contradicting the updated line 68 saying a compatible SGLang router build now works without it. examples/infra_features/score_centering/README.md:24 and :66 (the declared single source of truth per its own header) were never updated at all, so the doc was hand-edited instead of the README, violating the sync script's invariant. Running scripts/tools/sync_example_docs.py --check (used in CI per the script's docstring) will fail or regenerate the doc from the stale README, reverting this PR's doc fix. No safeguard catches this because the diff only touches the generated file, not its source.
Verification: normal. The doc is a generated mirror: docs/examples/infra-features/score-centering.md:4 says "Generated from examples/infra_features/score_centering/README.md by scripts/tools/sync_example_docs.py. Edit that README, not this file." The PR hand-edits only the generated doc (paragraph now at line 69) and never touches the README — `git diff 2860923 HEAD --…
|
cc cmt This push will rewrite
Verification: fast tests show no new failures against the rebased baseline. |
3df660e to
358acf2
Compare
There was a problem hiding this comment.
I reviewed this PR and didn't find any confirmed bugs, but a human look is still worthwhile: the change removes the only launch-time guard against a known SGLang router limitation and there's an unaddressed comment on the PR since the latest push.
What was reviewed:
validate_score_centering_args: the check that raised when session rollouts requested >20top_logprobswithout--use-miles-routeris deleted outright, with no automated replacement (only doc guidance to "verify" manually before launch).append_rollout_topk(rollout_topk.py): if a router still truncates candidates to 20, missing slots are silently padded with-1/-infrather than raising, so a stale/older router build would degrade score-centering data quietly instead of failing fast at launch as before.- Updated test and docs match the new intended behavior and are internally consistent with the code change.
Extended reasoning...
The diff (single commit 358acf2) touches only miles/utils/score_centering.py, its contract test, and docs, removing a validation branch that previously forced session rollouts with >20 candidate top_logprobs onto a deprecated router, and replacing it with documentation asking users to manually confirm router compatibility; there is no auth/crypto/injection surface, but it does affect training-data integrity since the downstream candidate-collection code (rollout_topk.py) silently pads missing candidate slots rather than erroring, so a stale router could now degrade results without any runtime signal. Decisive factors for deferring rather than approving: the PR depends on an unmerged upstream SGLang PR for the new behavior to be safe, the removed check is not replaced by any automated runtime verification, and the timeline shows a third-party comment from guapisolo posted after the latest commit push with no subsequent commit or reply addressing it, which per policy should block approval.
|
cc cmt This push will rewrite Verification: on the stack tip, the rollout, session, sessions-v2, arguments, train-data and score-centering test suites pass (1023 passed, 17 skipped); 84/84 native and session request/response cases are byte-identical to the previous stack tip. |
358acf2 to
4653de3
Compare
Replaying the rule on the score-centering chain (#3622-#3732) showed gaps. Validators in miles/utils/<feature>.py and engine env in miles/ray/specs were not loaded, and the rule gave no answer for four recurring cases: - a field the caller controls that training also needs fixed (candidate count); - a field that is free in evaluation but fixed in training or behind a feature; - router capability limits and behavior-changing environment variables; - a check removed from startup, leaving per-sample aborts and silent padding. Load the rule for top-level miles/utils modules and engine specs. Answer the decision question per mode, and treat the run's requirement on a dual-role field as a launch constraint, where merging or overriding is a departure. Treat external limits and environment variables as launch constraints. Fail at startup when a violation is knowable then, otherwise fail visibly rather than as a per-sample warning, and confirm from the response that a value forced on a downstream component was honored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
cc cmt This push will rewrite
Verification on the stack tip |
4653de3 to
0741507
Compare
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. Because these two new commits remove a code-level guardrail (the ValueError that previously required --use-miles-router for session rollouts with more than 20 candidates) and replace it with documentation-only guidance that depends on an unmerged upstream SGLang router change, a human look is still worthwhile.
What was reviewed:
- The removed check in
miles/utils/score_centering.pyand its replacement prose in both doc copies (docs/examples/infra-features/score-centering.md,examples/infra_features/score_centering/README.md). - The updated contract test (
test_large_session_heads_can_use_sglang_router), which now asserts success even withuse_miles_router=False, matching the code change. - No remaining code-level check catches a mismatch between an older/default SGLang router (which caps
top_logprobsat 20) and a configured candidate count above 20; enforcement is now purely operator-driven per the docs.
Extended reasoning...
This is the first review pass over commits 503eae8 and 0741507 (pushed 2026-09-30), which is when the actual functional change landed: prior reviews of this PR (including mine) only saw the documentation groundwork, since the ValueError removal in miles/utils/score_centering.py did not exist in the tree until 503eae8. The change removes a code-enforced safety check tying score-centering session rollouts (>20 candidates) to --use-miles-router, replacing it with documentation asking the operator to manually verify SGLang router compatibility, and explicitly depends on an unmerged upstream SGLang PR (#41373). miles/utils/ is CODEOWNERS-covered by guapisolo (who left an inline comment on this exact doc line and commented again after the fix commits) and Shi-Dong (the author), so a domain reviewer is already engaged, but the removal of a runtime guardrail in favor of prose-only guidance is a design decision worth a human sign-off rather than automated approval.
|
codex cmt This history rewrite from |
e990eaf to
bdfdf7a
Compare
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 1 finding from earlier reviews is still open above.
Still open from earlier reviews (1):
- 🔴
miles/backends/training_utils/loss_hub/score_centering/estimator.py:61—Removing the finite-advantage and non-finite-log-prob guards lets a NaN/Inf advantage or log-prob silently turn score_c…
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
|
codex cmt This history rewrite from |
bdfdf7a to
af511b6
Compare
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 1 finding from earlier reviews is still open above.
Still open from earlier reviews (1):
- Unresolved: 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
|
codex cmt This history rewrite from |
af511b6 to
a198d09
Compare
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 1 finding from earlier reviews is still open above.
Still open from earlier reviews (1):
- Unresolved: 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
|
codex cmt This history rewrite from |
a198d09 to
8648624
Compare
|
codex cmt This history rewrite from |
8648624 to
d497ef7
Compare
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 1 finding from earlier reviews is still open above.
Still open from earlier reviews (1):
- Unresolved: 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
Record SGLANG_RETURN_ORIGINAL_LOGPROB=0 for both inference engines in generated values and rendered manifests. The launcher now enforces this setting for every loss, so the previous snapshots rejected the intended environment.
|
codex cmt [P2] Commit |
There was a problem hiding this comment.
Code review found no new issues
No new issues were found in this update; 1 finding from earlier reviews is still open above.
Still open from earlier reviews (1):
- Unresolved: 1 blocking on lines changed since (possibly already fixed).
If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.
Summary
Remove the score-centering argument check that forces session rollouts with more than 20 candidates onto the deprecated Miles router. A compatible SGLang router can now forward the larger chat request. Update the contract test and document the required router behavior.
This PR is stacked on the score-centering documentation PR and depends on SGLang #41373. Existing SGLang router builds that cap chat
top_logprobsat 20 still require a smaller candidate count; the documentation calls for a routed-request check before launch.Verification
git diff --checkpasses.torch. CI should run it on the PR branch.