[Feature] Add journey state cleanup to scheduler (PR #3/9)#11
Merged
Conversation
Extends the centralized cleanup method to handle journey tracing state alongside core span cleanup. Fixes memory leak on natural completion path. Changes: - Extend _end_core_span_and_cleanup() with decoupled cleanup logic - Cleanup #1: Core spans (always runs, independent of flags) - Cleanup #2: Journey state (only if journey tracing enabled) - Remove duplicate inline cleanup from finish_requests() - Add 4 tests verifying state cleanup on all termination paths Tests: - test_journey_state_created: Verify state initialization - test_journey_state_cleaned_on_finish: Explicit abort cleanup - test_journey_state_cleaned_on_completion: Natural completion cleanup - test_no_state_leak: No accumulation over 20 iterations All 95 tests passing (4 new + 91 existing). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates: - Mark PR #3 as COMPLETED in PR sequence summary - Update PR dependencies to show PR #3 complete - Add PR #3 to Implementation History section with full details - Document commit hash (f4cf790) and PR number (vllm-project#33126) - Record test results, code review process, and key achievements Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.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.
Overview
Extends the centralized cleanup method to handle journey tracing state alongside core span cleanup. Fixes memory leak on natural completion path.
Problem Solved
Memory leak identified: Journey state (
_first_token_emitted,_journey_prefill_hiwater) was not being cleaned up on natural completion path, only on explicit abort path.Solution
Centralized all cleanup in
_end_core_span_and_cleanup()with proper decoupling:_enable_journey_tracing=True)Changes
Production Code (
vllm/v1/core/sched/scheduler.py)_end_core_span_and_cleanup()with decoupled cleanup logicfinish_requests()Tests (
tests/v1/core/test_scheduler.py)Added 4 comprehensive tests:
test_journey_state_created- Verify state initializationtest_journey_state_cleaned_on_finish- Explicit abort cleanuptest_journey_state_cleaned_on_completion- Natural completion cleanup ⭐ Critical testtest_no_state_leak- No accumulation over 20 iterations (focused unit test)Test Results
✅ All 95 tests passing (4 new + 91 existing)
✅ No regressions
✅ Memory leak fixed
✅ Both termination paths verified
Key Design Principles
Part of Journey Tracing Initiative
This is PR #3 of 9 in the dual-stream journey tracing implementation plan:
Review Notes
🤖 Generated with Claude Code