cutqc2.core package¶
Submodules¶
cutqc2.core.cut_circuit module¶
- class cutqc2.core.cut_circuit.CutCircuit(circuit, add_labels=True)[source]¶
Bases:
object
- add_cut(label, wire_index, gate_index)[source]¶
Add a cut to the circuit at the position of the instruction with the specified label. :type label:
str
:param label: The label of the instruction after which the cut should be made. :type wire_index:int
:param wire_index: The index of the wire where the cut should be made.
- cut(max_subcircuit_width, max_cuts, num_subcircuits, max_subcircuit_cuts, subcircuit_size_imbalance, generate_subcircuits=True)[source]¶
- find_cuts(max_subcircuit_width, max_cuts, num_subcircuits, max_subcircuit_cuts, subcircuit_size_imbalance)[source]¶
- static get_initializations(paulis, legacy=True)[source]¶
Get coefficients and kets used for each term in the expansion of the trace operators for each of the Pauli bases (eq. 2 in paper). :rtype:
list
[tuple
[int
,tuple
[str
]]]0 1 + i
0 1 I 1 1 X -1 -1 2 Y -1 -1 2 Z 1 -1
- static get_inter_wire_dag(circuit)[source]¶
Get the dag for the stripped version of a circuit where we only preserve gates that span two wires.
- Return type:
DAGCircuit
- static get_labeled_circuit(circuit)[source]¶
Get a labeled version of the circuit where each instruction is labeled
- Return type:
QuantumCircuit
- property num_cuts: int¶
- property reconstruction_qubit_order: dict[int, list[int]]¶
cutqc2.core.dag module¶
- class cutqc2.core.dag.DAGEdge(first, second)[source]¶
Bases:
object
Represents an edge in a quantum circuit DAG, connecting two DagNodes.
- class cutqc2.core.dag.DagNode(wire_index, gate_index, name='q')[source]¶
Bases:
object
Represents a node in a quantum circuit DAG (Directed Acyclic Graph), corresponding to a specific gate on a specific wire (qubit/register).
Since only inter-wire gates are important for the cut algorithm, any mention of gate_index refers to the index wrt inter-wire gates only.
- wire_index¶
The index of the wire (qubit/register).
- Type:
int
- gate_index¶
The index of the gate on the wire. Note: gate_index assumes that only inter-wire gates are considered.
- Type:
int
- name¶
The name of the node (default ‘q’).
- Type:
str
- classmethod from_string(s)[source]¶
Create a DagNode from a string representation.
- Parameters:
s (str) – The string representation of the node in the format ‘name[wire_index]gate_index’.
- Returns:
The created DagNode instance.
- Return type:
- locate(dag_circuit)[source]¶
Locate the position of the DagNode in the DAGCircuit. :type dag_circuit:
DAGCircuit
:param dag_circuit: The DAGCircuit containing the node. :type dag_circuit: DAGCircuit- Returns:
A tuple containing the Qubit and the index of the gate on that wire.
- Return type:
tuple[Qubit, int]
- Raises:
ValueError – If the node cannot be found in the DAGCircuit.
cutqc2.core.utils module¶
- cutqc2.core.utils.merge_prob_vector(unmerged_prob_vector, qubit_mask)[source]¶
Compress quantum probability vector by merging specified qubits.
- Parameters:
unmerged_prob_vector (numpy.ndarray) – Original probability vector (2^num_qubits,)
qubit_mask (mask specifying which qubits are active (1) and which) – need to get merged (0).
- Returns:
Compressed vector (2^num_active,) preserving active qubit states while summing over merged qubit states.
- Return type:
numpy.ndarray