qxmt.ansatze.pennylane.particle_conserving_u1 module#
- class qxmt.ansatze.pennylane.particle_conserving_u1.ParticleConservingU1Ansatz(device, hamiltonian, n_layers=2)
Bases:
BaseVQEAnsatz
Particle-Conserving U(1) ansatz for quantum chemistry calculations.
The ParticleConservingU1 ansatz is a hardware-efficient variational quantum circuit that respects U(1) particle number symmetry, making it particularly well-suited for quantum chemistry applications where particle number conservation is essential. This ansatz provides an excellent balance between expressibility and physical constraints.
The circuit architecture consists of layers of parameterized gates that preserve the total particle number throughout the computation. Each layer contains: 1. Single-qubit rotations that respect particle number conservation 2. Two-qubit gates that maintain the U(1) symmetry 3. Controlled operations that preserve fermion number
The ansatz constructs quantum states of the form:
|ψ⟩ = U_U1^(L)(θ_L) ⋯ U_U1^(1)(θ_1) |init⟩
where U_U1^(i) represents the i-th particle-conserving layer, θ_i are variational parameters, and |init⟩ is the initial state (typically Hartree-Fock).
Key features: - Strict particle number conservation (exact U(1) symmetry) - Hardware-efficient design for NISQ devices - Reduced parameter space due to symmetry constraints - Natural incorporation of physical quantum chemistry constraints - Improved optimization landscape compared to unconstrained ansätze - Compatible with fermionic mappings (Jordan-Wigner, Bravyi-Kitaev)
The U(1) symmetry constraint significantly reduces the parameter space and helps avoid unphysical states during optimization, leading to more stable and efficient variational quantum eigensolvers.
- 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-conserving operations while maintaining U(1) 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 >>> hamiltonian = MolecularHamiltonian(...) >>> device = BaseDevice(...) >>> >>> # Initialize ParticleConservingU1 ansatz with 4 layers >>> ansatz = ParticleConservingU1Ansatz(device, hamiltonian, n_layers=4) >>> >>> # Initialize parameters >>> params = np.random.normal(0, 0.02, ansatz.n_params) >>> >>> # Build quantum circuit (particle number automatically conserved) >>> ansatz.circuit(params)
References
PennyLane documentation: https://docs.pennylane.ai/en/stable/code/api/pennylane.ParticleConservingU1.html
Note
This ansatz is particularly beneficial for systems where particle number conservation is crucial for physical accuracy. The U(1) symmetry constraint reduces the search space and can lead to faster convergence compared to unconstrained variational circuits.
The reduced parameter space makes this ansatz especially suitable for near-term quantum devices with limited coherence times, as it requires fewer optimization steps while maintaining chemical accuracy.
- circuit(params)
Construct the ParticleConservingU1 quantum circuit.
This method builds a quantum circuit that preserves particle number through U(1) 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 ParticleConservingU1 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