QAOAAnsatz

class QAOAAnsatz(local_field=<class 'qiskit.circuit.library.standard_gates.ry.RYGate'>)[source]

Bases: Ansatz

QAOA-style ansatz inspired by Killoran et al. (2020).

Each of the L layers consists of a Hadamard encoding layer followed by a weight Hamiltonian:

  • for n_qubits == 1 — a single local-field rotation;

  • for n_qubits == 2 — one RZZ on the pair, then one local field per qubit (no wrap-around);

  • for n_qubits >= 3RZZ gates on a closed ring (i (i+1) % n), then one local field per qubit.

A trailing Hadamard layer is applied after the L-th weight Hamiltonian. The default local field is RYGate.

Parameters:

local_field (type[Gate]) – Single-qubit rotation used as the local field. Must be one of RXGate, RYGate, RZGate. Defaults to RYGate.

Methods Summary

build(params, n_qubits, n_layers, **kwargs)

Build the QAOA ansatz circuit.

n_params_per_layer(n_qubits, **kwargs)

Per-layer parameter count.

Methods Documentation

build(params, n_qubits, n_layers, **kwargs)[source]

Build the QAOA ansatz circuit.

Parameters:
  • params – Flat parameter array of length n_layers * n_params_per_layer(n_qubits).

  • n_qubits (int) – Number of qubits.

  • n_layers (int) – Number of QAOA layers.

  • **kwargs – Additional unused arguments.

Returns:

Qiskit circuit implementing the QAOA ansatz.

Return type:

QuantumCircuit

static n_params_per_layer(n_qubits, **kwargs)[source]

Per-layer parameter count.

  • n_qubits == 11 (single local-field rotation)

  • n_qubits == 23 (RZZ + one local field per qubit)

  • n_qubits >= 32 * n_qubits (ring of RZZ + per-qubit local field)

Return type:

int