[fix][train] Shut down DataLoader workers on exit - #1998
Open
bvolpato wants to merge 2 commits into
Open
Conversation
bvolpato
marked this pull request as ready for review
August 6, 2026 15:18
Contributor
There was a problem hiding this comment.
Code Review
This pull request ensures that trainer resources, specifically DataLoader worker processes, are properly shut down when training finishes or encounters an error. It introduces a shutdown_dataloader utility function to stop worker processes owned by a StatefulDataLoader, and integrates this into the shutdown methods of both SFTTrainer and Trainer. Additionally, finally blocks are added to the entry points to guarantee that shutdown is always executed. Feedback suggests improving the readability of the dataloader shutdown logic in SFTTrainer by separating the train and evaluation dataloader shutdown blocks instead of using an intermediate list.
bvolpato
force-pushed
the
bvolpato/shutdown-dataloader-workers
branch
from
August 6, 2026 17:44
f32b273 to
d74713a
Compare
bvolpato
force-pushed
the
bvolpato/shutdown-dataloader-workers
branch
from
August 7, 2026 00:21
d74713a to
1a025cd
Compare
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
StatefulDataLoaderworker processes normally stop when its iterator is exhausted or finalized. Training exceptions could bypass that cleanup because RL and SFT entrypoints did not shut down their train and evaluation dataloaders infinallyblocks.This change:
finallypath and closes every train/eval dataloaderThis covers process exits that unwind Python normally. Abrupt parent termination such as
SIGKILLremains outside this change's scope.Testing
pre-commit run --all-filesuv run --isolated --extra skyrl-train --extra dev pytest tests/train/ tests/backends/skyrl_train/ --ignore=tests/backends/skyrl_train/gpu -m "not vllm" -q1467 passed, 5 skipped, 5 deselectedCI dependency
Current
maincontains a Black formatting failure in an unrelated Tinker test. #2002 fixes that base-branch failure so this PR can rerun its gated CPU jobs.