quri_parts.qiskit.backend.primitive module#

class QiskitRuntimeSamplingResult(qiskit_result)#

Bases: SamplingResult

Class for the results by Qiskit sampler job.

Parameters:

qiskit_result (SamplerResult) –

property counts: backend.SamplingCounts#

Measurement counts obtained by a sampling measurement.

class QiskitRuntimeSamplingJob(qiskit_job)#

Bases: SamplingJob

A job for a Qiskit sampling measurement.

Parameters:

qiskit_job (RuntimeJob) –

result()#

Returns the result of the sampling job.

If the job is not complete, this method waits until the job finishes.

Return type:

SamplingResult

class QiskitRuntimeSamplingBackend(backend, service=None, circuit_converter=<function convert_circuit>, circuit_transpiler=None, enable_shots_roundup=True, qubit_mapping=None, sampler_options=None, run_kwargs={}, save_data_while_sampling=False, total_time_limit=None, single_job_max_execution_time=None, strict_time_limit=False)#

Bases: SamplingBackend

A Qiskit backend for a sampling measurement.

Parameters:
  • backend (IBMBackend) – A Qiskit qiskit_ibm_runtime.ibm_backend that interfaces with IBM quantum backend.

  • service (Optional[QiskitRuntimeService]) – A Qiskit

  • circuit_converter (QiskitCircuitConverter) –

  • circuit_transpiler (Optional[CircuitTranspiler]) –

  • enable_shots_roundup (bool) –

  • qubit_mapping (Optional[Mapping[int, int]]) –

  • sampler_options (Union[None, Options, Dict[str, Any]]) –

  • run_kwargs (Mapping[str, Any]) –

  • save_data_while_sampling (bool) –

  • total_time_limit (Optional[int]) –

  • single_job_max_execution_time (Optional[int]) –

  • strict_time_limit (bool) –

:param qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService: :param that interacts with the Qiskit Runtime service.: :param circuit_converter: A function converting

NonParametricQuantumCircuit to a Qiskit qiskit.circuit.QuantumCircuit.

Parameters:
  • circuit_transpiler (Optional[CircuitTranspiler]) – A transpiler applied to the circuit before running it. QiskitTranspiler 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}.

  • sampler_options (Union[None, Options, Dict[str, Any]]) – Options for providing sampler. It can be a dictionary or a qiskit_ibm_runtime.Options.

  • 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.

  • total_time_limit (Optional[int]) –

    The total time limit the jobs submitted by this backend can use.

    • A Tracker is created when the time limit is set. The tracker can be accessed by the .tracker attribute.

    • If the job execution time exceeds the time limit, new call to the sample() will be rejected and all current running jobs will be cancelled.

  • single_job_max_execution_time (Optional[int]) – Maximum execution time limit of a submitted (circuit, n_shot) pair. The value should be greater or equal to 300 seconds.

  • strict_time_limit (bool) – The Runtime backend can only abort jobs that has been executed longer than 300 seconds or above. If this option is set to True, the sampling backend will reject jobs whose time limit setting is less than 300 seconds.

  • backend (IBMBackend) –

  • service (Optional[QiskitRuntimeService]) –

  • circuit_converter (QiskitCircuitConverter) –

close()#

Close the IBM session.

This will terminate all unfinished jobs.

Return type:

None

sample(circuit, n_shots)#

Perform a sampling measurement of a circuit.

Parameters:
Return type:

SamplingJob

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.