quri_parts.qiskit.backend.sampling module#
- class QiskitSamplingResult(qiskit_result)#
Bases:
SamplingResult
A result of a Qiskit sampling job.
- Parameters:
qiskit_result (Result) –
- property counts: backend.SamplingCounts#
Measurement counts obtained by a sampling measurement.
- class QiskitSamplingJob(qiskit_job)#
Bases:
SamplingJob
A job for a Qiskit sampling measurement.
- Parameters:
qiskit_job (Job) –
- result()#
Returns the result of the sampling job.
If the job is not complete, this method waits until the job finishes.
- Return type:
- class QiskitSamplingBackend(backend, circuit_converter=<function convert_circuit>, circuit_transpiler=None, enable_shots_roundup=True, qubit_mapping=None, run_kwargs={}, save_data_while_sampling=False)#
Bases:
SamplingBackend
A Qiskit backend for a sampling measurement.
- Parameters:
backend (Backend) – A Qiskit
qiskit.providers.backend.Backend
for circuit execution.circuit_converter (QiskitCircuitConverter) – A function converting
NonParametricQuantumCircuit
to a Qiskitqiskit.circuit.QuantumCircuit
.circuit_transpiler (Optional[CircuitTranspiler]) – A transpiler applied to the circuit before running it.
QiskitSetTranspiler
is used when not specified.enable_shots_roundup (bool) – If True, when a number of shots specified to
sample()
is smaller than the minimum number of shots supported by the device, it is rounded up to the minimum. In this case, it is possible that shots more than specified are used. If it is strictly not allowed to exceed the specified shot count, set this argument to False.qubit_mapping (Optional[Mapping[int, int]]) – If specified, indices of qubits in the circuit are remapped before running it on the backend. It can be used when you want to use specific backend qubits, e.g. those with high fidelity. The mapping should be specified with “from” qubit indices as keys and “to” qubit indices as values. For example, if you want to map qubits 0, 1, 2, 3 to backend qubits as 0 → 4, 1 → 2, 2 → 5, 3 → 0, then the
qubit_mapping
should be{0: 4, 1: 2, 2: 5, 3: 0}
.run_kwargs (Mapping[str, Any]) – Additional keyword arguments for
qiskit.providers.backend.Backend.run()
method.save_data_while_sampling (bool) – If True, the circuit, n_shots and the sampling counts will be saved. Please use the .jobs or .jobs_json to access the saved data.
- sample(circuit, n_shots)#
Perform a sampling measurement of a circuit.
- Parameters:
circuit (NonParametricQuantumCircuit) –
n_shots (int) –
- Return type:
- property jobs: Sequence[QiskitSavedDataSamplingJob]#
Convert saved data to a list of QiskitSavedDataSamplingJob objects.
- property jobs_json: str#
Encodes the list of QiskitSavedDataSamplingJob objects to a json string.