qlauncher.routines.qiskit.algorithms.qml

qlauncher.routines.qiskit.algorithms.qml#

Summary#

Classes:

ComputeUncomputeCustom

This is just qiskit_machine_learning.state_fidelities.ComputeUncompute that checks if a sampler is an instance of BaseSamplerV1 instead of BaseSampler.

TrainQSVCKernel

Train a quantum kernel with additional parameters to be optimized. The kernel will be optimized to provide maximum accuracy with a support vector classifier on the provided dataset. If no trainable parameters are provided, the algorithm will return a qiskit_machine_learning.kernels.FidelityQuantumKernel kernel with a sampler assigned to the provided backend. Otherwise an instance of qiskit_machine_learning.kernels.TrainableFidelityQuantumKernel with optimal parameters and a sampler assigned to the provided backend will be returned.

Reference#

class qlauncher.routines.qiskit.algorithms.qml.ComputeUncomputeCustom(sampler: BaseSampler | BaseSamplerV2, *, options: Options | None = None, local: bool = False, pass_manager: PassManager | None = None)[source]#

Bases: ComputeUncompute

This is just qiskit_machine_learning.state_fidelities.ComputeUncompute that checks if a sampler is an instance of BaseSamplerV1 instead of BaseSampler. The reason was that classes basing BaseSampler were getting isinstance(cls(),BaseSampler) == False probably because of some qiskit shenanigans.

class qlauncher.routines.qiskit.algorithms.qml.TrainQSVCKernel(kernel_circuit: QuantumCircuit, trainable_params: Sequence[Parameter] | None = None, **alg_kwargs)[source]#

Bases: Algorithm

Train a quantum kernel with additional parameters to be optimized. The kernel will be optimized to provide maximum accuracy with a support vector classifier on the provided dataset. If no trainable parameters are provided, the algorithm will return

a qiskit_machine_learning.kernels.FidelityQuantumKernel kernel with a sampler assigned to the provided backend. Otherwise an instance of qiskit_machine_learning.kernels.TrainableFidelityQuantumKernel with optimal parameters and a sampler assigned to the provided backend will be returned.

Parameters:
  • kernel_circuit (QuantumCircuit) – A parametrizable quantum circuit. The measurements will be used to produce kernel output.

  • trainable_params (Sequence[Parameter] | None, optional) – The parameters to be optimized during training. If None no optimization will be done. Defaults to None.

run(problem: Problem, backend: Backend, formatter: Callable[[...], Any]) Result[source]#

Runs the algorithm on a specific problem using a backend.

Parameters:
  • problem (Problem) – The problem to be solved.

  • backend (Backend) – The backend to be used for execution.