Skip to content

Refactor rollout.py by file decompositions - #899

Merged
fzyzcjy merged 54 commits into
mainfrom
rollout_ft/1
May 31, 2026
Merged

Refactor rollout.py by file decompositions#899
fzyzcjy merged 54 commits into
mainfrom
rollout_ft/1

Conversation

@fzyzcjy

@fzyzcjy fzyzcjy commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Mechanical Move

Transform script: https://gist.github.com/fzyzcjy/f479621f729158542dc22db3d17f2929

One-click verification

python3 <(curl -sL https://gist.githubusercontent.com/fzyzcjy/f479621f729158542dc22db3d17f2929/raw/transform_rollout_split.py)

fzyzcjy added 30 commits April 6, 2026 09:19
Requires mechanical move PRs to include a reproducible transform
script as a gist. The script is fully self-contained: creates a
worktree, replays the transformation with commits, diffs against
the PR, and reports pass/fail. PR description includes a one-liner
verification command.
Base automatically changed from rollout_ft/0 to main May 5, 2026 13:22
Note: rollout_ft/0 was already merged into main as PR #897 and deleted
from origin, so the cascade starts from main → rollout_ft/1.

Conflict 1: miles/ray/rollout.py (modify/delete)
  - HEAD (rollout_ft/1) deleted the file as part of a mechanical split:
    commit d3fc26e "mechanically move" splits the original 1298-line
    miles/ray/rollout.py into the directory miles/ray/rollout/{addr_allocator,
    metrics,observability,rollout_manager,rollout_server,router_manager,
    server_group}.py.
  - origin/main modified the file (4 commits since merge-base):
    a772c33 zero_std all_zero_ratio/all_one_ratio metrics (#1034)
    41615af weight staleness control for fully async rollout (#958)
    c198efa consistent hashing routing policy (#891)
    eaa36a2 heartbeat and id to session server (#866)

  Resolution: removed miles/ray/rollout.py (preserve mechanical split)
  and re-applied main's 7 hunks to the new directory files:

  - miles/ray/rollout/router_manager.py:
      + import uuid
      + router_args.policy = args.sglang_router_policy (in start_router)
      + args.session_server_instance_id = uuid.uuid4().hex (in
        start_session_server)
  - miles/ray/rollout/train_data_conversion.py:
      + train_data["weight_versions"] population (after multimodal block)
      + "weight_versions" added to per-DP-split key whitelist
  - miles/ray/rollout/metrics.py:
      + oldest_weight_version statistics + mixed_version_ratio in
        _compute_metrics_from_samples
      + zero_std/all_zero_percentage and all_one_percentage in
        _compute_zero_std_metrics

  Verified: all dependent symbols (Sample.weight_versions,
  Sample.oldest_weight_version, args.sglang_router_policy,
  args.session_server_instance_id) are already present in the merged
  tree from cleanly-merged peer files (miles/utils/types.py,
  miles/backends/sglang_utils/arguments.py, etc.).

  Verified: merge_diff_check.py shows the only "lost" deviations are
  PR #897 skill files (already in main) — no real loss.
@fzyzcjy

fzyzcjy commented May 5, 2026

Copy link
Copy Markdown
Collaborator Author

Heads up — I merged origin/main into this branch (and cascaded the result down rollout_ft/2 … /32) so the chain stays current with main.

The conflict (only one in the entire 32-branch cascade)

miles/ray/rollout.py was a modify/delete:

Resolution

Removed the orphaned miles/ray/rollout.py and re-applied each main-side hunk into the corresponding new module:

Hunk Target
import uuid miles/ray/rollout/router_manager.py
router_args.policy = args.sglang_router_policy (in start_router) miles/ray/rollout/router_manager.py
args.session_server_instance_id = uuid.uuid4().hex (in start_session_server) miles/ray/rollout/router_manager.py
train_data["weight_versions"] = … miles/ray/rollout/train_data_conversion.py
"weight_versions" in per-DP key whitelist miles/ray/rollout/train_data_conversion.py
oldest_versions / mixed_version_ratio block miles/ray/rollout/metrics.py
zero_std/all_zero_percentage & all_one_percentage rewrite miles/ray/rollout/metrics.py

Merge commit: 9a5e5b196. The full conflict + resolution detail is in the commit message body.

Verification

  • Reverse-diff check: every + line in git diff badc784f2 9a5e5b196 -- 'miles/ray/rollout/' corresponds 1:1 to a + line in main's pre-merge rollout.py patch — no missing or extra additions.
  • mechanical-refactor-verify one-click ran against the unchanged BASE_COMMIT=1fb7e93c / TARGET_COMMIT=badc784fPASS (this PR's mechanical split itself is unaffected; the verification compares against the pre-merge target which is still reachable).
  • Auxiliary files from the four main PRs (e.g. Sample.weight_versions / oldest_weight_version in miles/utils/types.py, --sglang-router-policy in miles/backends/sglang_utils/arguments.py, session_server_instance_id plumbing in miles/rollout/session/sessions.py and openai_endpoint_utils.py) all auto-merged cleanly and are present in the merged tree.
  • /2 → /32 in the cascade were all auto-merged with zero conflicts.

fzyzcjy added 4 commits May 7, 2026 22:58
miles/ray/rollout.py: modify/delete conflict. rollout_ft/1 split this file
into the miles/ray/rollout/ package; main (#1164 Bump sglang to v0.5.12) added
env var SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2 to ServerGroup. Re-applied main's
new env key to its moved location miles/ray/rollout/server_group.py and kept
the file deletion.
@fzyzcjy

fzyzcjy commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

Verified the mechanical refactor via the one-click transform script:

python3 <(curl -sL https://gist.githubusercontent.com/fzyzcjy/f479621f729158542dc22db3d17f2929/raw/transform_rollout_split.py)

Result: PASS: transform reproduces the commit exactly.

The script checks out BASE_COMMIT = 1fb7e93c, runs the transform (line-range split of miles/ray/rollout.py into the miles/ray/rollout/ package), runs pre-commit run --all-files, and diffs against TARGET_COMMIT = badc784f. The diff is empty, confirming this is a pure mechanical move with no semantic changes. ✅

@fzyzcjy
fzyzcjy merged commit 68a8f11 into main May 31, 2026
24 of 25 checks passed
@fzyzcjy
fzyzcjy deleted the rollout_ft/1 branch May 31, 2026 01:16
Frankstein73 pushed a commit to sii-avalanche/miles that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants