Remove interactive v2#4730
Draft
lvhan028 wants to merge 18 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the “interactive v2” stateful inference contract by eliminating sequence_start, sequence_end, and step plumbing across TurboMind, AsyncEngine, pipeline chat, and chat-template/VL prompt rendering, shifting multi-turn behavior to fully stateless “render full history each request”.
Changes:
- Remove stateful session/continuation arguments from core inference entrypoints (AsyncEngine/TurboMind) and prompt-rendering APIs (chat templates + VL models).
- Update
Pipeline.chat()to build OpenAI-style message history and send full context each turn, rather than relying on backend KV continuation state. - Add/adjust tests to enforce the stateless signature/behavior contract and session cleanup semantics.
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_lmdeploy/turbomind/test_turbomind_stateless_wrapper.py | Adds a signature-level contract test for TurboMind stateless streaming. |
| tests/test_lmdeploy/test_vl/test_qwen3vl_processor.py | Updates VL processor tests to stop passing sequence_start. |
| tests/test_lmdeploy/test_vl/test_nonhf_chat_template.py | Updates non-HF template tests to match stateless prompt rendering. |
| tests/test_lmdeploy/test_vl/test_hf_chat_template.py | Adds coverage for forwarding tools/template kwargs and CogVLM image-token placement; removes sequence_start usage. |
| tests/test_lmdeploy/test_pipeline.py | Adds tests for stateless chat history handling and response clearing/history recording. |
| tests/test_lmdeploy/test_model.py | Updates chat-template tests for stateless prompting and adds regression coverage for assistant-prefix behavior. |
| tests/test_lmdeploy/serve/test_stateless_inference_contract.py | Adds contract tests for AsyncEngine stateless signature, removed-kwarg rejection, and safe-run cleanup. |
| tests/test_lmdeploy/serve/test_session_cleanup.py | Extends session cleanup tests for stateless sessions and async-close reuse semantics. |
| tests/test_lmdeploy/serve/parsers/test_qwen3_5_parser.py | Updates parser fixture comments/expectations for Qwen3.5 streams. |
| tests/test_lmdeploy/serve/parsers/test_glm47_parser.py | Updates GLM-4.7 parser test to reflect prompt-prefilled reasoning behavior. |
| tests/test_lmdeploy/serve/anthropic/test_endpoints.py | Updates fake template signature to match new stateless template API. |
| tests/test_lmdeploy/pytorch/engine/test_engine_instance_cleanup.py | Adds tests ensuring PyTorch engine instances end/cleanup sessions correctly in stateless mode. |
| lmdeploy/vl/model/qwen2.py | Removes sequence_start from VL prompt/to_* paths; forwards tools/template kwargs to rendering. |
| lmdeploy/vl/model/molmo.py | Removes sequence_start from unsupported engine interfaces for consistency. |
| lmdeploy/vl/model/minicpmv.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_* methods. |
| lmdeploy/vl/model/llava_hf.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_* methods. |
| lmdeploy/vl/model/llama4.py | Removes sequence_start and makes BOS handling stateless in tokenization. |
| lmdeploy/vl/model/internvl.py | Removes sequence_start from prompt/to_* paths while preserving tool forwarding. |
| lmdeploy/vl/model/glm4_v.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_pytorch. |
| lmdeploy/vl/model/gemma3_vl.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_* methods. |
| lmdeploy/vl/model/deepseek.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_* methods. |
| lmdeploy/vl/model/deepseek_vl2.py | Removes sequence_start; forwards tools/template kwargs in prompt rendering and to_* methods. |
| lmdeploy/vl/model/cogvlm.py | Refactors CogVLM prompt building to keep image tokens positioned correctly without interactive-state flags. |
| lmdeploy/vl/model/base.py | Removes sequence_start from shared VL prompt/tokenization helpers; adds tools forwarding to messages2prompt. |
| lmdeploy/vl/engine.py | Removes sequence_start passthrough in VL encoder wrappers. |
| lmdeploy/turbomind/turbomind.py | Drops stateful args from async_stream_infer and forces stateless session params. |
| lmdeploy/serve/processors/multimodal.py | Removes sequence_start handling; always encodes with BOS for stateless requests and forwards tools/kwargs. |
| lmdeploy/serve/openai/responses/serving.py | Removes stateful generate args from OpenAI Responses serving path. |
| lmdeploy/serve/openai/api_server.py | Removes stateful generate args from OpenAI endpoints and updates encode preprocessing behavior. |
| lmdeploy/serve/openai/api_client.py | Updates encode parameter docs to reflect stateless behavior. |
| lmdeploy/serve/managers/session_manager.py | Removes Session.step and refactors close/reset semantics for stateless sessions. |
| lmdeploy/serve/core/async_engine.py | Removes stateful args from generate, rejects removed kwargs explicitly, and simplifies session lifecycle cleanup. |
| lmdeploy/serve/anthropic/endpoints/messages.py | Removes stateful generate args from Anthropic endpoint. |
| lmdeploy/serve/anthropic/adapter.py | Removes stateful template rendering call in token counting. |
| lmdeploy/pytorch/engine/mp_engine/base.py | Ensures MP engine session state is cleaned up on cancel/finish in stateless mode. |
| lmdeploy/pytorch/engine/engine_instance.py | Ensures PyTorch backend sessions are ended in finally for stateless lifecycle correctness. |
| lmdeploy/pipeline.py | Implements stateless history->messages conversion and removes step-based continuation logic. |
| lmdeploy/model.py | Removes interactive-state flags from chat templates and HF template rendering logic. |
| benchmark/profile_throughput.py | Removes interactive-mode session end/sequence args from benchmark driver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
383
to
387
| async def _get_multimodal_prompt_input(self, | ||
| messages: list[dict], | ||
| do_preprocess: bool, | ||
| sequence_start: bool, | ||
| adapter_name: str, | ||
| tools: list[object] | None = None, |
Comment on lines
352
to
356
| async def _get_text_prompt_input(self, | ||
| prompt: str | list[dict], | ||
| do_preprocess: bool, | ||
| sequence_start: bool, | ||
| adapter_name: str, | ||
| tools: list[object] | None = None, |
lvhan028
force-pushed
the
remove-interactive-v2
branch
from
July 17, 2026 11:30
a2b52ab to
8404077
Compare
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.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Please describe the motivation of this PR and the goal you want to achieve through this PR.
Modification
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward-compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
Checklist