mlflow/mlflow · error · MlflowException
INTERNAL_ERROR
INTERNAL_ERROR
Error message
Unrecognized serialization format: {serialization_format} What it means
mlflow.sklearn's save path dispatches on the `serialization_format` argument and only understands 'skops' and 'cloudpickle'. Any other value falls into the final else branch and raises this MlflowException with error code INTERNAL_ERROR. The output directory is not written with a usable model.
Source
Thrown at mlflow/sklearn/__init__.py:712
shutil.rmtree(output_path, ignore_errors=True)
raise MlflowException(
"The sklearn model could not be serialized in the skops serialization format. "
"skops does not support custom functions or classes that are not defined at the "
"top level. To work around this limitation, you can set the serialization_format "
"'cloudpickle', while exercising caution due to the possible arbitrary "
"code during model deserialization using CloudPickle."
) from e
return
with open(output_path, "wb") as out:
if serialization_format == SERIALIZATION_FORMAT_PICKLE:
_dump_model(pickle, sk_model, out)
elif serialization_format == SERIALIZATION_FORMAT_CLOUDPICKLE:
import cloudpickle
_dump_model(cloudpickle, sk_model, out)
else:
raise MlflowException(
message=f"Unrecognized serialization format: {serialization_format}",
error_code=INTERNAL_ERROR,
)
def load_model(model_uri, dst_path=None):
"""
Load a scikit-learn model from a local file or a run.
Args:
model_uri: The location, in URI format, of the MLflow model, for example:
- ``/Users/me/path/to/local/model``
- ``relative/path/to/local/model``
- ``s3://my_bucket/path/to/model``
- ``runs:/<mlflow_run_id>/run-relative/path/to/model``
- ``models:/<model_name>/<model_version>``
- ``models:/<model_name>/<stage>``View on GitHub (pinned to 6a27f2decc)
Solutions
- Set serialization_format to exactly 'skops' or 'cloudpickle' (lowercase).
- Import the constants instead of hard-coding strings: from mlflow.sklearn import SERIALIZATION_FORMAT_SKOPS, SERIALIZATION_FORMAT_CLOUDPICKLE.
- Check for accidental whitespace or case differences in config/env-driven values (e.g. .strip().lower() before passing).
Example fix
// before mlflow.sklearn.save_model(model, path, serialization_format='pickle') // after mlflow.sklearn.save_model(model, path, serialization_format='cloudpickle')
Defensive patterns
Strategy: validation
Validate before calling
VALID = {'skops', 'cloudpickle'}
assert serialization_format in VALID, f'serialization_format must be one of {VALID}, got {serialization_format!r}' Try / catch
try:
mlflow.sklearn.save_model(model, path, serialization_format=fmt)
except MlflowException as e:
if 'Unrecognized serialization format' in str(e):
raise ValueError(f'Bad format {fmt!r}; use skops or cloudpickle') from e Prevention
- Use the module constants SERIALIZATION_FORMAT_SKOPS / SERIALIZATION_FORMAT_CLOUDPICKLE
- Lowercase/strip values coming from config or env vars
- Add a config schema check (pydantic/jsonschema) for serialization_format
When it happens
Trigger: Passing serialization_format to mlflow.sklearn.save_model/log_model (or via MLFLOW_SKLEARN_DEFAULT_SERIALIZATION_FORMAT-style config paths that ultimately reach _save_model) with a typo or unsupported value, e.g. 'pickle', 'joblib', or 'CloudPickle'.
Common situations: Typos in the format string; case-sensitivity mistakes ('CloudPickle' vs 'cloudpickle'); copying config from older MLflow versions or blog posts that predate the skops format.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Databricks host not found. Please either: 1. Set the DATAB
- @kubernetes/client-node is not installed. It is required for
- Invalid response format: missing credential_info
- An MLflow Tracking URI is required, please provide the track
- An MLflow experiment ID is required, please provide the expe
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/b570055e2cc32ff9.
Report an issue: GitHub.