[Fix] generate: propagate the disconnect 400 instead of returning null#4782
Open
AmirF194 wants to merge 1 commit into
Open
[Fix] generate: propagate the disconnect 400 instead of returning null#4782AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
Fixes InternLM#4781 _inner_call()'s disconnect branch returns create_error_response(400) from inside its async with block, but the call site never captures it and the nonlocal response it otherwise sets is only reachable on the normal completion path. Capture _inner_call()'s return value and return it directly when not None.
Author
|
Looked at the two failing jobs (pr_functions_test, unit_test). Both fail identically before any test runs: the turbomind CUDA extension build via cmake/ninja fails during |
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.
Motivation
Fixes #4781. The non-streaming
/generateendpoint aborts the session on client disconnect but discards the400response it computed, so the caller getsHTTP 200with anullbody instead. Same discard-the-inner-return shape as #4776/#4777, in the sibling/generateendpoint.Modification
generate's_inner_call()returns the disconnect error response from inside itsasync withblock, but the call site (await _inner_call()) never captured it, and thenonlocal responseit otherwise sets is only reachable on the non-disconnect path. Capture_inner_call()'s return value and return it directly when notNone, falling back toresponseonly on the normal completion path:Verification
Docker (
python:3.11-slim, CPU-only deps, no GPU), currentmain(9140d372). Addedtest_generate_disconnect_returns_client_disconnected_responsetotests/test_lmdeploy/serve/test_session_cleanup.py, mirroring the existingtest_completions_v1_disconnect_returns_client_disconnected_responsein the same file: a fakeAsyncEngine.generate()yields one item then blocks, and a fakeraw_request.is_disconnected()returnsTrue. Confirmed the test fails on unmodifiedmain(resultisNone) and passes with this change. The fulltests/test_lmdeploy/serve/test_session_cleanup.pyfile (10 tests) stays green, andpre-commit run --fileson both changed files passes.Not verified: the CUDA/GPU CI legs (no GPU on this machine) and the pre-existing failures in
tests/test_lmdeploy/serve/openai/responses/(unrelatedpydanticvalidation errors in the/responsesAPI, reproduced as already red on unmodifiedmain, untouched by this change).BC-breaking
None.
Checklist