mlflow/mlflow · error · RuntimeError
Unknown parameter search model type {type(param_search_model
Error message
Unknown parameter search model type {type(param_search_model)}. What it means
MLflow's PySpark autologging extracts validation metrics from parameter-search results, supporting CrossValidatorModel and TrainValidationSplitModel. If the fitted model is neither of these types, MLflow cannot find validationMetrics and raises this RuntimeError.
Source
Thrown at mlflow/pyspark/ml/__init__.py:513
- For TrainValidationSplitModel, the result dict contains metrics for each param map.
`best_index` is the best index of trials.
"""
from pyspark.ml.tuning import CrossValidatorModel, TrainValidationSplitModel
metrics_dict = {}
metric_key = param_search_estimator.getEvaluator().getMetricName()
if isinstance(param_search_model, CrossValidatorModel):
avg_metrics = param_search_model.avgMetrics
metrics_dict["avg_" + metric_key] = avg_metrics
if hasattr(param_search_model, "stdMetrics"):
metrics_dict["std_" + metric_key] = param_search_model.stdMetrics
elif isinstance(param_search_model, TrainValidationSplitModel):
avg_metrics = param_search_model.validationMetrics
metrics_dict[metric_key] = avg_metrics
else:
raise RuntimeError(f"Unknown parameter search model type {type(param_search_model)}.")
if param_search_estimator.getEvaluator().isLargerBetter():
best_index = np.argmax(avg_metrics)
else:
best_index = np.argmin(avg_metrics)
return metrics_dict, best_index
def _log_estimator_params(param_map):
# Chunk model parameters to avoid hitting the log_batch API limit
for chunk in _chunk_dict(param_map, chunk_size=MAX_PARAMS_TAGS_PER_BATCH):
truncated = _truncate_dict(chunk, MAX_ENTITY_KEY_LENGTH, MAX_PARAM_VAL_LENGTH)
mlflow.log_params(truncated)
class _AutologgingMetricsManager:
"""View on GitHub (pinned to 6a27f2decc)
Solutions
- Log the CrossValidatorModel/TrainValidationSplitModel itself, not its .bestModel.
- Confirm the tuning estimator is pyspark.ml.tuning.CrossValidator or TrainValidationSplit.
- Unwrap any custom tuner to the underlying Spark model before autolog logging.
- Upgrade MLflow if a newer Spark tuner type is the cause.
Example fix
# before best = cv_model.bestModel mlflow.pyspark.ml.log_posttraining_metadata(...) # expects tuner model, got best estimator # after mlflow.pyspark.ml.log_posttraining_metadata(...) # pass cv_model (the tuner model)
Defensive patterns
Strategy: type-guard
Validate before calling
from pyspark.ml.tuning import CrossValidatorModel, TrainValidationSplitModel
if not isinstance(tuner_model, (CrossValidatorModel, TrainValidationSplitModel)):
raise TypeError(f"Expected tuner model, got {type(tuner_model)}") Type guard
from pyspark.ml.tuning import CrossValidatorModel, TrainValidationSplitModel
def is_param_search_model(m) -> bool:
return isinstance(m, (CrossValidatorModel, TrainValidationSplitModel)) Try / catch
try:
log_tuning_metadata(model)
except RuntimeError as e:
if "Unknown parameter search model type" in str(e):
log_tuning_metadata(model._original_tuner_model) Prevention
- Log the CrossValidatorModel/TrainValidationSplitModel, not .bestModel
- Avoid custom tuner wrappers with autologging
- Check MLflow/Spark version compatibility for new tuner classes
When it happens
Trigger: Passing a fitted model to _log_posttraining_metadata / _create_child_runs_for_parameter_search that is not a CrossValidatorModel or TrainValidationSplitModel, e.g. a custom tuner, a wrapped model, or a tune step whose result was unwrapped to the best model.
Common situations: Autologging custom hyperparameter-tuning wrappers; calling .bestModel and logging the result as if it were the tuner model; Spark version changes introducing new tuner classes not yet supported.
Related errors
- INVALID_PARAMETER_VALUE
- Pipeline stages should be iterable, but found object {origin
- Tuning params should not include params not owned by the tun
- Failed to set up OpenTelemetry instrumentation for Agno V2.
- Unknown content type: {content_type['type']}. Please make su
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/7583941916ebafcc.
Report an issue: GitHub.