-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] fix vl gradio, use pipeline api and remove interactive chat #3136
Conversation
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) |
@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()) |
lmdeploy/lmdeploy/pytorch/engine/engine.py Line 236 in 188f069
|
It works on gradio! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…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)
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