[fix] fix vl gradio, use pipeline api and remove interactive chat - #3136
Merged
Conversation
Collaborator
|
The Pytorch engine assumes user would break the generate loop by themself. If the automatic break is required, you can change lmdeploy/lmdeploy/pytorch/engine/engine.py Line 268 in e91ccf0 to def _on_stop_session(self, reqs: Request, **kwargs):
"""on stop session callback."""
for req in reqs:
session_id = req.data['session_id']
resp = req.data.get('response', True)
resp_type = ResponseType.SESSION_NOT_EXIST
if session_id in self.scheduler.sessions:
self.scheduler.stop_session(session_id)
session = self.scheduler.sessions[session_id]
for seq in session.sequences.values():
resp: Response = getattr(seq, 'resp', None)
if resp is not None:
resp.type = ResponseType.FINISH
self.req_manager.response(resp)
resp_type = ResponseType.SUCCESS
if resp:
self._response(req.resp, resp_type) |
Collaborator
Author
|
@grimoire The following code is easier to reproduce import asyncio
import numpy as np
from lmdeploy import pipeline, PytorchEngineConfig
import random
messages = '写一篇高考作文'
pipe = pipeline('/mnt/141/vicuna-7b-v1.5/', backend_config=PytorchEngineConfig())
async def inference(session_id):
async for out in pipe.generate(messages=messages, session_id=session_id):
pass
print('inference done')
async def timer(event):
dur = 1 + random.random() * 2
await asyncio.sleep(dur)
event.set()
async def stop(event, session_id):
await event.wait()
await pipe.stop_session(session_id=session_id)
print('stop session')
async def main():
session_id = 0
event = asyncio.Event()
while True:
await asyncio.gather(inference(session_id), timer(event), stop(event, session_id))
print(f'session={session_id} done\n')
session_id += 1
event.clear()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main()) |
Collaborator
|
lmdeploy/lmdeploy/pytorch/engine/engine.py Line 236 in 188f069 |
Collaborator
|
It works on gradio! |
grimoire
approved these changes
Feb 17, 2025
tastelikefeet
added a commit
to tastelikefeet/lmdeploy
that referenced
this pull request
Feb 25, 2025
…oad_state_dict * commit 'f6f7a5d707e3ccbc69af10babf1c9afcaf72a402': fix deepseekv2 has no attribute use_mla error (InternLM#3188) fix blocked fp8 moe (InternLM#3181) [Feature] support deepseek-vl2 for pytorch engine (InternLM#3149) make turbomind support gpu embedding inputs (InternLM#3177) fix temperature=0 (InternLM#3176) Update qwen2.py (InternLM#3174) Fix tool call prompt for InternLM and Qwen (InternLM#3156) Use pad_token_id as image_token_id for vl models (InternLM#3158) fix default temperature value (InternLM#3166) fix min length penalty (InternLM#3150) update cuda runtime package dependencies (InternLM#3142) fix typing (InternLM#3153) support deepseekv2 for maca backend. (InternLM#2918) fix the issue that stop_token may be less than defined in model.py (InternLM#3148) [fix] fix vl gradio, use pipeline api and remove interactive chat (InternLM#3136) [feature] add dlinfer w8a8 support. (InternLM#2988) Use aiohttp inside proxy server && add --disable-cache-status argument (InternLM#3020) support eos_token list in turbomind (InternLM#3044)
oliveagle
pushed a commit
to oliveagle/lmdeploy
that referenced
this pull request
May 22, 2026
…ternLM#3136) * use pipeline api and remove interactive chat * support cancel request with pytorch backend
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
Use pipeline api and remove interactive chat to support vl models like qwen2-vl
Currently with pytoch backend, it seems that the generator cannot be interrupted when sending a stop request. @grimoire