Skip to content

fix(rlix): always resume generation after finalize#14

Merged
TianyeGGBond merged 1 commit into
rlops:zhenyu/miles-mvp-e2efrom
TianyeGGBond:tianye/m11-finalize-always-continue
May 18, 2026
Merged

fix(rlix): always resume generation after finalize#14
TianyeGGBond merged 1 commit into
rlops:zhenyu/miles-mvp-e2efrom
TianyeGGBond:tianye/m11-finalize-always-continue

Conversation

@TianyeGGBond

Copy link
Copy Markdown
Collaborator

What

Ensures MilesModelUpdateService._run_atomic_unit() always attempts continue_generation after the finalize_weight_update fan-out, even when finalize_weight_update raises.

Why

Before this change, the sequence was:

pause_generation(mode="retract")
await _ray_get(finalize_refs)
continue_generation()

If finalize_weight_update failed or timed out, control left _run_atomic_unit() before continue_generation() ran. Any engine paused by the pre-finalize pause_generation(mode="retract") could remain paused indefinitely, causing the next generate path to hang in a misleading way.

Correctness Semantics

This change does not treat a failed weight update as successful.

continue_generation here is only cleanup for the SGLang scheduler pause state. If finalize_weight_update fails:

  • the original exception still propagates
  • set_weight_version is not called
  • the pipeline does not publish the failed version
  • the driver/training loop still fails fast and can run cleanup

So the failure remains explicit, but we avoid leaking the engine in a paused control-plane state.

Before

finalize_refs = [h.finalize_weight_update.remote() for h in handles.values()]
await _ray_get(finalize_refs)

try:
    cont_refs = [h.continue_generation.remote() for h in handles.values()]
    await _ray_get(cont_refs)
except Exception as exc:
    logger.warning(...)

After

finalize_refs = [h.finalize_weight_update.remote() for h in handles.values()]
try:
    await _ray_get(finalize_refs)
finally:
    try:
        cont_refs = [h.continue_generation.remote() for h in handles.values()]
        await _ray_get(cont_refs)
    except Exception as exc:
        logger.warning(...)

Tests

Added a lightweight regression test that checks the cleanup contract structurally, without Ray or GPU dependencies:

python -m pytest -q tests/test_miles_model_update_service_cleanup.py

Result:

1 passed in 0.03s

Scope

Exception-safety hardening only. Happy-path ordering and version publishing behavior are unchanged.

@howard989

Copy link
Copy Markdown
Collaborator

lgtm

@TianyeGGBond
TianyeGGBond merged commit 8727394 into rlops:zhenyu/miles-mvp-e2e May 18, 2026
zhenyulincs added a commit that referenced this pull request May 24, 2026
…+ release-on-sync-failure)

Doc-audit gap closed. Tianye's `#14`
(`tianye/m11-finalize-always-continue`, merged 2026-05-18 as `8727394`)
was never reflected in the implementation guide. PR #14 contains two
commits, both pure `try/finally` cleanup-path fixes paralleling Phase 1
(R04-F1) and Phase 7 (F3+F4):

- `0302437 fix(rlix): always resume generation after finalize` —
  `rlix/pipeline/miles_model_update_service.py:307-323`. Wraps
  `_ray_get(finalize_refs)` in try/finally so `continue_generation`
  always fires; prevents indefinite engine pause after finalize raises.
  Test: `tests/test_miles_model_update_service_cleanup.py` (51 LoC).

- `a8460a9 fix(rlix): release train GPUs after sync failure` —
  `rlix/pipeline/miles_pipeline.py:674-697`. Wraps
  `sync_base_weights_to_active` in try/finally so
  `_notify_release_cluster_gpus` always fires; prevents scheduler-ledger
  leak of actor_train allocation when sync raises after train actor
  offloaded. R11-F1 invariant preserved.
  Test: `tests/test_miles_pipeline_after_training_cleanup.py` (39 LoC).

Promoted to §3.6 (top-level) per Codex recommendation — PR #14 is a
distinct merged PR, not an M11.3 open issue, so it belongs as a §3.5
sibling rather than nested below "Open M11.3 follow-ups".

Append-only verified: diff <HEAD:doc> <working> | grep '^<' = 0 lines.
Codex APPROVE_WITH_NOTES (0 BLOCKERS) pre-commit:
- Zero deletions confirmed.
- Diff content of `0302437` + `a8460a9` confirmed accurate.
- Test files confirmed on disk.
- Per-row markers not needed: sub-section-level marker suffices.
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