Skip to content
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

Refactor VLM module for minicpm and molmo #2794

Merged
merged 43 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c40a8ae
qwen2-vl
lvhan028 Nov 17, 2024
e24b303
internvl
lvhan028 Nov 18, 2024
dcc454b
qwen2
lvhan028 Nov 18, 2024
8407d57
get image_tokens_per_patch for internvl2
lvhan028 Nov 18, 2024
ba1ae5a
merge refactor-vl
lvhan028 Nov 18, 2024
676c23f
deepseek-vl
lvhan028 Nov 18, 2024
e7319c0
cogvlm
lvhan028 Nov 18, 2024
cc9a4eb
glm4v
lvhan028 Nov 18, 2024
b416a26
update internvl
lvhan028 Nov 18, 2024
086eed8
internvl_llava
lvhan028 Nov 18, 2024
da86bbe
llava
lvhan028 Nov 19, 2024
98dde7b
glm4v
lvhan028 Nov 19, 2024
5a06515
upate internvl
lvhan028 Nov 19, 2024
4daf4e3
cogvlm
lvhan028 Nov 19, 2024
a45ddf4
deepseek
lvhan028 Nov 19, 2024
2b8b053
llava_hf
lvhan028 Nov 19, 2024
9cff378
rollback llava, internvl-llava
lvhan028 Nov 19, 2024
09ebaf6
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 19, 2024
1132018
refactor qwen
lvhan028 Nov 19, 2024
32a5433
update internvl
lvhan028 Nov 19, 2024
61ad4a6
update llava_hf
lvhan028 Nov 19, 2024
e034874
update qwen2-vl
lvhan028 Nov 19, 2024
e6c8a1a
llava_next
lvhan028 Nov 20, 2024
a9493eb
update llava_next
lvhan028 Nov 20, 2024
8212da5
update llava
lvhan028 Nov 20, 2024
1a87001
update llava
lvhan028 Nov 20, 2024
5f47aa6
update llava
lvhan028 Nov 20, 2024
d958a1e
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 20, 2024
32cd694
qwen2
lvhan028 Nov 20, 2024
b9c8581
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 20, 2024
c7e8c53
fix internvl
lvhan028 Nov 20, 2024
e8eae01
phi3-vision
lvhan028 Nov 20, 2024
e3a08ca
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 20, 2024
36bffac
refactor yi-vl
lvhan028 Nov 20, 2024
8b0f049
refactor mllama
lvhan028 Nov 20, 2024
13ee140
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 20, 2024
d494e18
molmo
lvhan028 Nov 21, 2024
6c70392
minicpm 2.5
lvhan028 Nov 21, 2024
78ddc76
update minicpm2.6
lvhan028 Nov 22, 2024
ddc77a5
update
lvhan028 Nov 22, 2024
3937904
Merge branch 'refactor-vl' into refactor-vl-for-tm
lvhan028 Nov 22, 2024
a3e95de
fix
lvhan028 Nov 22, 2024
0823a5c
fix molmo
lvhan028 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lmdeploy/vl/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ async def async_infer(self, messages: List[Dict]) -> List[Dict]:
assert isinstance(messages, List)
assert all(isinstance(item, Dict) for item in messages)
for i, message in enumerate(messages):
preprocess = message.pop('preprocess', None)
preprocess = message['preprocess']
if preprocess:
result = self.model.forward(preprocess)
messages[i].update(preprocess=result)
messages[i].update(forward=result)
return messages

async def wrap_for_pytorch(self, messages: List[Dict], chat_template,
Expand All @@ -275,5 +275,17 @@ async def wrap_for_pytorch(self, messages: List[Dict], chat_template,

async def wrap_for_turbomind(self, messages: List[Dict], chat_template,
tokenizer, sequence_start) -> Dict:
"""
Args:
messages (List[Dict]): a list of message, which is supposed to be
the output of `async_infer`
Returns:
a dict which will be passed to pytorch engine_instance's forward.
The dict is like the following:
Dict(
'prompt': 'the prompt after applying chat template'
'input_ids': [],

"""
return self.model.to_turbomind(messages, chat_template, tokenizer,
sequence_start)
4 changes: 2 additions & 2 deletions lmdeploy/vl/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def to_turbomind_aux(cls, messages, prompt, IMAGE_TOKEN, tokenizer,
sequence_start):
# collect image features from messages
features = [
message.pop('preprocess') for message in messages
if 'preprocess' in message.keys()
message.pop('forward') for message in messages
if 'forward' in message.keys()
]
# flatten the list
features = list(itertools.chain(*features))
Expand Down
Loading
Loading