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

Summary

Classes

IBMDevice

IBM Qiskit backend for Ket process.

Classes

class IBMDevice(
backend: BackendV2 | None = None,
num_qubits: int | None = None,
gradient: bool = False,
optimization_level: int = 2,
qiskit_compiler=True,
)[source]

Bases: BatchExecution

IBM Qiskit backend for Ket process.

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

  • num_qubits – Maximum number of qubits to use. If not provided, it defaults to the number of qubits supported by the backend.

  • gradient – If True, enables gradient computation for variational algorithms. Defaults to False.

  • optimization_level – The optimization level for the Qiskit pass manager. Higher values apply more aggressive circuit optimizations. Defaults to 2.

  • qiskit_compiler – If True (default), gates are passed to Qiskit’s pass manager for transpilation and optimization before execution. If False, Libket decomposes gates into U/CNOT primitives before sending them to Qiskit.

sample(gates, qubits_to_sample, shots)[source]

Execute the circuit and sample the given qubits.

Warning

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

exp_value(gates, hamiltonian_list)[source]

Execute the circuit and compute expectation values.

Warning

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

connect()[source]

Connect to the device and return the configuration.