AGENT SKILL

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

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, or predict.
  • 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

  1. The package maximizes target values. Convert losses to scores, commonly by returning -loss or using a scikit-learn scorer whose larger value is better.
  2. pbounds keys must match the objective function keyword arguments exactly. Dict inputs are safest. Array/list inputs use the pbounds insertion order.
  3. Keep objective functions deterministic enough for the GP when possible. For noisy objectives, set allow_duplicate_points=True only when repeated evaluations at the same coordinates are intentional.
  4. Use f=None only for manual ask-tell loops: call suggest(), evaluate outside the optimizer, then register(params, target). Do not call eager probe(..., lazy=False) or maximize() with f=None.
  5. After maximize(), call predict(..., fit_gp=True) before relying on GP predictions; the final registered point may not be included in the fitted GP until prediction refits it.
  6. 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, TargetSpace result behavior, predict return 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=None misuse.

Bundled Smoke Scripts

  • scripts/bo_core_smoke.py: deterministic core API smoke test. It runs a tiny optimizer, validates max/res, exercises probe, 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

  1. Identify objective type:
    • In-process Python function: create BayesianOptimization(f=objective, ...).
    • External/manual evaluation: create BayesianOptimization(f=None, ...) and use ask-tell with suggest()/register().
  2. Define pbounds with 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.
  3. 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.
  4. Run maximize(init_points=..., n_iter=...) or the ask-tell loop.
  5. Validate optimizer.max is not None, has keys target and params, 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.
  6. Persist long or expensive runs with save_state(path). To resume, recreate a compatible optimizer and call load_state(path) before more suggestions or maximize(init_points=0, n_iter=...).
  7. If predictions or uncertainty are needed, call predict() with explicit fit_gp=True after at least one observation; use return_std=True or return_cov=True, never both.

Handoff Checklist For Future Agents

  • Objective wrapper returns a finite scalar target and uses the correct sign.
  • pbounds keys and objective kwargs match exactly.
  • Random seeds are set where reproducibility matters.
  • allow_duplicate_points is 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351