optimizer-workflows
Use BayesianOptimization for ordinary black-box optimization, manual ask-tell loops, persistence, prediction, and small ML hyperparameter optimization.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- optimizer-workflows
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use BayesianOptimization for ordinary black-box optimization, manual ask-tell loops, persistence, prediction, and small ML hyperparameter optimization.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md11.2 KB
- 参考文档references/troubleshooting.md9.1 KB
- 参考文档references/workflows.md11.0 KB
- 脚本scripts/bo_core_smoke.py8.4 KB
- 脚本scripts/sklearn_hpo_smoke.py6.2 KB
03 SKILL.md 正文
Optimizer Workflows
Use this sub-skill when a user wants to run the core bayes_opt.BayesianOptimization
lifecycle for a black-box objective or a small machine-learning hyperparameter
optimization job. This route is self-contained: future agents should not need to
open the original repository docs, notebooks, tests, or examples.
Load This When
- The user has a Python function or external evaluation service and wants to optimize scalar parameters with Bayesian optimization.
- The task mentions
BayesianOptimization,pbounds,maximize,max,res,probe,register,suggest,random_sample,set_bounds,set_gp_params,save_state,load_state, orpredict. - The user asks how to turn a loss into an optimization target, persist an optimizer, resume a run, validate results, or handle duplicate/noisy observations.
- The user wants a tiny scikit-learn HPO pattern using
bayesian-optimization.
Core Rules To Apply First
- The package maximizes target values. Convert losses to scores, commonly by
returning
-lossor using a scikit-learn scorer whose larger value is better. pboundskeys must match the objective function keyword arguments exactly. Dict inputs are safest. Array/list inputs use thepboundsinsertion order.- Keep objective functions deterministic enough for the GP when possible. For
noisy objectives, set
allow_duplicate_points=Trueonly when repeated evaluations at the same coordinates are intentional. - Use
f=Noneonly for manual ask-tell loops: callsuggest(), evaluate outside the optimizer, thenregister(params, target). Do not call eagerprobe(..., lazy=False)ormaximize()withf=None. - After
maximize(), callpredict(..., fit_gp=True)before relying on GP predictions; the final registered point may not be included in the fitted GP until prediction refits it. - Save/load state as JSON with a newly constructed compatible optimizer: same
objective-compatible kwargs,
pbounds, acquisition strategy, constraints, duplicate policy, and any bounds transformer.
Bundled References
- API reference: constructor and method
signatures, lifecycle semantics,
TargetSpaceresult behavior,predictreturn shapes, and state persistence details. - Workflow recipes: basic optimization, manual ask-tell evaluations, tiny HPO patterns, loss sign handling, persistence, duplicate/noisy recipes, bounds updates, and result validation.
- Troubleshooting: symptoms, causes, and fixes
for key mismatches, duplicate points, unfitted GP errors, stale state loads,
target-sign mistakes, bounds/type changes, slow objectives, and
f=Nonemisuse.
Bundled Smoke Scripts
scripts/bo_core_smoke.py: deterministic core API smoke test. It runs a tiny optimizer, validatesmax/res, exercisesprobe,register,suggest,random_sample,set_bounds,set_gp_params,predict, duplicate handling, and optional JSON save/load.scripts/sklearn_hpo_smoke.py: deterministic tiny scikit-learn HPO diagnostic with synthetic data. It demonstrates both maximizing a score and negating a loss, with safe integer casting for model hyperparameters.
Run scripts only in an environment where bayesian-optimization and its normal
Python dependencies are installed. Both scripts support --help, use bounded
synthetic data, do not download from the network, and avoid destructive writes.
Routing Boundaries
Stay in this sub-skill for the optimizer lifecycle, public result validation,
manual ask-tell loops, persistence/resume patterns, predict semantics, noisy
or duplicate objectives, bounds updates, GP parameter tuning through
set_gp_params, and ordinary small HPO recipes.
Route elsewhere for features that have distinct APIs or deeper contracts:
- Acquisition choices, custom acquisition functions,
ConstantLiar,GPHedge, and exploration/exploitation controls:../acquisition-control/SKILL.md. - Constraints, typed/categorical parameters beyond simple wrapper casting,
custom
BayesParameter, and sequential domain reduction:../advanced-domain-features/SKILL.md. - Repository editing, tests, docs, release, packaging, linting, and maintainer
workflows:
../repo-maintenance/SKILL.md.
Minimal Decision Flow
- Identify objective type:
- In-process Python function: create
BayesianOptimization(f=objective, ...). - External/manual evaluation: create
BayesianOptimization(f=None, ...)and use ask-tell withsuggest()/register().
- In-process Python function: create
- Define
pboundswith exact parameter names and realistic finite bounds. Prefer log-transformed parameters for scale-sensitive HPO (log10_C,log_learning_rate) and transform inside the objective wrapper. - Choose a budget. For smoke tests use tiny values such as
init_points=2,n_iter=2; for expensive tasks, increase only after validating objective sign, result shape, and runtime. - Run
maximize(init_points=..., n_iter=...)or the ask-tell loop. - Validate
optimizer.maxis notNone, has keystargetandparams, all returned params are within intended bounds,len(optimizer.res)matches the number of registered observations, and the best target uses the intended metric sign. - Persist long or expensive runs with
save_state(path). To resume, recreate a compatible optimizer and callload_state(path)before more suggestions ormaximize(init_points=0, n_iter=...). - If predictions or uncertainty are needed, call
predict()with explicitfit_gp=Trueafter at least one observation; usereturn_std=Trueorreturn_cov=True, never both.
Handoff Checklist For Future Agents
- Objective wrapper returns a finite scalar target and uses the correct sign.
pboundskeys and objective kwargs match exactly.- Random seeds are set where reproducibility matters.
allow_duplicate_pointsis justified for noise; otherwise duplicate errors are treated as a signal to change the loop.- State files are JSON and loaded into an optimizer with compatible settings.
- Any advanced acquisition, constraint, typed-parameter, or domain-reduction need has been routed to the sibling sub-skill instead of duplicated here.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).