fix: enforce training timeout for silent subprocesses - #193
Open
Tyagiquamar wants to merge 1 commit into
Open
Conversation
The training timeout was only checked after an output line arrived, so a subprocess that stayed quiet past the deadline (data loading, verbose=0 training, hung DDP rendezvous) blocked run_training forever inside readline(). Replace the per-line check with a watchdog timer that kills the process at the deadline regardless of output flow.
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.
Problem
LocalProcessRunner.run_trainingcan hang forever even though atimeoutis provided. The deadline was only checked after an output line arrived from the training subprocess, so any subprocess that stays silent past the deadline blocks the main thread insidereadline()indefinitely.Realistic triggers: loading a large dataset before the first log line, Keras/PyTorch training with progress output disabled, or a hung torchrun rendezvous during DDP startup.
Root cause
In
plexe/execution/training/local_runner.py, the timeout was enforced inside the output-pump loop:If the child produces no lines, control never returns to the check:
readline()waits on the pipe forever and the documented contract (timeout: Max training time (seconds)) is not upheld.Fix
Replace the per-line check with a
threading.Timerwatchdog that kills the process at the deadline regardless of output flow. The watchdog raises the samesubprocess.TimeoutExpiredas before, so callers still get the identicalTrainingError("Training timed out after N seconds").Testing
tests/unit/execution/training/test_local_runner_timeout.pysimulates a silent child via mockedPopen. On main it hangs (no result within 15 s fortimeout=3); with this fix it fails fast (~3 s) withTrainingError: Training timed out after 3 seconds.python -m pytest tests/unit -q -n 2: 107 passed, 15 skipped (main baseline on same machine: 106 passed, 15 skipped)ruff checkandblack --check: clean on changed files