dqcnac.compiler.gate_grouping module
Gate grouping module.
- class dqcnac.compiler.gate_grouping.GateGrouping(circuit: qiskit.QuantumCircuit, nodes_mapping: Dict[qiskit.circuit.Qubit, str], network: Network, max_gates_in_a_group: int = 0, check_swaps: bool = False)[source]
Bases:
objectThis class checks for gates that could share an EPR pair and groups them together
- __init__(circuit: qiskit.QuantumCircuit, nodes_mapping: Dict[qiskit.circuit.Qubit, str], network: Network, max_gates_in_a_group: int = 0, check_swaps: bool = False)[source]
Initializes the class with the parameters given
- Parameters:
circuit (QuantumCircuit) – Quantum circuit to be compiled
nodes_mapping (dict) – Mapping from qubit to nodes
network (Network) – The network configuration
max_gates_in_a_group (int) – The maximum number of gates that can be in a single group
check_swaps (bool) – Whether to check for swaps between gates
- add_gate_in_controlled(ind0: int, reg0: str)[source]
Adds to the list of gates in the working memory that are using the given qubit as control
- Parameters:
ind0 (int) – the index of the qubit
reg0 (str) – the register of the qubit
- add_to_circuit_and_reset(ind: int, reg: str)[source]
Adds the working memory connected to the given qubit to the circuit, and then resets it
- Parameters:
ind (int) – the index of the qubit
reg (str) – the register of the qubit
- as_instruction(working_memory: list[qiskit.circuit.Instruction]) qiskit.circuit.Instruction[source]
Transforms a list of instructions into a single Instruction
- Parameters:
working_memory (list[Instruction]) – The list of instructions to be transformed
- Returns:
The transformed instruction
- can_commute(gate1: qiskit.circuit.CircuitInstruction, gate2: qiskit.circuit.CircuitInstruction) bool[source]
Checks if the given gates are swappable
- Parameters:
gate1 (CircuitInstruction) – the first gate
gate2 (CircuitInstruction) – the second gate
- Returns:
True if the gates are swappable, False otherwise
- static local_op(qargs: Sequence, nodes_mapping) bool[source]
Returns True if the operation is local
- reset_if_max_depth(reg: str, ind: int)[source]
Checks if the working memory is at max depth: if it is, it resets it
- Parameters:
reg (str) – the register of the qubit
ind (int) – the index of the qubit