Conversation
…r input queues) Summary: **Problem.** A non-continuous fused subprocess pipeline (`fuse_subprocess_stages=True`) could silently drop its earliest items under concurrent/instrumented startup. Root cause (confirmed by instrumenting `_run_sessions`): the non-continuous workers shared one work-stealing input queue, and the bridge `_feed` put `num_workers` anonymous `_SESSION_END` markers on it. A worker that drained its stream and reached `_SESSION_END` early could loop back and consume a *second* marker meant for a slower peer still holding un-flushed items. That peer never ended, `_collect` reached its `_DONE` count from the wrong workers and finished, and the peer's earliest items were discarded with no error or log. A startup READY-handshake (the original hypothesis) does **not** fix this — items in a bounded `mp.Queue` are never lost before draining; the loss is the double-`_SESSION_END` consumption on the shared queue. **Fix.** Give each non-continuous worker its own input queue (continuous mode already does this). The bridge round-robins items across the per-worker queues and sends exactly one `_SESSION_END` to each, so every worker ends exactly once and no worker can steal a peer's marker. `_broadcast_shutdown` now sends one `_POOL_SHUTDOWN` per worker queue. This unifies both modes and removes the shared marker entirely. **Files** - `_subprocess_pipeline_pool.py`: one input queue per worker in both modes; per-worker shutdown. - `_components/_subprocess_pipe.py`: `_feed` round-robins items + broadcasts one `_SESSION_END` per queue; `max_threads` updated; docstrings. - `subprocess_pipeline_fuse_test.py`: updated `FeedAbortTest` for the new `_feed` signature; added `StartupRaceFuseTest` regression test.
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D110118262. (Because this pull request was imported automatically, there will not be any future comments.) |
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. A non-continuous fused subprocess pipeline (
fuse_subprocess_stages=True) could silently drop its earliest items under concurrent/instrumented startup. Root cause (confirmed by instrumenting_run_sessions): the non-continuous workers shared one work-stealing input queue, and the bridge_feedputnum_workersanonymous_SESSION_ENDmarkers on it. A worker that drained its stream and reached_SESSION_ENDearly could loop back and consume a second marker meant for a slower peer still holding un-flushed items. That peer never ended,_collectreached its_DONEcount from the wrong workers and finished, and the peer's earliest items were discarded with no error or log.A startup READY-handshake (the original hypothesis) does not fix this — items in a bounded
mp.Queueare never lost before draining; the loss is the double-_SESSION_ENDconsumption on the shared queue.Fix. Give each non-continuous worker its own input queue (continuous mode already does this). The bridge round-robins items across the per-worker queues and sends exactly one
_SESSION_ENDto each, so every worker ends exactly once and no worker can steal a peer's marker._broadcast_shutdownnow sends one_POOL_SHUTDOWNper worker queue. This unifies both modes and removes the shared marker entirely.