Repository navigation
Conversation
matrix72c
marked this pull request as ready for review
November 9, 2026 09:46
matrix72c
force-pushed
the
fix/failed-batch-cleanup-upstream
branch
from
November 23, 2026 03:56
4ab838d to
9a917a7
Compare
This branch has not been deployed
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.
ProduceBatchResult impact: no fields, reward accounting, rollout statuses or producer counters are changed. This affects trainer failure unwinding after batch installation, not batch production; the primary failure is no longer delayed by queued cleanup on a blocked worker.
RoutedExperts impact: trainer/trace ownership remains unchanged. Controller-local batch object refs are cleared on every exit; pending workers may retain their installed batch until they can process release or are torn down. This is best-effort cleanup, not a claim of immediate remote release. Trace-owned routed-experts refs must not be freed by generic batch cleanup; LMDeploy→XTuner transfer is unchanged.
Ray concurrency impact: actor groups/dispatch remain unchanged. A synchronous worker blocked in a collective cannot execute its queued release RPC; failure cleanup now polls completed release refs without waiting. Successful cleanup still waits. This does not make a blocked actor recoverable or introduce a new concurrent control lane.
Root Cause
_loaded_batchalways waited for everyrelease_train_batchRPC, even while propagating a training/load failure. If a peer was blocked in a collective, its release RPC stayed queued and the controller waited for the long training timeout instead of surfacing the original exception.Fix
Keep awaited cleanup on successful exit. On failure, submit best-effort releases independently, log submission errors, poll with
ray.wait(..., timeout=0), and inspect only ready individual results with a zero timeout. Preserve the primary error and clear local batch refs on every path. Cover load submission/result failures, body failures, cleanup submission/result/wait failures, successful cleanup and trace-owned routed refs.Independent branch:
fix/failed-batch-cleanup-upstream, commit4ab838dde6032b1a881f0398aa7236287986f942, based directly ond841a3feeba4565054ad773fce5335a4734def88; no dependency on another new topic.Test Plan
Verified in
sandbox-rl-dev: Python 3.12.12, Torch 2.10.0+cu128, Ray 2.56.1, Transformers 5.17.0, FLA 0.5.2. Existing LMDeploy/opt/src/lmdeployremains at3f99ed1502ce3f7cf9747afc2138ff624e5d5457; candidate source is selected by per-command PYTHONPATH only.tests/rl/test_train_batch_contract.py::{TestFailedBatchCleanup,TestBatchLifecycle}: 18 passed, 0 skipped, exit 0.test_real_ray_blocked_synchronous_peerexecuted and passed, not skipped (JUnit duration 12.966s). It started its own local two-CPU runtime, blocked one synchronous actor, raised the primary error on its peer and confirmed cleanup used only zero-timeout polling. Finally it killed only its own actors and calledray.shutdown()for its own runtime; no globalray stopwas used.pre-commit run --all-filesexecuted: exit 1 from existing formatting/import-order/docformatter problems in sevenautotest/files. Hook-only edits were restored. Full mypy passed on 430 source files; other applicable hooks passed. Full hooks/CI are not green.Reproduction (container):
Outstanding verification is listed above.