Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

ComputeUncompute

class ComputeUncompute(sampler, options=None)

GitHub(opens in a new tab)

Bases: qiskit.algorithms.state_fidelities.base_state_fidelity.BaseStateFidelity

This class leverages the sampler primitive to calculate the state fidelity of two quantum circuits following the compute-uncompute method (see [1] for further reference). The fidelity can be defined as the state overlap.

ψ(x)ϕ(y)2|\langle\psi(x)|\phi(y)\rangle|^2

where xx and yy are optional parametrizations of the states ψ\psi and ϕ\phi prepared by the circuits circuit_1 and circuit_2, respectively.

Reference: [1] Havlíček, V., Córcoles, A. D., Temme, K., Harrow, A. W., Kandala, A., Chow, J. M., & Gambetta, J. M. (2019). Supervised learning with quantum-enhanced feature spaces. Nature, 567(7747), 209-212. arXiv:1804.11326v2 [quant-ph](opens in a new tab)

Parameters

  • sampler (BaseSampler) – Sampler primitive instance.
  • options (Options | None) – Primitive backend runtime options used for circuit execution. The order of priority is: options in run method > fidelity’s default options > primitive’s default setting. Higher priority setting overrides lower priority setting.

Raises

ValueError – If the sampler is not an instance of BaseSampler.


Methods

create_fidelity_circuit

ComputeUncompute.create_fidelity_circuit(circuit_1, circuit_2)

Combines circuit_1 and circuit_2 to create the fidelity circuit following the compute-uncompute method.

Parameters

Return type

QuantumCircuit

Returns

The fidelity quantum circuit corresponding to circuit_1 and circuit_2.

run

ComputeUncompute.run(circuits_1, circuits_2, values_1=None, values_2=None, **options)

Runs asynchronously the state overlap (fidelity) calculation between two (parametrized) circuits (first and second) for a specific set of parameter values (first and second). This calculation depends on the particular fidelity method implementation.

Parameters

  • circuits_1 – (Parametrized) quantum circuits preparing ψ|\psi\rangle.
  • circuits_2 – (Parametrized) quantum circuits preparing ϕ|\phi\rangle.
  • values_1 – Numerical parameters to be bound to the first set of circuits.
  • values_2 – Numerical parameters to be bound to the second set of circuits.
  • options – Primitive backend runtime options used for circuit execution. The order of priority is: options in run method > fidelity’s default options > primitive’s default setting. Higher priority setting overrides lower priority setting.

Returns

Primitive job for the fidelity calculation. The job’s result is an instance of StateFidelityResult.

update_default_options

ComputeUncompute.update_default_options(**options)

Update the fidelity’s default options setting.

Parameters

**options – The fields to update the default options.


Attributes

options

Return the union of estimator options setting and fidelity default options, where, if the same field is set in both, the fidelity’s default options override the primitive’s default setting.

Return type

Options

Returns

The fidelity default + estimator options.

Was this page helpful?
Report a bug or request content on GitHub.