qxmt.ansatze.pennylane.gete_fabric module

qxmt.ansatze.pennylane.gete_fabric module#

class qxmt.ansatze.pennylane.gete_fabric.GeteFabricAnsatz(device, hamiltonian, n_layers=2, include_pi=False)

Bases: BaseVQEAnsatz

Gate Fabric (GateFabric) ansatz for quantum chemistry calculations.

The GateFabric ansatz is a hardware-efficient variational quantum circuit that employs a structured arrangement of parameterized gates to prepare quantum states for molecular ground state calculations. This ansatz is designed to balance expressibility and trainability while maintaining compatibility with near-term quantum hardware constraints.

The circuit architecture consists of layers of alternating single-qubit rotations and two-qubit entangling gates arranged in a fabric-like pattern. Each layer applies: 1. Parameterized single-qubit rotations (RY gates) on all qubits 2. Controlled entangling operations between neighboring qubits 3. Optional phase gates when include_pi is enabled

The ansatz creates quantum states of the form:

|ψ⟩ = U_fabric^(L)(θ_L) ⋯ U_fabric^(1)(θ_1) |init⟩

where U_fabric^(i) represents the i-th layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).

Key features: - Hardware-efficient design suitable for NISQ devices - Structured gate arrangement optimizing qubit connectivity - Adjustable circuit depth through layer parameter - Built-in initialization from Hartree-Fock state - Support for phase gates to enhance expressibility - Polynomial parameter scaling with system size

Parameters:
  • device (BaseDevice) – Quantum device for executing the variational circuit.

  • hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron, orbital, and geometry information.

  • n_layers (int, optional) – Number of circuit layers. Higher values increase expressibility but also circuit depth and parameter count. Defaults to 2.

  • include_pi (bool, optional) – Whether to include additional phase (π) gates in the circuit. This can enhance expressibility at the cost of increased complexity. Defaults to False.

hamiltonian

Molecular Hamiltonian for the ansatz.

Type:

MolecularHamiltonian

wires

Qubit indices used in the quantum circuit.

Type:

range

n_layers

Number of layers in the circuit architecture.

Type:

int

include_pi

Flag indicating whether π gates are included.

Type:

bool

hf_state

Hartree-Fock reference state for initialization.

Type:

np.ndarray

params_shape

Shape of the parameter tensor for the circuit.

Type:

tuple

n_params

Total number of variational parameters.

Type:

int

Example

>>> from qxmt.hamiltonians.pennylane.molecular import MolecularHamiltonian
>>> from qxmt.devices import BaseDevice
>>>
>>> # Create Hamiltonian and device
>>> hamiltonian = MolecularHamiltonian(...)
>>> device = BaseDevice(...)
>>>
>>> # Initialize GateFabric ansatz with 3 layers and π gates
>>> ansatz = GeteFabricAnsatz(device, hamiltonian, n_layers=3, include_pi=True)
>>>
>>> # Initialize parameters
>>> params = np.random.normal(0, 0.1, ansatz.n_params)
>>>
>>> # Build quantum circuit
>>> ansatz.circuit(params)

References

Note

For optimal performance and stability with automatic differentiation, it is recommended to use ‘parameter-shift’ as the diff_method instead of ‘adjoint’ or ‘best’. The GateFabric operation may not work correctly with adjoint differentiation in some cases due to its complex gate structure.

This ansatz is particularly useful when chemical intuition about excitations is limited or when exploring hardware-efficient implementations for specific quantum devices.

circuit(params)

Construct the GeteFabric quantum circuit.

Parameters:

params (np.ndarray) – Parameters for the GeteFabric circuit. The length of this array should match the number of parameters required by the circuit.

Return type:

None

prepare_hf_state()

Prepare the Hartree-Fock reference state.

This method creates the Hartree-Fock reference state using PennyLane’s qchem module. The Hartree-Fock state is a product state where the first n electrons occupy the lowest energy orbitals.

The state is stored in self.hf_state as a numpy array.

Note

The number of electrons and orbitals are obtained from the Hamiltonian.

Return type:

None