qpe_toolbox.circuit.gate_count¶
Functions¶
|
Count quantum gates appearing in a circuit or gate-instruction list. |
|
Estimate the number of SWAP gates required for a gate. |
|
Compute the distance between two qubits. |
|
Group gate counts by the number of qubits they act on. |
Module Contents¶
- qpe_toolbox.circuit.gate_count.count_gates(circ)[source]¶
Count quantum gates appearing in a circuit or gate-instruction list.
Gates are grouped by label, with controlled gates prefixed by
'C'for each control qubit (e.g.'CCX'for a doubly controlled X).An estimate of the number of SWAP gates required to implement the circuit on a 1D nearest-neighbor architecture is also included.
- Parameters:
circ (Circuit, CircuitMPS, or list) – Circuit object or list of gate instructions of the form
(label, params, qubits, controls).- Returns:
Dictionary mapping gate labels to their counts. The key
'SWAP'contains the estimated number of SWAP gates required due to connectivity constraints.- Return type:
Notes
SWAP counting assumes a linear qubit layout with nearest-neighbor connectivity.
For quimb circuits, gate information is extracted from
circ.gates.
- qpe_toolbox.circuit.gate_count.count_swaps(qubits, controls)[source]¶
Estimate the number of SWAP gates required for a gate.
The estimate assumes a 1D nearest-neighbor qubit layout and counts the minimal number of SWAPs required to bring all involved qubits next to a common interaction point.
- Parameters:
- Returns:
Estimated number of SWAP gates required.
- Return type:
Notes
This is a heuristic estimate and does not correspond to an explicit routing algorithm.
- qpe_toolbox.circuit.gate_count.distance_qubits(i, j)[source]¶
Compute the distance between two qubits.
This function defines the qubit connectivity metric and can be customized for different hardware topologies.
- qpe_toolbox.circuit.gate_count.count_gates_by_qb(gate_count)[source]¶
Group gate counts by the number of qubits they act on.
Gates are classified as: -
'1qb': single-qubit gates -'2qb': two-qubit gates (including singly controlled gates) -'3+qb': gates acting on three or more qubits- Parameters:
gate_count (dict) – Dictionary mapping gate labels to counts as produced by
qpe_toolbox.estimation.quantum_phase_estimation.qpe_energy().- Returns:
Dictionary with keys
'1qb','2qb', and'3+qb'.- Return type: