You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend the Olive MobiusBuilder pass so recipes can provide a custom Mobius export callback through Olive's standard user_script mechanism.
This enables model-specific, multi-component Mobius workflows—such as CLM and KEV—to run through olive run while retaining standard Olive configuration, system, accelerator, caching, and output handling.
Changes
Add optional exporter_func configuration to MobiusBuilder.
Accepts a callable directly or a function name resolved from user_script.
Receives the input model, Olive output directory, precision, execution provider, and recipe-specific configuration.
Add optional exporter_config for model-specific callback settings.
Add standard user_script and script_dir configuration support to MobiusBuilder.
Allow recipe callbacks to write complete multi-component packages directly into the Olive output directory.
Require callbacks to return a non-empty component-name list.
Preserve package-level sidecar files through the returned CompositeModelHandler.
Preserve component subdirectory layouts through no_flatten.
Correctly handle custom exports containing a single component without assuming a root-level model.onnx.
Reject unsupported combinations of exporter_func with text_only or components_to_export.
Preserve all existing MobiusBuilder behavior when no custom exporter is configured.
Accept Mapping implementations instead of only dict instances
olive/passes/onnx/mobius_model_builder.py:234
The documented callback contract says this result may be a “mapping,” but this check accepts only concrete dict instances. A valid collections.abc.Mapping implementation (for example, UserDict or a recipe-specific immutable mapping) is therefore rejected despite supporting get and indexing exactly as the following code requires. Check against Mapping (and import it alongside Callable) so the implementation matches the public contract.
A concrete use case is olive-recipes#646, which exports CLM and KEV multi-component packages through olive run.
These models require recipe-specific orchestration beyond the standard mobius.build() path: loading pinned base and head artifacts, merging KEV LoRA weights, applying strict component-specific weights, and assembling provider-specific package manifests and sidecars.
We do not want to put that model-specific logic in Olive core. exporter_func, resolved through Olive’s existing user_script mechanism, keeps the implementation in the recipe while Olive still owns accelerator selection, pass execution, caching, and output handling. The callback contract itself remains generic and can support other specialized multi-component Mobius exports.
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
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.
Summary
Extend the Olive
MobiusBuilderpass so recipes can provide a custom Mobius export callback through Olive's standarduser_scriptmechanism.This enables model-specific, multi-component Mobius workflows—such as CLM and KEV—to run through
olive runwhile retaining standard Olive configuration, system, accelerator, caching, and output handling.Changes
exporter_funcconfiguration toMobiusBuilder.user_script.exporter_configfor model-specific callback settings.user_scriptandscript_dirconfiguration support toMobiusBuilder.CompositeModelHandler.no_flatten.model.onnx.exporter_funcwithtext_onlyorcomponents_to_export.MobiusBuilderbehavior when no custom exporter is configured.Example
{ "input_model": { "type": "HfModel", "model_path": "Qwen/Qwen3.5-4B-Base", "load_kwargs": { "revision": "1001bb4d826a52d1f399e183466143f4da7b741b", "torch_dtype": "float16" } }, "systems": { "local_system": { "type": "LocalSystem", "accelerators": [ { "device": "gpu", "execution_providers": ["CUDAExecutionProvider"] } ] } }, "passes": { "m": { "type": "MobiusBuilder", "precision": "fp16", "exporter_func": "export_kev_package", "exporter_config": { "artifact_path": "artifacts/kev", "recipe_precision": "mixed" }, "user_script": "../user_script.py", "script_dir": "../.." } }, "target": "local_system", "output_dir": "build", "cache_dir": "cache", "no_artifacts": true }