GenericLayerAnsatz

class GenericLayerAnsatz(gate_sequence, entangler=None, entangling_layout=None)[source]

Bases: Ansatz

A flexible ansatz alternating single-qubit gates with optional entanglers.

Parameters:
  • gate_sequence (Sequence[type[Gate]]) – Sequence of one-qubit Qiskit Gate subclasses (e.g., RYGate, RZGate).

  • entangler (type[Gate] | None) – Two-qubit Qiskit Gate subclass (e.g., CXGate, CZGate). If None, no entanglement is applied.

  • entangling_layout (Literal['linear', 'brick', 'circular', 'all-to-all'] | Sequence[tuple[int, int]] | None) – Layout for entangling layer (“linear”, “all-to-all”, etc.).

Methods Summary

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

Builds the ansatz circuit and returns a list of operations.

n_params_per_layer(n_qubits, **kwargs)

sum(_gate_n_params(g) for g in gate_sequence) * n_qubits.

Methods Documentation

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

Builds the ansatz circuit and returns a list of operations.

Parameters:
  • params – Parameter array for the ansatz.

  • n_qubits (int) – Number of qubits in the circuit.

  • n_layers (int) – Number of ansatz layers.

  • **kwargs – Additional arguments specific to the ansatz.

Returns:

The ansatz circuit on n_qubits qubits.

Return type:

QuantumCircuit

n_params_per_layer(n_qubits, **kwargs)[source]

sum(_gate_n_params(g) for g in gate_sequence) * n_qubits.

Return type:

int