Skip to content

Commit bf4d631

Browse files
committed
add model registration and other boilerplate
1 parent ca927c7 commit bf4d631

File tree

9 files changed

+31
-1
lines changed

9 files changed

+31
-1
lines changed

python/mlc_llm/conversation_template/qwen2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,17 @@
1818
stop_token_ids=[151643, 151645],
1919
)
2020
)
21+
22+
ConvTemplateRegistry.register_conv_template(
23+
Conversation(
24+
name="qwen2-vl",
25+
system_template=f"<|im_start|>system\n{MessagePlaceholders.SYSTEM.value}<|im_end|>\n",
26+
system_message="You are a helpful assistant.",
27+
roles={"user": "<|im_start|>user", "assistant": "<|im_start|>assistant"},
28+
seps=["<|im_end|>\n"],
29+
role_content_sep="\n",
30+
role_empty_sep="\n",
31+
stop_str=["<|endoftext|>", "<|im_end|>"],
32+
stop_token_ids=[151643, 151645],
33+
)
34+
)

python/mlc_llm/interface/gen_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
267267
"chatml",
268268
"chatml_nosystem",
269269
"qwen2",
270+
"qwen2-vl",
270271
"open_hermes_mistral",
271272
"neural_hermes_mistral",
272273
"llama_default",

python/mlc_llm/model/model.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .qwen import qwen_loader, qwen_model, qwen_quantization
3939
from .qwen2 import qwen2_loader, qwen2_model, qwen2_quantization
4040
from .qwen2_moe import qwen2_moe_loader, qwen2_moe_model, qwen2_moe_quantization
41+
from .qwen2_vl import qwen2_vl_loader, qwen2_vl_model, qwen2_vl_quantization
4142
from .rwkv5 import rwkv5_loader, rwkv5_model, rwkv5_quantization
4243
from .rwkv6 import rwkv6_loader, rwkv6_model, rwkv6_quantization
4344
from .stable_lm import stablelm_loader, stablelm_model, stablelm_quantization
@@ -299,6 +300,20 @@ class Model:
299300
"ft-quant": qwen2_moe_quantization.ft_quant,
300301
},
301302
),
303+
"qwen2_vl": Model(
304+
name="qwen2_vl",
305+
model=qwen2_vl_model.QWen2VLLMHeadModel,
306+
config=qwen2_vl_model.QWen2VLConfig,
307+
source={
308+
"huggingface-torch": qwen2_vl_loader.huggingface,
309+
"huggingface-safetensor": qwen2_vl_loader.huggingface,
310+
},
311+
quantize={
312+
"no-quant": qwen2_vl_quantization.no_quant,
313+
"group-quant": qwen2_vl_quantization.group_quant,
314+
"ft-quant": qwen2_vl_quantization.ft_quant,
315+
},
316+
),
302317
"deepseek_v2": Model(
303318
name="deepseek_v2",
304319
model=deepseek_v2_model.DeepseekV2ForCausalLM,

python/mlc_llm/model/qwen2_vl/__init__.py

Whitespace-only changes.

python/mlc_llm/model/qwen2_vl/qwen2_vl_image.py

Whitespace-only changes.

python/mlc_llm/model/qwen2_vl/qwen2_vl_loader.py

Whitespace-only changes.

python/mlc_llm/model/qwen2_vl/qwen2_vl_model.py

Whitespace-only changes.

python/mlc_llm/model/qwen2_vl/qwen2_vl_quantization.py

Whitespace-only changes.

python/mlc_llm/model/vision/image_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_output_image_size(image: Tensor):
8484
assert False, "not supported resize parameter"
8585

8686
(new_h, new_w) = get_output_image_size(image)
87-
out = op.interpolate(image, (new_h, new_w), data_layout="NCHW", mode="linear")
87+
out = op.interpolate(image, (new_h, new_w), data_layout="NCHW", mode="bicubic")
8888
return out
8989

9090
# pylint: disable=too-many-arguments,too-many-locals

0 commit comments

Comments
 (0)