dotnet/machinelearning · error · InvalidOperationException
SMAC sweeper localSearch threw exception
Error message
SMAC sweeper localSearch threw exception
What it means
Same pattern as SmacSweeper's LocalSearch: SmacTuner.LocalSearch computes expected improvement over mutation neighborhoods, and any exception inside is wrapped in InvalidOperationException ('SMAC sweeper localSearch threw exception') with the original exception as InnerException.
Source
Thrown at src/Microsoft.ML.AutoML/Tuner/SmacTuner.cs:254
for (; ; )
{
Parameter[] neighborhood = GetOneMutationNeighborhood(currentBestConfig);
var eis = neighborhood.Select(p => EvaluateConfigurationsByEI(forest, bestLoss, p)).ToArray();
var maxIndex = eis.ArgMax();
if (Math.Abs(eis[maxIndex] - currentBestEI) < _epsilon)
break;
else
{
currentBestConfig = neighborhood[maxIndex];
currentBestEI = eis[maxIndex];
}
}
return new Tuple<double, Parameter>(currentBestEI, currentBestConfig);
}
catch (Exception e)
{
throw new InvalidOperationException("SMAC sweeper localSearch threw exception", e);
}
}
private Parameter[] GetOneMutationNeighborhood(Parameter currentBestConfig)
{
var neighborhood = new List<Parameter>();
var features = _searchSpace.MappingToFeatureSpace(currentBestConfig);
for (int d = 0; d != _searchSpace.FeatureSpaceDim; ++d)
{
var newFeatures = features.Select(x => x).ToArray();
if (_searchSpace.Step[d] is int step)
{
// if step is not null, it means the parameter on that index is discrete.
// in that case, to sample a new value, we need to add the current feature value with 1/step
var nextStep = features[d] + (1.0 / step);
if (nextStep > 1)
{
nextStep -= 1;View on GitHub (pinned to 7b76e69cf9)
Solutions
- Inspect InnerException to find the true root cause and fix it.
- Validate sweeper parameter ranges and types given to SmacTuner.
- Increase fit/local-search sample counts so the model has sufficient history.
- Catch the InvalidOperationException and fall back to another tuner.
Example fix
// before
var best = tuner.ProposeSweep(); // may throw wrapped localSearch exception
// after
try { var best = tuner.ProposeSweep(); }
catch (InvalidOperationException ex) { logger.LogError(ex.InnerException, "SMAC local search failed"); } Defensive patterns
Strategy: try-catch
Validate before calling
if (!double.IsNaN(history.BestScore)) Console.WriteLine("model healthy"); // ensure non-degenerate history before tuning Try / catch
try { var cfg = smacTuner.ProposeSweep(); }
catch (InvalidOperationException ex) { logger.LogError(ex.InnerException, "SmacTuner local search failed"); cfg = fallbackTuner.ProposeSweep(); } Prevention
- Inspect InnerException for root cause
- Feed the tuner enough initial trials
- Validate parameter mutation ranges before running long sweeps
When it happens
Trigger: SmacTuner's bestChildKvp → LocalSearch path throws while evaluating one-mutation neighborhoods of the best configuration — typically due to failures in EPM predictions or invalid generated parameters.
Common situations: Running SMAC-tuned AutoML where the expected-improvement model produces NaN/invalid outputs, or parameter mutation generates out-of-range values.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Fail to find available configs for given trainers: {string.J
- {nameof(ChannelMessageKind)}.{e.Kind} is not yet implemented
- Training failed with the exception: {_history.Last().Excepti
- Metric {typeof(TMetrics)} not implemented
- SMAC sweeper localSearch threw exception
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/b141b8900bc087df.
Report an issue: GitHub.