-
Notifications
You must be signed in to change notification settings - Fork 332
Add text-only mode support for Qwen 3.5 model builder #2157
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
Merged
+109
−8
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
495e4c4
Add qwen3.5 text model type
apsonawane 74e7a97
Merge branch 'main' into asonawane/qwen_text
apsonawane 5fe0d8e
Address comments and add test
apsonawane 0e7c68e
Merge branch 'main' into asonawane/qwen_text
apsonawane c14354a
Address copilot comments
apsonawane 40a253d
Address comments
apsonawane faf35a4
Merge branch 'main' into asonawane/qwen_text
apsonawane 83b2bb9
Update extensions commit
apsonawane 2d08052
Potential fix for pull request finding 'CodeQL / Unused import'
apsonawane bce9aa9
move position_ids logic to override
apsonawane edd7d54
Merge branch 'asonawane/qwen_text' of https://github.com/microsoft/on…
apsonawane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License | ||
|
|
||
| """ | ||
| Unit tests for Qwen3.5 text-only (LLM) model. | ||
|
|
||
| Tests cover model loading, tokenizer creation, generator creation, and | ||
| basic text generation for the text-only variant of Qwen3.5 (model type | ||
| "qwen3_5_text"), which uses 2D position_ids and hybrid KV/recurrent state. | ||
|
|
||
| Usage: | ||
| pytest test_qwen35_text_only.py --test_models=test/test_models | ||
| """ | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import onnxruntime_genai as og | ||
| import pytest | ||
|
|
||
| MODEL_DIR = "qwen35-text-only" | ||
|
|
||
|
|
||
| def _model_path(test_data_path): | ||
| return os.fspath(Path(test_data_path) / MODEL_DIR) | ||
|
|
||
|
|
||
| def _skip_if_missing(test_data_path): | ||
| path = _model_path(test_data_path) | ||
| if not os.path.exists(path): | ||
| pytest.skip(f"{MODEL_DIR} test model not found at {path}") | ||
| return path | ||
|
|
||
|
|
||
| def test_qwen35_text_only_model_loads(test_data_path): | ||
| """Test that a Qwen3.5 text-only model loads successfully.""" | ||
| model_path = _skip_if_missing(test_data_path) | ||
| model = og.Model(model_path) | ||
| assert model is not None | ||
|
|
||
|
|
||
| def test_qwen35_text_only_generator_creates(test_data_path): | ||
| """Test that a Generator can be created for the text-only model. | ||
| Validates that hybrid state auto-discovery works with qwen3_5_text type.""" | ||
| model_path = _skip_if_missing(test_data_path) | ||
| model = og.Model(model_path) | ||
| params = og.GeneratorParams(model) | ||
| params.set_search_options(max_length=10) | ||
| generator = og.Generator(model, params) | ||
| assert generator is not None | ||
|
|
||
|
|
||
| def test_qwen35_text_only_accepts_input_ids(test_data_path): | ||
| """Test that the text-only model accepts input_ids (not inputs_embeds). | ||
| The dummy model uses Identity pass-through which doesn't support KV cache | ||
| shape changes, so we only validate that the generator constructs and | ||
| is ready to accept tokens.""" | ||
| model_path = _skip_if_missing(test_data_path) | ||
| model = og.Model(model_path) | ||
| params = og.GeneratorParams(model) | ||
| params.set_search_options(max_length=5) | ||
|
|
||
| # The model should accept raw token IDs (input_ids, not inputs_embeds) | ||
| generator = og.Generator(model, params) | ||
| assert generator is not None |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.