Repository navigation
Preserve and validate score-centering candidate distributions - #3622
Conversation
|
@claude review always |
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.
24fb3aa to
ba1b261
Compare
ba1b261 to
e70c84f
Compare
There was a problem hiding this comment.
Beyond the reported findings, I also checked whether validate_score_centering_args (the new config-contract validator with all its MIS/TIS/advantage-estimator checks) is invoked anywhere outside its own test file — it isn't; nothing in miles/utils/arguments.py or elsewhere calls it, so it's currently dead code pending a later stack PR.
Extended reasoning...
Reviewed miles/utils/score_centering.py and miles/rollout/generate_utils/score_centering.py, which add candidate-distribution capture/validation for the new score-centering feature; no injection/auth/data-exposure surface is touched, this is internal RL training plumbing. Confirmed both ruled-out items from the candidate list: (1) validate_score_centering_sample's cross-check of sampled-token vs. candidate logprobs only fires when rollout_sampling_mask is set, since the match array is empty otherwise; (2) validate_score_centering_args is unreferenced outside tests. Two prior reviews on earlier pushes already said no issues; this run's diff is one incremental commit consistent with the PR's stated "part 2/6, wiring comes later" scope, and no third-party changes-requested review is outstanding.
e70c84f to
4d6bf6c
Compare
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline finding, I checked two other candidate issues from this run's hunt: (1) --loss-type choices in miles/utils/arguments.py still omit "score_centering", so the feature can't be enabled via CLI yet — consistent with this being an intermediate stack PR (2/6), not a bug in this diff; (2) the multi-turn merge path in sample_utils.py/score_centering.py for mismatched candidate fields across turns raises a clear ValueError (merge_score_centering_field) rather than crashing unguarded, so that's deliberate fail-fast behavior, not a silent defect.
Extended reasoning...
This diff adds a score-centering feature (candidate-probability capture, validation, serialization, and merge/conversion wiring) across rollout generation, sample types, and training-batch conversion — no auth/crypto/data-exposure surface, but plenty of validation logic where edge cases matter. A prior-run-confirmed bug (unhandled TypeError on zero-generated-tokens in support/filtered sampling mode) is being posted as an inline finding, so this warrants defer rather than approve. I independently verified that finding by re-reading append_score_centering_topk, and separately re-checked two of the four ruled-out candidates (CLI reachability gating and cross-turn merge error handling), confirming both are intentional/non-issues rather than additional bugs.
4d6bf6c to
e83351e
Compare
e83351e to
704485c
Compare
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
This automated review ran and found the wiring gap noted inline (validate_score_centering_args is never invoked from miles_validate_args, so the new config-contract checks don't run at startup); given that, a human look at this PR is still worthwhile before merging.
Extended reasoning...
The diff adds a score-centering rollout/training pipeline touching sampling request construction, sample serialization, and training-batch conversion; no auth/crypto/injection surface is involved. The decisive fact is the confirmed inline finding that the new validate_score_centering_args function is dead code in production (only called from tests), so misconfigured score-centering runs (e.g. via --custom-config-path bypassing argparse choices) would not fail fast as intended.
704485c to
e40d41f
Compare
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. My earlier findings — the TypeError on zero-new-token completions in support mode, and the missing validate_score_centering_args startup call — are both fixed in the latest commits (b566b61, e40d41f). Because this is a large, numerically intricate change to core rollout/training-data plumbing, a human look would still be worthwhile.
What was reviewed: sample merge/truncate/reset handling of the new top-k fields, wire encode/decode, and validate_score_centering_sample's shape/duplicate/probability-mass checks. Also checked: a trained token missing from its recorded top-k candidates (score_centering.py:176) — the row's consistency check is vacuously skipped rather than a false accept in the expected case; and enabling score_centering without a populated rollout path (train_data_conversion.py:124) — raises a clear ValueError rather than crashing.
Extended reasoning...
The diff adds a new score-centering training path spanning sample lifecycle (merge/trim/reset), wire serialization, CLI-arg validation, and training-batch conversion; it touches no auth/crypto/data-exposure surface. Both prior inline findings from earlier runs (empty-completion TypeError at score_centering.py, and the unwired validate_score_centering_args) were fixed by the new commits b566b61 and e40d41f pushed since the last review. No new findings were reported this run, and two additional candidate issues (silent accept of an out-of-top-k sampled token, and a missing-candidates crash path) were examined and ruled out as non-issues. Given the size and numeric-correctness intricacy of the remaining code (probability-mass invariants, support-set matching) and that this is one part of a larger stacked series, a human review is still warranted.
e40d41f to
637bce7
Compare
There was a problem hiding this comment.
I reviewed this PR and found no bugs. The two issues I flagged in earlier reviews of this PR — the zero-new-token crash in append_score_centering_topk and validate_score_centering_args never being invoked from miles_validate_args — have both been fixed by later commits (7748886, 637bce7), each with a regression test. Because this is a large, numerically intricate feature spanning rollout generation, session serialization, and training-batch conversion, a human look would still be worthwhile.
What was reviewed: candidate-array validation/support-membership logic in score_centering.py, the new field merge/pad/reset handling in sample_utils.py and types.py, and the new CLI args/startup validation wiring in arguments.py. Checked whether validate_score_centering_sample's final check could miss an unrecorded sampled token, and whether merge_samples crashes (rather than truncating) when a turn lacks score-centering candidates — both are pre-existing/design-level observations, not new regressions.
Extended reasoning...
The diff adds a large score-centering feature: new modules for config validation and per-token candidate-distribution capture, threaded through Sample dataclass fields, session codec, rollout merge/pad logic, and the training-batch conversion pipeline. No injection/auth/data-exposure surface; the sensitive surface is numerical correctness of probability/validation logic feeding training data. Both previously-flagged inline concerns (crash on zero-token completions; missing startup validation call) were fixed with real code changes plus tests since the last review, and this run found no new issues, but the change's size and complexity (six-part stack, heavy vectorized validation) still warrant a human pass rather than an autonomous approval.
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline finding, I checked whether the new score-centering request/response wiring (configure_score_centering_request, append_score_centering_topk in miles/rollout/generate_utils/score_centering.py) is invoked from any production rollout path (sglang_rollout.py's generate, generate_endpoint_utils.py, session merge.py) — it isn't yet, which would make train_data_conversion.py's validate_score_centering_sample raise on a real rollout, but I'm not flagging that as a bug here since this PR is explicitly stack part 2/6 (plumbing only) and later parts likely add those call sites.
Extended reasoning...
This PR wires score-centering candidate-distribution plumbing through Sample, codec, sampling-mask, and train-data conversion across 12 files; the confirmed inline finding is a dead validation check (use_sampling_support_replay is forced before validate_score_centering_args runs, so its filtered-rollout guard can never trigger). I additionally confirmed configure_score_centering_request/append_score_centering_topk are never called from any real generate() call site, meaning a real rollout with --loss-type score_centering would currently fail sample validation, but treated this as intended given the PR's explicit stack-part-2/6, dependency-ordered-merge framing rather than a standalone bug.
There was a problem hiding this comment.
I reviewed this PR again and found no new bugs. The commits pushed since my last review (2886558 through aa584fc) address all three issues I previously flagged inline: the empty-completion TypeError in append_score_centering_topk is now guarded on n, validate_score_centering_args is now wired into miles_validate_args, and the vacuous use_sampling_support_replay check was removed in favor of the already-derived flag. Given this is a substantial new RL loss feature with several interacting validation paths, a human look is still worthwhile before merging.
Extended reasoning...
The diff adds score-centering candidate-distribution plumbing across sample types, session codec, sampling-mask logic, argument validation, and training-batch conversion; the security-relevant surface is limited to input validation (no auth/crypto/injection). All three previously-raised inline findings (a TypeError-vs-ValueError edge case, a missing validator call site, and a dead-code check) are now fixed by the latest commits, and no third-party CHANGES_REQUESTED review is outstanding. The change remains large and touches training correctness, which is why I'm deferring rather than approving outright.
Follow the #3622 split in test_score_centering_filtered.py: import the helpers from miles.rollout.generate_utils.rollout_topk_logprobs under their new names, and select --rollout-sampling-logprobs-mode support where the tests build filtered score-centering args, since score centering now requires the mode that matches its sampling. The unnormalized-support and top-p-without-top-k cases go: the rollout args and replay own those checks after #3622 trimmed the candidate helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
codex cmt This history rewrite from |
82d7a8f to
4980d27
Compare
|
codex cmt This history rewrite from |
4980d27 to
ae02067
Compare
|
codex cmt This history rewrite from |
ae02067 to
1ee4332
Compare
|
codex cmt This history rewrite from |
1ee4332 to
8741fcb
Compare
Follow the #3622 split: the native payload builders and response paths use configure_rollout_topk_logprobs_request / append_rollout_topk_logprobs / pad_rollout_topk_logprobs from miles.rollout.generate_utils.rollout_topk_logprobs, and size the candidates with --rollout-top-logprobs-num instead of score_centering_top_k(args). The tests and the manual live probe move to the new args; the filtered native test selects --rollout-sampling-logprobs-mode support explicitly. The response-side gates are unchanged: they still tell a training request that asked for candidates from an evaluation request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SessionServerConfig carries rollout_top_logprobs_num and rollout_sampling_logprobs_mode instead of loss_type and score_centering_top_k, so the session server applies the same rollout args as native generation. prepare_chat_request still calls configure_rollout_topk_logprobs_request after the session sampling defaults and model rules, because the helper's own sampling defaults must not pre-empt them; merge.py sizes the recorded candidates with args.rollout_top_logprobs_num. The two fields are read from args directly; rollout_temperature stays in the config unchanged, and the older-args test now covers only its default. Tests, fixtures and the overhead bench move to the new fields, and the sampling-rule test matches the "Rollout top-k logprobs" wording from #3622; an injected top_p is now rejected by the replay request check, which owns top-p/top-k bounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow the #3622 split in test_score_centering_filtered.py: import the helpers from miles.rollout.generate_utils.rollout_topk_logprobs under their new names, and select --rollout-sampling-logprobs-mode support where the tests build filtered score-centering args, since score centering now requires the mode that matches its sampling. The unnormalized-support and top-p-without-top-k cases go: the rollout args and replay own those checks after #3622 trimmed the candidate helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Carry rollout candidate IDs and probabilities through samples, session serialization, trimming, reset, and training-batch conversion. Validate shapes, padding, uniqueness, and sampled-token agreement.
Accept unfiltered sampling and bounded top-p/top-k sampling in the configuration contract. For filtered requests, ask SGLang for post-filter probabilities over the complete realized support. Reject support larger than the saved candidate count or missing probability metadata. This uses the API from SGLang #40932, incorporated into
sglang-milesby #41047. The minimum source revision onsglang-milesis merge commitae04cb14046896b6d453758c5769d639deedd353, or a descendant containing it. Session/OpenAI transport also needs a compatible router build forwardingsampling_logprobs_mode; the corresponding router change #41373 is still open, so this engine revision is not a released-router guarantee.Stack part 2/6. Depends on #3621. Merge in dependency order.
Validation: 80 focused tests passed and 6 GPU-dependent cases skipped on this intermediate branch.