kernels-fidelity
Evaluate, configure, and train Qiskit Machine Learning fidelity-based quantum kernels, including statevector kernels, ComputeUncompute fidelity, duplicate and PSD policies, trainable parameters, and kernel losses.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- kernels-fidelity
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Evaluate, configure, and train Qiskit Machine Learning fidelity-based quantum kernels, including statevector kernels, ComputeUncompute fidelity, duplicate and PSD policies, trainable parameters, and kernel losses.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md9.1 KB
- 参考文档references/fidelity-and-runtime.md4.5 KB
- 参考文档references/troubleshooting.md7.7 KB
- 参考文档references/workflows.md7.0 KB
- 脚本scripts/kernel_smoke.py1.9 KB
03 SKILL.md 正文
Fidelity kernels
Use this route when the task is to turn a parameterized quantum feature map into
fidelity kernel matrices, select a fidelity primitive or statevector simulation,
control duplicate/PSD/shot behavior, bind trainable feature-map parameters, or
optimize a kernel with QuantumKernelTrainer.
Fast route
- Define an explicit
QuantumCircuitfeature map whose data-parameter count equals the input feature dimension. The current implementation's base class rejects a missing feature map, even where a constructor annotation permitsNone; do not rely on an implicit default. - Choose
FidelityStatevectorKernelfor exact/classically simulated overlaps, optionally with bounded caching and shot-noise emulation. ChooseFidelityQuantumKernelfor a sampler-backedBaseStateFidelity; its default fidelity isComputeUncomputeover the QML reference sampler. - Evaluate
K_train = kernel.evaluate(X)and, for held-out data,K_test = kernel.evaluate(X_test, X_train). Check shapes before passing a precomputed matrix to a consumer. Route QSVC/QSVR fitting to the algorithms sub-skill; this skill owns the kernel object and matrices, not model fitting. - For noisy symmetric training matrices, keep
enforce_psd=Trueunless the downstream algorithm or experiment explicitly requires the raw noisy matrix. Selectevaluate_duplicatesdeliberately for primitive kernels. - For a trainable feature map, construct a trainable fidelity kernel, bind every
training parameter with
assign_training_parameters, then useQuantumKernelTrainerwith a derivative-free optimizer and an appropriate kernel loss. Route optimizer-specific choices to the optimizers sub-skill. - If a sampler requires backend-specific transpilation, construct
ComputeUncompute(sampler=..., pass_manager=...)using a pass manager for the same backend and validate the resulting circuit layout before execution.
Read workflows for concrete procedures, api-reference for signatures and matrix semantics, fidelity-and-runtime for primitive/runtime adaptation, and troubleshooting before changing an otherwise working configuration.
Applicability and boundaries
- This route covers
BaseKernel,FidelityQuantumKernel,FidelityStatevectorKernel, their trainable variants,BaseStateFidelity,ComputeUncompute,StateFidelityResult,QuantumKernelTrainer, and kernel losses (SVCLoss,SVRLoss,MSRLoss,MARLoss,HuberLoss). - It covers feature-map dimensions, symmetric/asymmetric evaluation, duplicate shortcuts, PSD projection, statevector caching, shot noise, parameter binding, trainer outputs, and fidelity runtime/pass-manager adaptation.
- It does not choose classical optimizers, fit QSVC/QSVR models, or explain raw QNN gradient workflows. Use the linked algorithms, optimizers, or qnn-gradients routes when those are the primary task.
- Keep matrices in memory or in user-named artifacts; do not assume a source
checkout exists at runtime. Install public dependencies using the package's
published installation instructions, for example
pip install qiskit-machine-learningplus compatible Qiskit and scikit-learn packages.
Minimal acceptance checks
Run the bundled smoke check with python path/to/kernel_smoke.py. It constructs
a two-feature statevector kernel, asserts a square symmetric training matrix,
checks the asymmetric (1, 2) shape, and verifies unit self-fidelity. For a
sampler-backed or trainable deployment, additionally check the relevant workflow
and runtime failure cases in the references. Do not claim hardware verification
from a statevector-only smoke test.
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).