{"record":{"id":"b141b8900bc087df","repo":"dotnet/machinelearning","slug":"smac-sweeper-localsearch-threw-exception-b141b8","errorCode":null,"errorMessage":"SMAC sweeper localSearch threw exception","messagePattern":"SMAC sweeper localSearch threw exception","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Tuner/SmacTuner.cs","lineNumber":254,"sourceCode":"                for (; ; )\n                {\n                    Parameter[] neighborhood = GetOneMutationNeighborhood(currentBestConfig);\n                    var eis = neighborhood.Select(p => EvaluateConfigurationsByEI(forest, bestLoss, p)).ToArray();\n                    var maxIndex = eis.ArgMax();\n                    if (Math.Abs(eis[maxIndex] - currentBestEI) < _epsilon)\n                        break;\n                    else\n                    {\n                        currentBestConfig = neighborhood[maxIndex];\n                        currentBestEI = eis[maxIndex];\n                    }\n                }\n\n                return new Tuple<double, Parameter>(currentBestEI, currentBestConfig);\n            }\n            catch (Exception e)\n            {\n                throw new InvalidOperationException(\"SMAC sweeper localSearch threw exception\", e);\n            }\n        }\n\n        private Parameter[] GetOneMutationNeighborhood(Parameter currentBestConfig)\n        {\n            var neighborhood = new List<Parameter>();\n            var features = _searchSpace.MappingToFeatureSpace(currentBestConfig);\n            for (int d = 0; d != _searchSpace.FeatureSpaceDim; ++d)\n            {\n                var newFeatures = features.Select(x => x).ToArray();\n                if (_searchSpace.Step[d] is int step)\n                {\n                    // if step is not null, it means the parameter on that index is discrete.\n                    // in that case, to sample a new value, we need to add the current feature value with 1/step\n                    var nextStep = features[d] + (1.0 / step);\n                    if (nextStep > 1)\n                    {\n                        nextStep -= 1;","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Tuner/SmacTuner.cs#L236-L272","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running SMAC-tuned AutoML where the expected-improvement model produces NaN/invalid outputs, or parameter mutation generates out-of-range values.","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."],"exampleFix":"// before\nvar best = tuner.ProposeSweep(); // may throw wrapped localSearch exception\n// after\ntry { var best = tuner.ProposeSweep(); }\ncatch (InvalidOperationException ex) { logger.LogError(ex.InnerException, \"SMAC local search failed\"); }","handlingStrategy":"try-catch","validationCode":"if (!double.IsNaN(history.BestScore)) Console.WriteLine(\"model healthy\"); // ensure non-degenerate history before tuning","typeGuard":null,"tryCatchPattern":"try { var cfg = smacTuner.ProposeSweep(); }\ncatch (InvalidOperationException ex) { logger.LogError(ex.InnerException, \"SmacTuner local search failed\"); cfg = fallbackTuner.ProposeSweep(); }","preventionTips":["Inspect InnerException for root cause","Feed the tuner enough initial trials","Validate parameter mutation ranges before running long sweeps"],"tags":["csharp","tuner","smac"],"backgroundTag":"internal-invariant-violation","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}