Add skops saving format for lightgbm flavor#20151
Conversation
🛠 DevTools 🛠
Install mlflow from this PRFor Databricks, use the following command: |
|
/autoformat |
There was a problem hiding this comment.
Pull request overview
This pull request adds support for the skops serialization format to the LightGBM flavor, enabling safer model serialization and deserialization for LightGBM scikit-learn API models. The implementation leverages sklearn's existing save and load functions for non-Booster models, introducing new parameters serialization_format and skops_trusted_types to both save_model and log_model functions.
Changes:
- Added
serialization_formatandskops_trusted_typesparameters to lightgbm'ssave_modelandlog_modelfunctions - Refactored
_save_modeland_load_modelto delegate to sklearn's serialization functions for non-Booster models - Updated documentation to reflect the new serialization options
- Relocated security warning from sklearn's public API to internal
_save_modelfunction - Added test for saving and loading LightGBM models using skops format
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| mlflow/lightgbm/init.py | Added skops serialization support by introducing new parameters and refactoring save/load logic to use sklearn's serialization functions for non-Booster models |
| mlflow/sklearn/init.py | Refactored warning message location and updated documentation for serialization format parameter |
| tests/lightgbm/test_lightgbm_model_export.py | Added test case for saving and loading models with skops serialization format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Documentation preview for 4a8aaf9 is available at: More info
|
| path=model_path, | ||
| serialization_format="skops", | ||
| skops_trusted_types=[ | ||
| "collections.OrderedDict", |
There was a problem hiding this comment.
Are these pretty common? If so, we might want to add these as examples to the docstring for this argument
There was a problem hiding this comment.
Yes it is common.
If skops_trusted_types is not set correctly, user will get clear message about which types need to set as skops_trusted_types.
I added this to example code too.
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
Added skops saving format for lightgbm flavor
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Added skops saving format for lightgbm flavor
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.