Add Python API for all CLI commands with WorkflowOutput returns#1907
Conversation
Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>
…ation Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>
Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com>
|
We don't need python APIs for following CLIs. shared_cache, |
…e_qualcomm_sdk as requested Co-authored-by: devang-ml <47577486+devang-ml@users.noreply.github.com>
Removed the Python APIs for shared_cache, manage_aml_compute, and configure_qualcomm_sdk as requested. Updated all documentation, tests, and examples to reflect these changes. Commit: 99c5a40 |
|
Let's add documentation on how to use these APIs. docs/source/how-to/index.rst documents how to use CLI and how to use .json configuration. Let's update this page to cover ho to use python APIs. |
Co-authored-by: devang-ml <47577486+devang-ml@users.noreply.github.com>
Added comprehensive Python API documentation to the docs/source/how-to/index.rst page. Created a new "Working with the Python API" section with detailed documentation for auto_opt(), finetune(), quantize(), run(), and an overview page with usage patterns and examples. The documentation follows the same structure as the CLI documentation with function signatures, parameters, return values, and integration examples. Commit: f7051f7 |
|
The Python API should be in one single documentation page with different sections. |
There was a problem hiding this comment.
lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
| @@ -0,0 +1,117 @@ | |||
| # Olive Python API | |||
There was a problem hiding this comment.
Remove this file, combine this content to documentation you added.
| @@ -0,0 +1,159 @@ | |||
| # ------------------------------------------------------------------------- | |||
|
Fix lint issue. |
|
The Python API should be in one single documentation page with different sections. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
This PR implements a comprehensive Python API for all Olive CLI commands, allowing users to programmatically execute workflows and receive structured
WorkflowOutputobjects containingModelOutputinstances.Overview
The new Python API provides 13 functions corresponding to all CLI commands:
Workflow Functions (return
WorkflowOutputwithModelOutputinstances):auto_opt()- Auto-optimize models for performancefinetune()- Fine-tune models using LoRA/QLoRAquantize()- Quantize models for reduced sizecapture_onnx()- Capture ONNX graphs from PyTorch modelsgenerate_adapter()- Generate adapters for ONNX modelssession_params_tuning()- Tune ONNX Runtime parametersrun()- Execute workflows from configurationUtility Functions (perform operations, return
None):configure_qualcomm_sdk()- Configure Qualcomm SDKconvert_adapters()- Convert adapter formatsextract_adapters()- Extract LoRA adaptersgenerate_cost_model()- Generate cost models for splittingmanage_aml_compute()- Manage AzureML compute resourcesshared_cache()- Manage shared cache operationsUsage Examples
Key Benefits
WorkflowOutputobjects for optimization workflowsFiles Added
olive/api/__init__.py- API module exportsolive/api/workflow.py- All API function implementationsolive/api/README.md- Comprehensive documentationexamples/python_api_usage.py- Usage examplestest/unit_test/test_python_api.py- Unit testsFiles Modified
olive/__init__.py- Export API functions from main moduleThe API maintains full compatibility with existing CLI functionality while providing a more convenient interface for programmatic use.
Fixes #1906.