ket.ibm

Module providing functionality to interact with IBM Quantum and IBM Cloud devices.

Note

This module requires additional dependencies from ket-lang[ibm].

Install with: pip install ket-lang[ibm].

Classes ket.ibm

IBMDevice

IBM Qiskit backend for Ket process.

class IBMDevice(backend: BackendV2 | None = None, *, shots: int | None = None, classical_shadows: dict | None = None, use_qiskit_transpiler: bool = False)

IBM Qiskit backend for Ket process.

The arguments shots and classical_shadows control how the execution is performed for estimating expectation values of an Hamiltonian term. Only one of these arguments can be specified at a time.

If shots is specified, it will run the circuit multiple times (the number of shots) to estimate the expectation values. If classical_shadows is specified, it will use the classical shadows technique for state estimation. The dictionary should be in the format: {"bias": (int, int, int), "samples": int, "shots": int}. The bias tuple represents the bias for the randomized measurements on the X, Y, and Z axes, respectively. The samples is the number of classical shadows to be generated, and shots is the number of shots for each sample.

Parameters:
  • backend – The backend to be used for the quantum execution. If not provided, it defaults to the AerSimulator.

  • use_qiskit_transpiler – Use Qiskit transpiler instead of Ket’s.

  • shots – The number of shots for the execution to estimate the expectation values of an Hamiltonian term. If classical_shadows and shots are not specified, it defaults to 2048.

  • classical_shadows – If specified, it will use the classical shadows technique for state estimation.

clear()

Clear the data to start a new execution.

Warning

This method is called by Libket and should not be called directly.

submit_execution(circuit, parameters)

Get the quantum circuit to execute.

Warning

This method is called by Libket and should not be called directly.

get_result()

Get the result of the quantum circuit execution.

Warning

This method is called by Libket and should not be called directly.

pauli_x(target, control)

Apply a Pauli-X gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

pauli_y(target, control)

Apply a Pauli-Y gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

pauli_z(target, control)

Apply a Pauli-Z gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

hadamard(target, control)

Apply a Hadamard gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

rotation_x(target, control, **kwargs)

Apply a X-Rotation gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

rotation_y(target, control, **kwargs)

Apply a Y-Rotation gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

rotation_z(target, control, **kwargs)

Apply a Z-Rotation gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

phase(target, control, **kwargs)

Apply a Phase gate to the target qubit.

Warning

This method is called by Libket and should not be called directly.

sample(_, qubits, shots)

Sample the qubits.

Warning

This method is called by Libket and should not be called directly.

connect()

Call ket.clib.libket.BatchExecution.configure with the appropriated arguments to generate the quantum execution target.

Warning

This method is called automatically by Process. It is not necessary to call it manually.