Skip to content

Conversation

@xiaoyu-work
Copy link
Collaborator

@xiaoyu-work xiaoyu-work commented Jan 8, 2026

Describe your changes

  1. Add popular model IO configs.
  2. Use Olive built in IO configs for ONNX conversion pass.
  3. Remove optimum dependency.

This change is verified by running capture-onnx-graph CLI for 70+ huggingface models.

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.

(Optional) Issue link

Copy link
Contributor

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@xiaoyu-work xiaoyu-work requested a review from Copilot January 13, 2026 20:11
@xiaoyu-work xiaoyu-work marked this pull request as ready for review January 13, 2026 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a comprehensive internal implementation of HuggingFace model IO configurations to replace the dependency on the optimum library. The changes include adding support for popular model types and diffusers pipeline components (SD, SDXL, SD3, Flux, Sana), implementing ONNX export configurations, and updating the DiffusersModelVariant enum from "sd15" to "sd".

Changes:

  • Adds a new olive/common/hf/io_config/ module with base classes, model configs, input generators, normalized configs, and task definitions for ONNX export
  • Updates DiffusersModelVariant enum: renames SD15 to SD, adds SD3 and SANA variants, and moves to olive/constants.py
  • Adds DiffusersComponent enum for pipeline component names
  • Refactors diffusers model detection to use config files instead of model name patterns
  • Updates ONNX conversion to use new io_config instead of optimum's main_export
  • Updates all tests and CLI to use the new variant names

Reviewed changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
olive/constants.py Adds DiffusersModelVariant and DiffusersComponent enums
olive/common/hf/io_config/ New module with 1000+ lines implementing ONNX export configs for 80+ model types
olive/model/handler/diffusers.py Updates variant detection logic and adds exportable component methods
olive/passes/onnx/conversion.py Refactors diffusers export to use new io_config instead of optimum
olive/common/hf/model_io.py Simplifies to use new io_config module
test/ files Updates all tests to use new variant names and adds comprehensive test coverage
olive/cli/ Updates CLI to support new variants

Comment on lines 116 to 118
if model_type not in _ONNX_CONFIG_REGISTRY:
return False
return task in _ONNX_CONFIG_REGISTRY[model_type]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rewrite

return model_type in _ONNX_CONFIG_REGISTRY and task in _ONNX_CONFIG_REGISTRY[model_type]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 271 to 303
if variant == DiffusersModelVariant.SD:
return [
DiffusersComponent.TEXT_ENCODER,
DiffusersComponent.UNET,
DiffusersComponent.VAE_ENCODER,
DiffusersComponent.VAE_DECODER,
]
elif variant == DiffusersModelVariant.SDXL:
return [
DiffusersComponent.TEXT_ENCODER,
DiffusersComponent.TEXT_ENCODER_2,
DiffusersComponent.UNET,
DiffusersComponent.VAE_ENCODER,
DiffusersComponent.VAE_DECODER,
]
elif variant == DiffusersModelVariant.SD3:
return [
DiffusersComponent.TEXT_ENCODER,
DiffusersComponent.TEXT_ENCODER_2,
DiffusersComponent.TEXT_ENCODER_3,
DiffusersComponent.TRANSFORMER,
DiffusersComponent.VAE_ENCODER,
DiffusersComponent.VAE_DECODER,
]
elif variant == DiffusersModelVariant.FLUX:
return [
DiffusersComponent.TEXT_ENCODER,
DiffusersComponent.TEXT_ENCODER_2,
DiffusersComponent.TRANSFORMER,
DiffusersComponent.VAE_ENCODER,
DiffusersComponent.VAE_DECODER,
]
elif variant == DiffusersModelVariant.SANA:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth converting this if/else to a map, may be even a constant map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using map now.

@xiaoyu-work xiaoyu-work merged commit 3c31f1b into main Jan 14, 2026
11 checks passed
@xiaoyu-work xiaoyu-work deleted the xiaoyu/optimum branch January 14, 2026 23:16
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.

3 participants