[KV Offloading] Detect and clean up stalled transfer jobs - #46019
Closed
Alex-ai-future wants to merge 4 commits into
Closed
Alex-ai-future wants to merge 4 commits into
Alex-ai-future wants to merge 4 commits into
Conversation
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Alex-ai-future
force-pushed
the
feature/stalled-transfer
branch
from
June 22, 2026 03:42
c5d741f to
93ca166
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Alex-ai-future
force-pushed
the
feature/stalled-transfer
branch
from
June 22, 2026 08:08
93ca166 to
0988542
Compare
Alex-ai-future
force-pushed
the
feature/stalled-transfer
branch
2 times, most recently
from
June 29, 2026 06:06
aef4861 to
af8f340
Compare
Add stalled transfer detection to prevent cascading resource leaks when workers fail to report completion. Jobs exceeding 300s timeout are automatically cleaned up with success=False to discard potentially incomplete data. Key design decisions: - Stalled store jobs use success=False so blocks are not marked as stored and can be re-offloaded - _stalled_job_ids (dict) tracks remaining worker count for late report handling, avoiding KeyError in multi-worker scenarios - Stall check is throttled to 10s intervals 11 tests cover store/load cleanup, late worker reports, missing req_status edge cases, throttle verification, and reset_cache state clearing. Signed-off-by: Alex <alex.tech.lab@outlook.com>
Extract shared cleanup logic from _handle_stalled_job and update_connector_output into _complete_job. This removes ~45 lines of duplicated code and fixes a bug where _handle_stalled_job called on_request_finished a second time — request_finished() already notified the manager, so the duplicate call could cause KeyError or premature secondary tier cleanup in TieringManager. Added 5 tests covering both normal and stalled paths through _complete_job: _blocks_being_loaded cleanup, _req_status deletion, _block_id_to_pending_jobs cleanup, and on_request_finished non-invocation. Signed-off-by: Alex <alex.tech.lab@outlook.com>
Alex-ai-future
force-pushed
the
feature/stalled-transfer
branch
from
June 30, 2026 02:01
af8f340 to
1f92bea
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Alex <alex.tech.lab@outlook.com>
Signed-off-by: Alex <alex.tech.lab@outlook.com>
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
KV Offloading transfer jobs (store/load) can stall indefinitely when workers fail to report completion due to GPU hangs, CUDA driver bugs, or network failures. Without detection, stalled jobs cause cascading resource leaks:
_blocks_being_loadedpermanently occupied → other requests can't load those blocksref_cntstuck at -1 → GPU memory blocks can't be freed_req_statusgrows unbounded → memory leakreset_cache()→ full stop, discarding all offloaded blocksSolution
Add stalled transfer detection to
OffloadingConnectorScheduler. Jobs exceeding a 300s timeout are automatically cleaned up.Key design decisions
success=Falsefor stalled stores: Stalled store data may be incomplete. Usingsuccess=Falseensures the manager discards the data rather than marking it as stored. Other requests will re-offload from scratch instead of loading corrupt data._stalled_job_idsasdict[int, int]: After stalled cleanup, late worker reports may still arrive. The dict tracks remaining worker count per job so late reports decrement cleanly to 0, avoidingKeyErrorin multi-worker scenarios.Throttled stall check (10s interval): Avoids traversing all jobs on every
update_connector_outputcall._complete_jobshared cleanup path: Extracted from both normal and stalled completion paths to eliminate ~45 lines of code duplication. The shared method does not callon_request_finished— that isrequest_finished()'s responsibility, not the job cleanup path's.Testing
11 tests covering:
test_stalled_store_job_detectedcomplete_store(success=False)test_stalled_load_unblocks_being_loaded_blocks_being_loadedreleasedtest_stalled_job_skips_late_worker_reporttest_stalled_job_with_missing_req_statusreq_status=Noneedge casetest_stall_check_is_throttledtest_reset_cache_clears_stalled_job_statereset_cacheclears stalled statetest_stalled_job_no_double_on_request_finishedon_request_finishednot called from job cleanuptest_normal_load_completes_clears_blocks_being_loadedtest_normal_last_job_deletes_req_status_req_statusdeletiontest_complete_job_clears_block_id_to_pending_jobstest_stalled_load_does_not_pass_successcomplete_loadwithoutsuccesskwargFollow-ups
OffloadingSpec.logger.erroris emitted. A follow-up will add astalled_transfers_totalcounter for observability and alerting.Roadmap
Part of KV Offloading roadmap (#33689).