Skip to content

optimize is documented as top-level Python API but not exported from olive #2561

Description

@saschagobel

Describe the bug

The Python API docs show optimize as importable directly from the top-level olive package:

from olive import optimize

However, this currently fails because optimize is not re-exported in olive/__init__.py.

The function itself exists and works when imported from the internal CLI API module:

from olive.cli.api import optimize

Looking at olive/__init__.py, many Python API functions are imported from olive.cli.api and included in __all__, but optimize appears to be missing from both places. This looks like a small accidental omission.

To Reproduce

from olive import optimize

This raises:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name 'optimize' from 'olive'

The following workaround works:

from olive.cli.api import optimize

Expected behavior

optimize should be available from the documented top-level Python API:

from olive import optimize

Olive config

Not applicable. This is an import/export issue and happens before running an Olive workflow.

Olive logs

Not applicable.

Other information

  • OS: Ubuntu 24.04 LTS
  • Olive version: olive-ai 0.13.0
  • ONNXRuntime package and version: onnxruntime 1.27.0
  • Transformers package version: transformers 5.12.1

Additional context

I ran into this while integrating Olive-based ONNX export into tlmtc: https://github.com/saschagobel/tlmtc

I would be happy to open a small PR adding optimize to the import block and __all__ in olive/__init__.py if this is considered a bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions