AGENT SKILL

optimizers

Select, configure, run, and troubleshoot Qiskit Machine Learning optimizers for classical objectives and variational training, including SciPy wrappers, SPSA/QNSPSA, gradient and steppable workflows, bounds, callbacks, serialization, and optional NLopt.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
optimizers
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Select, configure, run, and troubleshoot Qiskit Machine Learning optimizers for classical objectives and variational training, including SciPy wrappers, SPSA/QNSPSA, gradient and steppable workflows, bounds, callbacks, serialization, and optional NLopt.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

Optimizers

Use this skill when a downstream task must minimize a scalar objective over parameter vectors with qiskit_machine_learning.optimizers. It covers the optimizer contract and optimizer-specific behavior. It does not design a VQC/VQR or other trainable model, and it does not implement quantum gradients; route model embedding to algorithms and gradient construction to qnn-gradients.

Fast route

  1. Define fun(x) -> scalar, a one-dimensional initial point x0, and, when available, jac(x) -> gradient. Decide whether the objective is smooth, noisy, constrained/bounded, or requires a global search.
  2. Use the decision table in optimizer-selection.md. Prefer minimize(fun, x0, jac=jac, bounds=bounds) for an ordinary run.
  3. Check get_support_level() before trusting jac or bounds; ignored is not the same as supported. The support matrix and constructor facts are in api-reference.md.
  4. Use workflows.md for ordinary, noisy, ask/tell, QN-SPSA, serialization, and optional-NLopt procedures.
  5. Interpret OptimizerResult and verify that the final point is feasible and that the reported objective was evaluated under the same noise/seed policy. If anything fails, use troubleshooting.md.

Public entry points

from qiskit_machine_learning.optimizers import (
    ADAM, AQGD, CG, COBYLA, GSLS, GradientDescent, L_BFGS_B,
    NELDER_MEAD, NFT, P_BFGS, POWELL, QNSPSA, SLSQP, SPSA, TNC,
    UMDA, SciPyOptimizer,
)

The optional NLopt-backed exports are CRS, DIRECT_L, DIRECT_L_RAND, ESCH, ISRES, and SBPLX. Instantiate them only after checking the optional dependency. Do not silently substitute an unsupported optimizer: choose a documented CPU fallback when NLopt is unavailable.

Guardrails

  • Every ordinary optimizer consumes fun, x0, optional jac, and optional bounds, and returns an OptimizerResult; most optimizers require an initial point even when their support level says it is merely supported.
  • Bounds are a list of (lower, upper) pairs aligned with x0. Do not pass bounds to an optimizer whose level is ignored and then assume they were enforced. Use L_BFGS_B, SLSQP, TNC, POWELL, GSLS, or finite-bound NLopt when bound enforcement is required.
  • SPSA and QNSPSA are stochastic. Set qiskit_machine_learning.utils.algorithm_globals.random_seed before the run when reproducibility matters; a NumPy seed alone is not a substitute.
  • If only one of SPSA's learning_rate and perturbation is supplied, construction of the run raises ValueError. Supplying neither invokes calibration and consumes extra objective evaluations.
  • Callback signatures are optimizer-specific. Never reuse a callback written for one optimizer without adapting its arguments. Model-level callback behavior belongs to algorithms, not this skill.
  • settings is a configuration snapshot, not generally a live optimizer state. Callables, fidelity functions, termination checkers, and custom linear solvers are not JSON values. ADAM has a separate CSV snapshot mechanism.

Verification checklist

Before handing off an optimizer choice, check: import path; constructor signature; support levels; objective and gradient shapes; finite bounds when required; seed and evaluation budget; callback arity; result.x feasibility; and result.fun, nfev, and nit interpretation. Run the bundled smoke script from any working directory with python .../optimizer_smoke.py --help or a small installed-package invocation using scripts/optimizer_smoke.py.

Read the linked references progressively rather than loading the entire catalog into every optimization task.

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