qdk_chemistry.plugins.openfermion.qubit_mapper module
OpenFermion-based qubit mappers to map electronic structure Hamiltonians to qubit operators.
This module provides an OpenFermionQubitMapper class to convert Hamiltonians to QubitHamiltonians
using different mapping strategies. The encoding is determined by the MajoranaMapping passed
to run().
- class qdk_chemistry.plugins.openfermion.qubit_mapper.OpenFermionQubitMapper[source]
Bases:
QubitMapperMap an electronic structure Hamiltonian to a QubitOperator using OpenFermion.
This is a third-party backend: it reads
mapping.base_encodingto select the corresponding OpenFermion transform function and ignoresmapping.table. The qubit operator is built from scratch using OpenFermion’s own fermion-to-qubit pipeline.Warning
Because this backend chooses its transform by encoding name rather than from the Pauli table, it relies on the mapping’s
base_encodingstring being consistent with its table. This is guaranteed for factory-produced mappings (MajoranaMapping.jordan_wigner(),.bravyi_kitaev(), etc.) and is verified by cross-backend eigenvalue tests in the test suite. Manually built mappings with mismatched names will produce silently incorrect results.Tapering-based encodings (e.g. symmetry-conserving Bravyi-Kitaev) are supported — each backend handles tapering in its own
_run_impl()via theQubitMapper._taper_result()helper.Both restricted (RHF) and unrestricted (UHF) Hamiltonians are supported. For unrestricted systems, separate alpha/beta spin channels are handled via
hamiltonian_to_interaction_operator.- Supported base encodings:
"jordan-wigner"→openfermion.transforms.jordan_wigner"bravyi-kitaev"→openfermion.transforms.bravyi_kitaev"bravyi-kitaev-tree"→openfermion.transforms.bravyi_kitaev_tree
Examples
>>> from qdk_chemistry.algorithms import create >>> from qdk_chemistry.data import MajoranaMapping >>> mapper = create("qubit_mapper", "openfermion") >>> mapping = MajoranaMapping.jordan_wigner(num_modes=n_spin_orbitals) >>> qh = mapper.run(hamiltonian, mapping)
- class qdk_chemistry.plugins.openfermion.qubit_mapper.OpenFermionQubitMapperSettings[source]
Bases:
QubitMapperSettingsSettings configuration for an OpenFermionQubitMapper.