Skip to content

Commit

Permalink
change description
Browse files Browse the repository at this point in the history
  • Loading branch information
sabinadragoi committed Nov 23, 2023
1 parent 1acb322 commit e7c3455
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions qopt_best_practices/swap_strategies/build_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,33 @@ def create_qaoa_swap_circuit(
mixer: QuantumCircuit = None,
):
"""
This method can only handle circuits with only 1-qubit or 2-qubit gates, due to the limitation in the function `apply_swap_strategy`, which can only handle 2-qubit gates. Given this constraint, we still have to treat the 1-qubit gates and 2-qubit gates separately. Suppose H = H1 + H2, where H1 has only 1-qubit gates, and H2 only 2-qubit gates.
Create the circuit for QAOA.
Notes: This circuit construction for QAOA works for quadratic terms in `Z` as well as
first-order terms in `Z`. Higher-orders are not supported due to the limitation
in the function `apply_swap_strategy`, which can only handle 2-qubit gates.
Given this constraint, we still have to treat the 1-qubit gates and 2-qubit gates separately.
Suppose H = H1 + H2, where H1 has only 1-qubit gates, and H2 only 2-qubit gates.
Strategy is
- create correspponding circuits for both H1 and H2
- `apply_swap_strategy` on the circuit of H2
- combine the two circuits
Args:
cost_operator: the cost operator.
swap_strategy: selected swap strategy
edge_coloring: A coloring of edges that should correspond to the coupling
map of the hardware. It defines the order in which we apply the Rzz
gates. This allows us to choose an ordering such that `Rzz` gates will
immediately precede SWAP gates to leverage CNOT cancellation.
num_qubits: the number of qubits
local_correlators: list of paulis
theta: The QAOA angles.
qaoa_layers: The number of layers of the cost-operator and the mixer operator.
initial_state: The initial state on which we apply layers of cost-operator
and mixer.
mixer: The QAOA mixer. It will be applied as is onto the QAOA circuit. Therefore,
its output must have the same ordering of qubits as its input.
swap_strategy: selected swap strategy
random_cut: A random cut, i.e., a series of 1 and 0 with the same length
as the number of qubits. If qubit `i` has a `1` then we flip its
Expand Down

0 comments on commit e7c3455

Please sign in to comment.