qxmt.ansatze.pennylane.particle_conserving_u2 module#
- class qxmt.ansatze.pennylane.particle_conserving_u2.ParticleConservingU2Ansatz(device, hamiltonian, n_layers=2)
Bases:
BaseVQEAnsatz
Particle-Conserving U(2) ansatz for quantum chemistry calculations.
The ParticleConservingU2 ansatz is an advanced hardware-efficient variational quantum circuit that respects both U(1) particle number symmetry and additional U(2) symmetries, providing enhanced physical constraints for quantum chemistry applications. This ansatz extends the U(1) framework by incorporating spin symmetries and additional conservation laws.
The U(2) symmetry group includes: - U(1) particle number conservation (total electron count) - Additional symmetries related to spin and orbital angular momentum - Enhanced preservation of physical quantum chemistry properties
The circuit architecture consists of layers of parameterized gates that preserve both particle number and spin-related quantities. Each layer contains: 1. Single-qubit rotations that respect U(2) symmetry constraints 2. Two-qubit gates that maintain particle and spin conservation 3. Controlled operations preserving fermion number and spin projections
The ansatz constructs quantum states of the form:
|ψ⟩ = U_U2^(L)(θ_L) ⋯ U_U2^(1)(θ_1) |init⟩
where U_U2^(i) represents the i-th particle and spin-conserving layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).
Key features: - Strict particle number and enhanced symmetry conservation - Hardware-efficient design optimized for NISQ devices - Further reduced parameter space compared to U(1) due to additional constraints - Natural incorporation of spin and orbital symmetries - Improved stability and faster convergence in optimization - Enhanced compatibility with molecular symmetries and point groups - Reduced barren plateau effects due to symmetry constraints
The U(2) symmetry constraints provide even tighter control over the variational space, leading to more efficient optimization and better preservation of molecular properties during the quantum computation.
- Parameters:
device (BaseDevice) – Quantum device for executing the variational circuit.
hamiltonian (MolecularHamiltonian) – Molecular Hamiltonian defining the quantum chemistry problem, containing electron configuration, orbital basis, and molecular geometry.
n_layers (int, optional) – Number of circuit layers. Each layer applies particle and spin-conserving operations while maintaining U(2) symmetry. Higher values increase expressibility but also circuit depth. Defaults to 2.
- hamiltonian
Molecular Hamiltonian for the ansatz.
- Type:
MolecularHamiltonian
- n_layers
Number of layers in the circuit architecture.
- Type:
int
- wires
Qubit indices used in the quantum circuit.
- Type:
range
- 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 for molecular system >>> hamiltonian = MolecularHamiltonian(...) >>> device = BaseDevice(...) >>> >>> # Initialize ParticleConservingU2 ansatz with 3 layers >>> ansatz = ParticleConservingU2Ansatz(device, hamiltonian, n_layers=3) >>> >>> # Initialize parameters (smaller values due to tighter constraints) >>> params = np.random.normal(0, 0.01, ansatz.n_params) >>> >>> # Build quantum circuit (particle number and spin automatically conserved) >>> ansatz.circuit(params)
References
PennyLane documentation: https://docs.pennylane.ai/en/stable/code/api/pennylane.ParticleConservingU2.html
Note
This ansatz is particularly beneficial for molecular systems where both particle number and spin conservation are critical. The U(2) symmetry constraints provide the most restrictive parameter space among particle-conserving ansätze, leading to highly stable optimization but potentially requiring more layers for complex molecular systems.
The enhanced symmetry preservation makes this ansatz ideal for systems with specific spin states or when studying spin-dependent properties. It is especially suitable for near-term quantum devices due to its efficient parameter usage and reduced noise sensitivity.
- circuit(params)
Construct the ParticleConservingU2 quantum circuit.
This method builds a quantum circuit that preserves particle number through U(2) symmetry. The circuit applies multiple layers of particle-conserving gates while maintaining the total number of particles (electrons) in the system.
- Parameters:
params (np.ndarray) – Parameters for the ParticleConservingU2 circuit. The length of this array should match the number of parameters required by the circuit (determined by n_layers and number of qubits).
- 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