mqt.qecc.cococo.circuit_construction¶
Misc functions for plotting and Benchmarking.
Functions¶
|
Creates a sequential circuit with j gates per layer on q qubits with at least num_gates in total. |
|
Circuits with maximally parallelizable layers, i.e. per layer, ALL qubits are used in disjoint gates. |
|
Circuits which have nearly no parallelism at all. |
|
Random CNOT Pairs. Optional: random T gates. |
Module Contents¶
- create_random_sequential_circuit_dag(j: int, q: int, num_gates: int, seed: int = 45) tuple[DAGCircuit, list[tuple[int, int]]][source]¶
Creates a sequential circuit with j gates per layer on q qubits with at least num_gates in total.
takes layers from perspective of DAG into account
- generate_max_parallel_circuit(q: int, min_depth: int, seed: int = 45) list[tuple[int, int]][source]¶
Circuits with maximally parallelizable layers, i.e. per layer, ALL qubits are used in disjoint gates.
CNOTS only. To make it less arbitrary, you should choose min depth to be a multiple of q, i.e. s*q, s.t. you get 2s layers Otherwise, the last layer might be a bit empty.
- generate_min_parallel_circuit(q: int, min_depth: int, layer_size: int, seed: int = 45) list[tuple[int, int]][source]¶
Circuits which have nearly no parallelism at all.
CNOTS only. One could enforce that each consecutive gate shares one qubit with the one before, but then there would be NO parallelism at all and then, the hc and routing would trivially have no benefit and no parallelism. Hence, choose a layer_size, maybe 2 or 3 which ensures that there are max. 2 or 3 gates per layer until a qubit is shared again.
- generate_random_circuit(q: int, min_depth: int, tgate: bool = False, ratio: float = 0.5, seed: int = 45) list[tuple[int, int] | int][source]¶
Random CNOT Pairs. Optional: random T gates.
makes it deep enough that each qubit is used at least once min_depth is the minimum number of gates circuit = set of terminal pairs the labeling does not yet follow the labels of a networkx.Graph but only range(q).
Note: min_depth should in principle be larger than q.
- Parameters:
q (int) – number of qubits of the circuit
min_depth (int) – minimal number of gates
tgate (bool, optional) – whether t gates are included or not Defaults to False.
ratio (float, optional) – ratio between t gates and cnots. more t gates if smaller than 0.5. note that the ratio is not deterministically fixed, only determines probabilities. Defaults to 0.5. ratio = num_cnots/(num_t + num_cnots)
seed (int) – seed for generation
- Returns:
random circuit of cnot gates and t gates.
- Return type: