quri_parts.openfermion.transforms package#
- quri_parts.openfermion.transforms.OpenFermionQubitOperatorMapper#
Interface for a function that maps a
openfermion.ops.FermionOperator
,openfermion.ops.InteractionOperator
oropenfermion.ops.MajoranaOperator
to aOperator
.alias of
Callable
[[Union
[FermionOperator
,InteractionOperator
,MajoranaOperator
]],Operator
]
- class quri_parts.openfermion.transforms.OpenFermionQubitMapping(*args, **kwargs)#
Bases:
FermionQubitMapping
,Protocol
Mapping from Fermionic operators and states to :class:`Operator`s and states using OpenFermion.
- abstract get_of_operator_mapper(n_spin_orbitals: int | None = None, n_fermions: int | None = None) Callable[[FermionOperator | InteractionOperator | MajoranaOperator], Operator] #
Returns a function that maps an OpenFermion
FermionOperator
,InteractionOperator
orMajoranaOperator
to aopenfermion.ops.QubitOperator
.- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits. Some mappings require this argument (e.g.
OpenFermionSymmetryConservingBravyiKitaev
) while others calculate it automatically when omitted.n_fermions – When specified, restrict the mapping to a subspace spanned by states containing the fixed number of Fermions. Some mappings require this argument (e.g.
OpenFermionSymmetryConservingBravyiKitaev
) while the others ignore it.
- get_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None) Callable[[Collection[int]], ComputationalBasisState] #
Returns a function that maps occupied spin orbital indices to a computational basis state of qubits.
- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits.
n_fermions – When specified, restrict the mapping to a subspace spanned by states containing the fixed number of Fermions. Some mappings require this argument (e.g. symmetry-conserving Bravyi-Kitaev transformation) while the others ignore it.
- get_inv_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None, n_up_spins: int | None = None) Callable[[ComputationalBasisState], Collection[int]] #
Returns a function that maps a computational basis state of qubits to the set of occupied spin orbital indices.
- Parameters:
n_spin_orbitals – The number of spin orbitals.
n_fermions – The number of fermions considered when the qubit state is mapped. Some mappings require this argument (e.g. symmetry-conserving Bravyi-Kitaev transformation) while the others ignore it.
n_up_spins – The number of spin-up electrons.
- class quri_parts.openfermion.transforms.OpenFermionJordanWigner#
Bases:
JordanWigner
,OpenFermionQubitMapping
Jordan-Wigner transformation using OpenFermion.
- get_of_operator_mapper(n_spin_orbitals: int | None = None, n_fermions: int | None = None) Callable[[FermionOperator | InteractionOperator | MajoranaOperator], Operator] #
Returns a function that maps a
FermionOperator
,InteractionOperator
orMajoranaOperator
to aopenfermion.ops.QubitOperator
with Jordan-Wigner transformation.Both the arguments (
n_spin_orbitals
andn_fermions
) are ignored since the mapping does not depend on them.
- get_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None) Callable[[Collection[int]], ComputationalBasisState] #
Returns a function that maps occupied spin orbital indices to a computational basis state of qubits with Jordan-Wigner transformation.
- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits.
n_fermions – This argument is ignored since the mapping does not depend on it.
- class quri_parts.openfermion.transforms.OpenFermionBravyiKitaev#
Bases:
BravyiKitaev
,OpenFermionQubitMapping
Bravyi-Kitaev transformation using OpenFermion.
- get_of_operator_mapper(n_spin_orbitals: int | None = None, n_fermions: int | None = None) Callable[[FermionOperator | InteractionOperator | MajoranaOperator], Operator] #
Returns a function that maps a
FermionOperator
,InteractionOperator
orMajoranaOperator
to aopenfermion.ops.QubitOperator
with Bravyi-Kitaev transformation.- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits. When omitted, it is automatically calculated from the largest orbital index contained in the operator.
n_fermions – This argument is ignored since the mapping does not depend on it.
- get_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None) Callable[[Collection[int]], ComputationalBasisState] #
Returns a function that maps occupied spin orbital indices to a computational basis state of qubits with Bravyi-Kitaev transformation.
- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits.
n_fermions – This argument is ignored since the mapping does not depend on it.
- class quri_parts.openfermion.transforms.OpenFermionSymmetryConservingBravyiKitaev#
Bases:
SymmetryConservingBravyiKitaev
,OpenFermionQubitMapping
Symmetry-conserving Bravyi-Kitaev transformation described in arXiv:1701.08213, using OpenFermion.
Note that in this mapping the spin orbital indices are first reordered to all spin-up orbitals, then all spin-down orbitals. Bravyi-Kitaev transoformation is applied after the reordering and then two qubits are dropped using conservation of particle number and spin.
Any operators which don’t have particle number and spin symmetry are converted to Operator(), whose expectation value is zero for all states.
- get_of_operator_mapper(n_spin_orbitals: int | None = None, n_fermions: int | None = None) Callable[[FermionOperator | InteractionOperator | MajoranaOperator], Operator] #
Returns a function that maps a
FermionOperator
,InteractionOperator
orMajoranaOperator
to aopenfermion.ops.QubitOperator
with symmetry-conserving Bravyi-Kitaev transformation.Both the arguments (
n_spin_orbitals
andn_fermions
) are required.
- get_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None) Callable[[Collection[int]], ComputationalBasisState] #
Returns a function that maps occupied spin orbital indices to a computational basis state of qubits with symmetry-conserving Bravyi- Kitaev transformation.
- Parameters:
n_spin_orbitals – The number of spin orbitals to be mapped to qubits.
n_fermions – Restrict the mapping to a subspace spanned by states containing the fixed number of Fermions. This argument is required.
- get_inv_state_mapper(n_spin_orbitals: int, n_fermions: int | None = None, n_up_spins: int | None = None) Callable[[ComputationalBasisState], Collection[int]] #
Returns a function that maps a computational basis state of qubits to the set of occupied spin orbital indices.
- Parameters:
n_spin_orbitals – The number of spin orbitals.
n_fermions – The number of fermions considered when the qubit state is mapped. Some mappings require this argument (e.g. symmetry-conserving Bravyi-Kitaev transformation) while the others ignore it.
n_up_spins – The number of spin-up electrons.