[deps] update to transformers 4.52 (#8125)
This commit is contained in:
@@ -135,8 +135,7 @@ def _check_plugin(
|
||||
expected_mm_inputs: dict[str, Any] = {},
|
||||
expected_no_mm_inputs: dict[str, Any] = {},
|
||||
) -> None:
|
||||
# test omni_messages
|
||||
if plugin.__class__.__name__ == "Qwen2OmniPlugin":
|
||||
if plugin.__class__.__name__ == "Qwen2OmniPlugin": # test omni_messages
|
||||
assert plugin.process_messages(OMNI_MESSAGES, IMAGES, NO_VIDEOS, AUDIOS, processor) == expected_mm_messages
|
||||
assert plugin.process_token_ids(INPUT_IDS, LABELS, IMAGES, NO_VIDEOS, AUDIOS, tokenizer, processor) == (
|
||||
expected_input_ids,
|
||||
@@ -146,8 +145,7 @@ def _check_plugin(
|
||||
plugin.get_mm_inputs(IMAGES, NO_VIDEOS, AUDIOS, IMGLENS, NO_VIDLENS, AUDLENS, BATCH_IDS, processor),
|
||||
expected_mm_inputs,
|
||||
)
|
||||
# test mm_messages
|
||||
if plugin.__class__.__name__ != "BasePlugin":
|
||||
elif plugin.__class__.__name__ != "BasePlugin": # test mm_messages
|
||||
assert plugin.process_messages(MM_MESSAGES, IMAGES, NO_VIDEOS, NO_AUDIOS, processor) == expected_mm_messages
|
||||
assert plugin.process_token_ids(INPUT_IDS, LABELS, IMAGES, NO_VIDEOS, NO_AUDIOS, tokenizer, processor) == (
|
||||
expected_input_ids,
|
||||
@@ -201,7 +199,7 @@ def test_gemma3_plugin():
|
||||
_check_plugin(**check_inputs)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Unknown error.")
|
||||
@pytest.mark.skipif(not is_transformers_version_greater_than("4.52.0"), reason="Requires transformers>=4.52.0")
|
||||
def test_internvl_plugin():
|
||||
image_seqlen = 256
|
||||
tokenizer_module = _load_tokenizer_module(model_name_or_path="OpenGVLab/InternVL3-1B-hf")
|
||||
@@ -219,7 +217,7 @@ def test_internvl_plugin():
|
||||
_check_plugin(**check_inputs)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Unknown error.")
|
||||
@pytest.mark.skipif(not is_transformers_version_greater_than("4.51.0"), reason="Requires transformers>=4.51.0")
|
||||
def test_llama4_plugin():
|
||||
tokenizer_module = _load_tokenizer_module(model_name_or_path=TINY_LLAMA4)
|
||||
processor = tokenizer_module["processor"]
|
||||
@@ -321,10 +319,9 @@ def test_pixtral_plugin():
|
||||
_check_plugin(**check_inputs)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="Unknown error.")
|
||||
@pytest.mark.skipif(not is_transformers_version_greater_than("4.52.0"), reason="Requires transformers>=4.52.0")
|
||||
def test_qwen2_omni_plugin():
|
||||
image_seqlen = 4
|
||||
audio_seqlen = 2
|
||||
image_seqlen, audio_seqlen = 4, 2
|
||||
tokenizer_module = _load_tokenizer_module(model_name_or_path="Qwen/Qwen2.5-Omni-7B")
|
||||
qwen2_omni_plugin = get_mm_plugin(
|
||||
name="qwen2_omni", audio_token="<|AUDIO|>", image_token="<|IMAGE|>", video_token="<|VIDEO|>"
|
||||
|
||||
@@ -127,20 +127,21 @@ def test_encode_multiturn(use_fast: bool):
|
||||
|
||||
@pytest.mark.parametrize("use_fast", [True, False])
|
||||
@pytest.mark.parametrize("cot_messages", [True, False])
|
||||
@pytest.mark.parametrize("enable_thinking", [True, False])
|
||||
@pytest.mark.parametrize("enable_thinking", [True, False, None])
|
||||
def test_reasoning_encode_oneturn(use_fast: bool, cot_messages: bool, enable_thinking: bool):
|
||||
messages = MESSAGES_WITH_THOUGHT if cot_messages else MESSAGES
|
||||
input_messages = MESSAGES_WITH_THOUGHT if cot_messages else MESSAGES
|
||||
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B", use_fast=use_fast)
|
||||
data_args = DataArguments(template="qwen3", enable_thinking=enable_thinking)
|
||||
template = get_template_and_fix_tokenizer(tokenizer, data_args)
|
||||
prompt_ids, answer_ids = template.encode_oneturn(tokenizer, messages)
|
||||
prompt_ids, answer_ids = template.encode_oneturn(tokenizer, input_messages)
|
||||
output_messages = MESSAGES if enable_thinking is False else input_messages
|
||||
prompt_str = (
|
||||
f"<|im_start|>user\n{messages[0]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
f"<|im_start|>user\n{output_messages[0]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
f"{MESSAGES[1]['content']}<|im_end|>\n"
|
||||
f"<|im_start|>user\n{messages[2]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
f"<|im_start|>user\n{output_messages[2]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
)
|
||||
answer_str = f"{messages[3]['content']}<|im_end|>\n"
|
||||
if not cot_messages:
|
||||
answer_str = f"{output_messages[3]['content']}<|im_end|>\n"
|
||||
if not cot_messages or enable_thinking is False:
|
||||
if enable_thinking:
|
||||
answer_str = "<think>\n\n</think>\n\n" + answer_str
|
||||
else:
|
||||
@@ -151,18 +152,19 @@ def test_reasoning_encode_oneturn(use_fast: bool, cot_messages: bool, enable_thi
|
||||
|
||||
@pytest.mark.parametrize("use_fast", [True, False])
|
||||
@pytest.mark.parametrize("cot_messages", [True, False])
|
||||
@pytest.mark.parametrize("enable_thinking", [True, False])
|
||||
@pytest.mark.parametrize("enable_thinking", [True, False, None])
|
||||
def test_reasoning_encode_multiturn(use_fast: bool, cot_messages: bool, enable_thinking: bool):
|
||||
messages = MESSAGES_WITH_THOUGHT if cot_messages else MESSAGES
|
||||
input_messages = MESSAGES_WITH_THOUGHT if cot_messages else MESSAGES
|
||||
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B", use_fast=use_fast)
|
||||
data_args = DataArguments(template="qwen3", enable_thinking=enable_thinking)
|
||||
template = get_template_and_fix_tokenizer(tokenizer, data_args)
|
||||
encoded_pairs = template.encode_multiturn(tokenizer, messages)
|
||||
prompt_str_1 = f"<|im_start|>user\n{messages[0]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
answer_str_1 = f"{messages[1]['content']}<|im_end|>\n"
|
||||
prompt_str_2 = f"<|im_start|>user\n{messages[2]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
answer_str_2 = f"{messages[3]['content']}<|im_end|>\n"
|
||||
if not cot_messages:
|
||||
encoded_pairs = template.encode_multiturn(tokenizer, input_messages)
|
||||
output_messages = MESSAGES if enable_thinking is False else input_messages
|
||||
prompt_str_1 = f"<|im_start|>user\n{output_messages[0]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
answer_str_1 = f"{output_messages[1]['content']}<|im_end|>\n"
|
||||
prompt_str_2 = f"<|im_start|>user\n{output_messages[2]['content']}<|im_end|>\n<|im_start|>assistant\n"
|
||||
answer_str_2 = f"{output_messages[3]['content']}<|im_end|>\n"
|
||||
if not cot_messages or enable_thinking is False:
|
||||
if enable_thinking:
|
||||
answer_str_1 = "<think>\n\n</think>\n\n" + answer_str_1
|
||||
answer_str_2 = "<think>\n\n</think>\n\n" + answer_str_2
|
||||
|
||||
Reference in New Issue
Block a user