Skip to content

fix: accept Hugging Face configs without a model_type in HfModel - #2691

Open
Yuri Khrustalev (ykhrustalev) wants to merge 1 commit into
microsoft:mainfrom
ykhrustalev:ykhrustalev/accept-hf-configs-without-model-type
Open

Yuri Khrustalev (ykhrustalev) wants to merge 1 commit into
microsoft:mainfrom
ykhrustalev:ykhrustalev/accept-hf-configs-without-model-type

Conversation

@ykhrustalev

Copy link
Copy Markdown
Contributor

Describe your changes

Problem
LiquidAI/LFM2.5-Audio-1.5B has no model_type in its config.json, so AutoConfig rejects it and HfModelHandler can't be constructed. onnxruntime-genai's model builder already supports this checkpoint, so only Olive blocks ModelBuilder.

Solution

  • Falls back to a plain PretrainedConfig in get_model_config when the config has no model_type
  • Applies load kwargs to the fallback config the same way AutoConfig does
  • Keeps raising for unknown model types and for remote-code configs loaded without trust_remote_code

Testing

  • Ran ModelBuilder on a tiny random checkpoint with the LFM2.5-Audio config layout: it produced model.onnx and a genai_config.json of type lfm2_audio_text (onnxruntime-genai 0.17.0)

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

Release note: HfModel accepts Hugging Face checkpoints whose config.json has no model_type, such as LiquidAI/LFM2.5-Audio-1.5B, so ModelBuilder can convert them.

LiquidAI/LFM2.5-Audio-1.5B has no model_type in its config.json, so AutoConfig
rejects it and HfModelHandler can't be built, though the ORT GenAI model builder
supports it. Fall back to a plain PretrainedConfig then; unknown model types and
untrusted remote-code configs still raise.
Copilot AI lite review requested due to automatic review settings September 25, 2026 23:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified, and all reviewed changes are covered by tests.

Review effort: Lite
Findings: None

What changed in this PR

Adds support for Hugging Face checkpoints whose configurations lack model_type, enabling HfModel and ModelBuilder processing.

Changes:

  • Falls back to PretrainedConfig while preserving load kwargs.
  • Retains validation for unknown types and untrusted remote code.
  • Adds focused unit tests.
File Description
test/​common/​test_hf.py Tests fallback behavior and error cases.
olive/​common/​hf/​utils.py Implements configuration fallback logic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants