diff --git a/tests/reasoning/test_qwen3_reasoning_parser.py b/tests/reasoning/test_qwen3_reasoning_parser.py index 052b87cc91a..7fe57d3218c 100644 --- a/tests/reasoning/test_qwen3_reasoning_parser.py +++ b/tests/reasoning/test_qwen3_reasoning_parser.py @@ -11,28 +11,19 @@ parser_name = "qwen3" start_token = "" end_token = "" -REASONING_MODEL_NAME = "Qwen/Qwen3-0.6B" +REASONING_MODEL_NAMES = [ + "Qwen/Qwen3-0.6B", + "Qwen/Qwen3.5-397B-A17B", + "Qwen/Qwen3-4B-Thinking-2507", +] -@pytest.fixture(scope="module") -def qwen3_tokenizer(): - return AutoTokenizer.from_pretrained(REASONING_MODEL_NAME) +@pytest.fixture(scope="module", params=REASONING_MODEL_NAMES) +def qwen3_tokenizer(request): + return AutoTokenizer.from_pretrained(request.param) -# --- Qwen3 style: both and generated by model --- - -WITH_THINK = { - "output": "This is a reasoning sectionThis is the rest", - "reasoning": "This is a reasoning section", - "content": "This is the rest", -} -WITH_THINK_STREAM = { - "output": "This is a reasoning sectionThis is the rest", - "reasoning": "This is a reasoning section", - "content": "This is the rest", -} - -# --- Qwen3.5 style: in prompt, only in output --- +# --- in prompt, only in output (typical) --- WITHOUT_START_TOKEN = { "output": "This is a reasoning sectionThis is the rest", @@ -50,6 +41,19 @@ WITHOUT_START_TOKEN_COMPLETE_REASONING = { "content": None, } +# --- present in output (old template / edge case) --- + +WITH_THINK = { + "output": "This is a reasoning sectionThis is the rest", + "reasoning": "This is a reasoning section", + "content": "This is the rest", +} +WITH_THINK_STREAM = { + "output": "This is a reasoning sectionThis is the rest", + "reasoning": "This is a reasoning section", + "content": "This is the rest", +} + # --- No think tokens at all (thinking disabled) --- WITHOUT_THINK = { @@ -58,7 +62,7 @@ WITHOUT_THINK = { "content": "This is the rest", } # In streaming, the parser cannot distinguish "thinking disabled" from -# "Qwen3.5 reasoning in progress" when no think tokens have appeared yet. +# "reasoning in progress" when no think tokens have appeared yet. # It assumes reasoning. The serving layer handles the "thinking disabled" # case by checking prompt_is_reasoning_end_arr before calling the parser. WITHOUT_THINK_STREAM = { @@ -92,16 +96,6 @@ ONLY_OPEN_TAG_STREAM = { } TEST_CASES = [ - pytest.param( - False, - WITH_THINK, - id="with_think", - ), - pytest.param( - True, - WITH_THINK_STREAM, - id="with_think_stream", - ), pytest.param( False, WITHOUT_START_TOKEN, @@ -122,6 +116,16 @@ TEST_CASES = [ WITHOUT_START_TOKEN_COMPLETE_REASONING, id="without_start_token_complete_reasoning_stream", ), + pytest.param( + False, + WITH_THINK, + id="with_think", + ), + pytest.param( + True, + WITH_THINK_STREAM, + id="with_think_stream", + ), pytest.param( False, WITHOUT_THINK,