qlauncher.routines.cirq#

Routine file for Cirq library

Summary#

Classes:

CirqBackend

CirqSampler

Sampler adapter for Cirq

CirqSamplerV2

Functions:

Reference#

qlauncher.routines.cirq.extract_bitstrings_from_result(result: Result) list[str][source]#
qlauncher.routines.cirq.cirq_result_to_counts(result: Result) dict[source]#
qlauncher.routines.cirq.cirq_result_to_probabilities(result: Result, integer_keys: bool = False) dict[source]#
class qlauncher.routines.cirq.CirqSampler(*, options: dict | None = None)[source]#

Bases: Sampler

Sampler adapter for Cirq

run(circuits: tuple[Circuit, ...], parameter_values: tuple[tuple[float, ...], ...], **run_options)[source]#

Run the job of the sampling of bitstrings.

Parameters:
  • circuits (tuple[Circuit, ...]) – One of more circuit objects.

  • parameter_values (tuple[tuple[float, ...], ...]) – Parameters to be bound to the circuit.

  • run_options – Backend runtime options used for circuit execution.

Returns:

The job object of the result of the sampler. The i-th result corresponds to circuits[i] evaluated with parameters bound as parameter_values[i].

Raises:

ValueError – Invalid arguments are given.

class qlauncher.routines.cirq.CirqSamplerV2[source]#

Bases: BaseSamplerV2

run(pubs: Iterable[QuantumCircuit | Tuple[QuantumCircuit] | Tuple[QuantumCircuit, Mapping[Parameter | str | Tuple[Parameter | str, ...], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]]] | Tuple[QuantumCircuit, Mapping[Parameter | str | Tuple[Parameter | str, ...], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], Integral | None]], *, shots: int | None = None) BasePrimitiveJob[PrimitiveResult[SamplerPubResult], Any][source]#

Run and collect samples from each pub.

Parameters:
  • pubs (Iterable[QuantumCircuit | Tuple[QuantumCircuit] | Tuple[QuantumCircuit, Mapping[Parameter | str | Tuple[Parameter | str, ...], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]]] | Tuple[QuantumCircuit, Mapping[Parameter | str | Tuple[Parameter | str, ...], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], Integral | None]]) – An iterable of pub-like objects. For example, a list of circuits or tuples (circuit, parameter_values).

  • shots (int | None) – The total number of shots to sample for each sampler pub that does not specify its own shots. If None, the primitive’s default shots value will be used, which can vary by implementation.

Returns:

The job object of Sampler’s result.

Return type:

BasePrimitiveJob[PrimitiveResult[SamplerPubResult], Any]

class qlauncher.routines.cirq.CirqBackend(name: Literal['local_simulator'] = 'local_simulator', error_mitigation_strategy: CircuitExecutionMethod | None = None)[source]#

Bases: GateCircuitBackend[Circuit]

Parameters:

Backend (_type_) – _description_

basis_gates: list[str] = ['x', 'y', 'z', 'cx', 'h', 'rx', 'ry', 'rz']#
static to_qasm(circuit: Circuit) str[source]#
static from_qasm(qasm: str) Circuit[source]#
sample_circuit(circuit: Circuit, shots: int = 1024) dict[str, int][source]#
estimate_energy(circuit: QuantumCircuit, observable: SparsePauliOp) float[source]#
compatible_circuit#

alias of Circuit