Interface
Generate random circuits, unitary matrices, and test circuit equivalence.
API Reference: qbraid.interface
Generate random circuits
Generate a random quantum circuit object of any registered program type from
qbraid.NATIVE_REGISTRY
. For example:
Optionally specify number of qubits, circuit depth, and whether to measure over all qubits.
Generate random unitaries
Generate random unitary matrices of any specified dimension (dim
):
Check circuit unitary equivalence
Check whether two quantum circuits have equivalent unitary representations, regardless of their types.
All input circuits must be registered in qbraid.programs.NATIVE_REGISTRY
. Below is an example demonstrating
the comparison between two circuits that each create a Bell state using different quantum programming libraries
(Cirq and Qiskit).
This function also supports several optional keyword arguments that allow customization of the equivalence checking process:
index_contig
: If set to True, maps both circuits to use sequential qubit indexing prior to computing their unitaries. Defaults to False.allow_rev_qubits
: If set to True, allows the function to consider circuits as equivalent even if their qubits are in reversed order. Defaults to False.strict_gphase
: If set to False, ignores differences in global phase between the circuits. Defaults to True.atol
: Sets the absolute tolerance level for the numerical comparison of unitaries, using np.allclose. Defaults to 1e-7.
Here are some examples of how these arguments could be used: