Gate Cutting to Reduce Circuit Depth
ยังไม่ได้แปล
หน้านี้ยังไม่ได้รับการแปล คุณกำลังดูเวอร์ชันต้นฉบับภาษาอังกฤษ
In this tutorial, we will reduce a circuit's depth by cutting distant gates, avoiding the swap gates that would otherwise be introduced by routing.
These are the steps that we will take in this Qiskit pattern:
- Step 1: Map problem to quantum circuits and operators:
- Map the hamiltonian onto a quantum circuit.
- Step 2: Optimize for target hardware [Uses the cutting addon]:
- Cut the circuit and observable.
- Transpile the subexperiments for hardware.
- Step 3: Execute on target hardware:
- Run the subexperiments obtained in Step 2 using a
Samplerprimitive.
- Run the subexperiments obtained in Step 2 using a
- Step 4: Post-process results [Uses the cutting addon]:
- Combine the results of Step 3 to reconstruct the expectation value of the observable in question.
Step 1: Map
Create a circuit to run on the backend
# Added by doQumentation — required packages for this notebook
!pip install -q numpy qiskit qiskit-addon-cutting qiskit-aer qiskit-ibm-runtime
from qiskit.circuit.library import efficient_su2
circuit = efficient_su2(num_qubits=4, entanglement="circular")
circuit.assign_parameters([0.4] * len(circuit.parameters), inplace=True)
circuit.draw("mpl", scale=0.8)

Specify an observable
from qiskit.quantum_info import SparsePauliOp
observable = SparsePauliOp(["ZZII", "IZZI", "-IIZZ", "XIXI", "ZIZZ", "IXIX"])
Step 2: Optimize
Specify a backend
You can provide either a fake backend or a hardware backend from Qiskit Runtime.
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
backend = FakeManilaV2()
Transpile the circuit, visualize the swaps, and note the depth
We choose a layout that requires two swaps to execute the gates between qubits 3 and 0 and another two swaps to return the qubits to their initial positions.
from qiskit.transpiler import generate_preset_pass_manager
pass_manager = generate_preset_pass_manager(
optimization_level=1, backend=backend, initial_layout=[0, 1, 2, 3]
)
transpiled_qc = pass_manager.run(circuit)
print(f"Transpiled circuit depth: {transpiled_qc.depth(lambda x: len(x.qubits) >= 2)}")
Transpiled circuit depth: 30
transpiled_qc.draw("mpl", scale=0.4, idle_wires=False, fold=-1)

Replace distant gates with TwoQubitQPDGates by specifying their indices
cut_gates will replace the gates in the specified indices with TwoQubitQPDGates and also return a list of QPDBasis instances -- one for each gate decomposition.
from qiskit_addon_cutting import cut_gates
# Find the indices of the distant gates
cut_indices = [
i
for i, instruction in enumerate(circuit.data)
if {circuit.find_bit(q)[0] for q in instruction.qubits} == {0, 3}
]
# Decompose distant CNOTs into TwoQubitQPDGate instances
qpd_circuit, bases = cut_gates(circuit, cut_indices)
qpd_circuit.draw("mpl", scale=0.8)
