[WIP] fix: correct callback event firing in streaming loops - #736
Draft
bhimrazy wants to merge 1 commit into
Draft
[WIP] fix: correct callback event firing in streaming loops#736bhimrazy wants to merge 1 commit into
bhimrazy wants to merge 1 commit into
Conversation
The sync streaming loop fired AFTER_PREDICT twice and never fired the decode-request events. Separately, all three streaming paths fired the "after" events before the stream was consumed - since predict and encode_response return generators, no work has happened at that point, so AFTER_PREDICT always measured ~0s. Add the decode-request events and move AFTER_PREDICT / AFTER_ENCODE_RESPONSE to after the stream is exhausted. Fixes Lightning-AI#735
bhimrazy
requested review from
Abdul-0x4A,
andyland,
dmitsf,
ethanwharris,
justusschock,
k223kim and
tchaton
as code owners
August 26, 2026 18:10
bhimrazy
marked this pull request as draft
August 26, 2026 18:12
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #736 +/- ##
===================================
- Coverage 85% 85% -0%
===================================
Files 39 39
Lines 3285 3286 +1
===================================
- Hits 2781 2780 -1
- Misses 504 506 +2 🚀 New features to boost your workflow:
|
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.
What does this PR do?
Fixes #735.
The sync streaming loop fired
AFTER_PREDICTtwice and never fired the decode-request events.While fixing it, a second issue surfaced:
predictandencode_responsereturn generators, so no work has happened when they return — it all runs interleaved as the stream is consumed. Firing the "after" events at that point meantPredictionTimeLoggerreportedPrediction took 0.00 secondson every streaming request.So all three streaming paths now fire:
each exactly once.
Note: the async and
BatchedStreamingLoopchanges go beyond the reported issue — same bug, but they shift event timing for existing users.