Repository navigation
refactor(rl): derive use_rollout_sampling_mask once and thread it through - #2
Closed
guapisolo wants to merge 7 commits into
Conversation
…ough Sampling-support replay was switched on by re-evaluating sampling_support_replay_enabled(args) at every consumer: the Megatron and FSDP actor gates, the policy loss, the rollout request decision, the session-server config and wire allowlists, and argument validation. Each site re-derived the same predicate from rollout_top_p / rollout_top_k with getattr defaults, so an object lacking those fields silently evaluated to "replay off" and the session server had to duck-type three numeric fields. Derive the switch exactly once in miles_validate_args, right after the top-p / top-k range checks, as args.use_rollout_sampling_mask, and make the existing fail-closed block key on it. Thread that value the way use_rollout_routing_replay already flows: SessionServerConfig gains a use_rollout_sampling_mask bool filled from args, and every consumer reads the attribute directly. The activation condition, the per-request checks in should_return_sampling_mask, the actor-only gates, and the wire formats are unchanged; a missing attribute now raises instead of disabling replay. The helper is removed. Test fixtures set the attribute explicitly, and the derivation is covered at parse level in test_arguments. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
guapisolo
marked this pull request as draft
September 22, 2026 08:13
guapisolo
marked this pull request as ready for review
September 22, 2026 09:09
guapisolo
marked this pull request as draft
September 22, 2026 09:21
guapisolo
marked this pull request as ready for review
September 22, 2026 09:31
guapisolo
marked this pull request as draft
September 22, 2026 10:24
nanjiangwill
force-pushed
the
feat/top-p-sampling-mask-actor-logprobs
branch
from
September 22, 2026 18:04
9f68c61 to
ad27242
Compare
Author
|
your pr radixark#3354 already include some of this logic, will close this now |
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.
Summary
Derive
use_rollout_sampling_maskonce at validation and thread it to every replay consumer.Motivation
Sampling-support replay was switched on by calling
sampling_support_replay_enabled(args)at every consumer: the Megatron and FSDP actor gates,policy_loss_function,should_return_sampling_mask, the agentic hub,OpenAIEndpointTracer.create, both session cores,resolve_request_args_by_config, and argument validation. Each site re-derived the same predicate fromrollout_top_p/rollout_top_kthroughgetattrdefaults, so any object lacking those fields silently evaluated to "replay off", andSessionServerConfighad to duck-type three numeric fields to stand in forargs. The sibling R3 switch already follows a different pattern:use_rollout_routing_replayis one value onargs, copied intoSessionServerConfig, and read directly everywhere. Public API, the activation condition (rollout_top_p < 1orrollout_top_k > 0), the per-request checks, the actor-only gates, and the wire formats stay the same.Before / After
getattrfallbacks; after,miles_validate_argscomputesargs.use_rollout_sampling_maskright after the top-p / top-k range checks, the fail-closed block keys on it, and every consumer reads the attribute directly.miles/utils/sampling_mask.py(helper removed) intomiles/utils/arguments.py,SessionServerConfiggaineduse_rollout_sampling_mask: boolfilled fromargsnext touse_rollout_routing_replay, and the consumers inbackends/megatron_utils/{actor,model}.py,backends/fsdp_utils/actor.py,backends/training_utils/loss_hub/losses.py,rollout/generate_utils/{sampling_mask,openai_endpoint_utils}.py,rollout/generate_hub/agentic_tool_call.py,rollout/session/{core,request_args}.py, plusrollout/session/v2/core.pyswitched to direct attribute reads.SessionServerConfigstill carriesrollout_top_p/rollout_top_k/rollout_temperaturebecause they fill missing request parameters.AttributeErrorinstead of silently disabling replay.Behavior Preservation
tests/fast/utils/test_arguments.py::test_sampling_support_arguments_fail_closed: every launch-time rejection (top-p without top-k, prefill recompute, missing Miles router, KL / OPD) still fires from the same flags.tests/fast/rollout/generate_utils/test_sampling_mask.py: request-level validation plus thereturn_sampling_maskpayload decision are unchanged for bounded, unbounded, or evaluation requests.tests/fast/backends/test_fsdp_train.py,tests/fast/backends/megatron_utils/test_shared_ppo_lifecycle.py: actor-only scoring gates still exclude the ref / teacher prefixes.tests/fast/rollout/session/: session config, request-arg resolution, sample assembly, and wire allowlists behave as before (mask field only when replay is on).Verification
tests/fast/utils/test_arguments.py::test_bounded_rollout_sampling_derives_use_rollout_sampling_mask(new): the attribute is absent after parsing, then equals the derived value after validation for bounded and unbounded launches.tests/fast/rollout,tests/fast/backends,tests/fast/router,tests/fast/utils,tests/fast/ray/rollout,tests/fast/exampleson a CPU-only image (tests/fast/tinkerexcluded,tinkermodule absent): 8418 passed, 0 failed, 39 skipped, 7 xfailed.tests/fast/router/test_sglang_anthropic_conversion.pyfails at import on a missingSGLANG_SOURCE_ROOTvariable, whiletests/fast/utils/test_http_utils.py::TestWaitTcpReadyAsync::test_it_returns_once_the_port_acceptshangs on the box (deselected) and touches no modified code.black24.3.0,isort5.13.2,ruff0.14.7: clean on all changed files.Review Focus
miles/utils/arguments.py/miles_validate_args: the derived attribute is set before the fail-closed block, beforeargsis serialized to Ray actors, and beforecompute_session_server_configruns.miles/rollout/session/config.py:SessionServerConfigis a strict pydantic model, so every constructor in tests, benchmarks, or e2e helpers must now passuse_rollout_sampling_mask.getattrdefaults on purpose, so a custom rollout function that builds its ownargsobject must set the attribute.🤖 Generated with Claude Code