Utils

gateset.DQCPass() BasePass

Transpile a given circuit to the gateset supported by pytket-dqc by calling DQCPass().apply(circuit).

class pytket_dqc.utils.circuit_analysis.ConstraintException(message, server)

Raised when the communication memory constraint of a server is exceeded. Stores the offending server and gate vertex at which the constraint was violated.

circuit_analysis.ebit_memory_required() dict[int, int]

Scan the circuit and find, for each server, the maximum number of ebits simultaneously linked to it. This corresponds to the minimum memory dedicated to ebits this circuit requires.

Parameters:

circ (Circuit) – The circuit to be analysed

Returns:

A dictionary mapping servers to ebit memory required. In particular, dict[2] == 3 means that, at some point in the circuit, there are 3 ebits simultaneously sharing a qubit with server 2.

Return type:

dict[int, int]

utils.ebit_cost() int

Scan the circuit and return the number of ebits required to implement it.

Parameters:

circ (Circuit) – The circuit to be analysed.

Returns:

The number of ebits consumed by the circuit.

Return type:

int

qasm.to_qasm_str()

Return the QASM representation of the circuit, where the starting and ending processes are represented as custom gates.

Parameters:

circ (Circuit) – The circuit in pytket format.

Returns:

The QASM output as a string.

Return type:

str

verification.check_equivalence(circ2: Circuit, qubit_mapping: dict[pytket._tket.circuit.Qubit, pytket._tket.circuit.Qubit]) bool

Use PyZX to check the two circuits are equivalent. This is done by concatenating the ZX diagram of circ1 with the adjoint of the ZX diagram of circ2 to see if the result is the identity.

NOTE: PyZX can be installed via pip install pyzx. You will also need to install pytket-pyzx via pip install pytket-pyzx.

NOTE: returning False does not guarantee that the circuits are different; it just means that PyZX could not prove that they are equivalent. If it returns True and the qubit_mapping covers all qubits of both circuits, then it is guaranteed that the circuits are equivalent. If some qubits are missing from qubit_mapping then there are post-selections/projections to state 0, which means that the test is not a formal proof – we would need to test for projection to state 1 as well (and, in fact, all combinations of 0 and 1). Hence, in the latter case, we can only say “we have strong evidence that the circuits are equivalent”.

Parameters:
  • circ1 (Circuit) – The first of the two circuits to be compared for equality

  • circ2 (Circuit) – The second of the two circuits to be compared for equality

  • qubit_mapping (dict[Qubit, Qubit]) – A mapping from qubits of circ1 to qubits of circ2. If a qubit is not included in this dictionary it means that it ought to be treated as an ancilla (i.e. prepared and measured).

Returns:

Whether the circuits are proven to be equivalent.

Return type:

bool