Repository navigation
fix: --config mode model_type and token ID propagation - #152
Merged
Merged
Conversation
Add model_type, bos_token_id, and eos_token_id fields to ArchitectureConfig and populate them in from_transformers(). Previously, write_ort_genai_config() with hf_model_id=None (i.e. --config mode) would produce model.type='unknown' in genai_config.json because ArchitectureConfig had no model_type field, and the bos/eos token IDs would be absent because they were only fetched via AutoConfig.from_pretrained(). Fixes: - Issue 1: ArchitectureConfig now stores model_type; the else-branch in write_ort_genai_config reads it to resolve the ORT-GenAI type. - Issue 2: ArchitectureConfig stores bos_token_id/eos_token_id from the HF config; the else-branch reads them for genai_config.json. pad_token_id already present in BaseModelConfig is also forwarded. Tests added for both code paths in auto_export_test.py and a new from_transformers test in _configs_test.py. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
justinchuby
commented
Apr 10, 2026
Performance Comparison
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes ORT-GenAI export behavior when building from a local --config directory by ensuring the model type and special token IDs are preserved on ArchitectureConfig and then propagated into genai_config.json without requiring a HuggingFace Hub lookup.
Changes:
- Add
model_type,bos_token_id, andeos_token_idfields toArchitectureConfigand populate them inArchitectureConfig.from_transformers(). - Update ORT-GenAI config generation to fall back to
ArchitectureConfigformodel_typeand BOS/EOS/PAD token IDs whenhf_model_id=None(config-mode). - Add unit tests covering config-mode propagation for
model.typeand special token IDs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/mobius/integrations/ort_genai/auto_export.py | Reads model type + token IDs from ArchitectureConfig when hf_model_id is not provided. |
| src/mobius/integrations/ort_genai/auto_export_test.py | Adds unit tests validating config-mode model type and token ID propagation into genai_config.json. |
| src/mobius/_configs.py | Extends ArchitectureConfig with model_type/BOS/EOS fields and populates them from HF configs. |
| src/mobius/_configs_test.py | Adds a unit test verifying the new fields are preserved by from_transformers(). |
- Expand comment on _pad < 0 guard to mention DEFAULT_INT (-42) and why negative IDs are treated as unset - Add test_config_mode_eos_token_id_as_list to cover list[int] eos (e.g. Gemma multi-stop token case) Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
- Warning now says 'missing, None, or not mapped' and logs raw_type (%r) so users can diagnose which value caused the fallback to 'unknown' - Update hf_model_id param docstring to describe the new config-field fallback (bos/eos/pad read from ArchitectureConfig when hf_model_id is None) instead of the old 'defaults to None' description Addresses Copilot review comments on PR #152. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes model.type=unknown and missing bos/eos token IDs when using local --config path. Addresses Issues 1 and 2 from Edge LLM evaluation.
Problem
When building with
--config <local_dir>instead of a HuggingFace model ID:Issue 1:
genai_config.jsonalways contained"type": "unknown"becauseArchitectureConfighad nomodel_typefield — it was read from the HF config but never stored.Issue 2:
bos_token_id/eos_token_idwere absent fromgenai_config.jsonbecause token IDs were only fetched viaAutoConfig.from_pretrained(), which is skipped whenhf_model_id=None.Fix
model_type,bos_token_id,eos_token_idfields toArchitectureConfigfrom_transformers()(called by the--configpath)write_ort_genai_config(), theelsebranch (nohf_model_id) now reads all three fromArchitectureConfiginstead of leaving them asNoneTests
_configs_test.py: verifiesfrom_transformers()stores the new fieldsauto_export_test.py: two new tests —test_config_mode_model_type_propagatedandtest_config_mode_token_ids_propagated