Release Notes¶
Upcoming release (327/merge)¶
New Features¶
Added a C API for the edge-vertex and transfer-vertex operator representations, which were previously available only from Python. This includes two new opaque structs,
QfEdgeVertexOperatorandQfTransferVertexOperator, each one with an equivalent set of functions to the existing operator structs.Both operators store two parallel index arrays,
left_indicesandright_indices, in place of the singlemodesarray the Majorana operator uses. Because a generator is always identified by exactly one(left, right)pair, the two arrays necessarily have the same length and the constructors therefore take a singlenum_indicesargument covering both.
Added
qf_edge_op_canonical_orderandqf_transfer_op_canonical_order, along with the commutator, anti-commutator and double-commutator functions for both new operator types (qf_edge_op_commutatorand friends).
Added C API functions for the edge-vertex and transfer-vertex mappers:
qf_edge_vertex_to_fermion(),qf_edge_vertex_to_majorana(),qf_transfer_vertex_to_fermion(),qf_transfer_vertex_to_majorana(), andqf_transfer_vertex_to_edge_vertex().
How an
Evolutiongate gets decomposed in fermionic space is now configurable through its new keyword-onlysynthesisargument, mirroring thesynthesisargument of Qiskit’sPauliEvolutionGate. The available methods live in the newqiskit_fermions.circuit.library.synthesismodule, which provides theFermionicEvolutionSynthesisinterface and its first-orderFermionicLieTrotterimplementation.This fermion-to-fermion step is optional: an
Evolutiongate can be handed straight to the fermion-to-qubit stage regardless of how many terms its operator holds. Decomposing it beforehand is a choice, taken to obtain cheaper factors or to expose structure (such as mutually commutinggroups) that the later stage can exploit. Because both sides of the rewrite stay in fermionic space, that structure survives it, which is what these methods can exploit and Qiskit’sEvolutionSynthesiscannot.The default is unchanged: leaving
synthesisatNoneusesFermionicLieTrotter, which reproduces exactly the decomposition thatEvolutionperformed before, so existing circuits synthesize identically.
Improved the numerical conditioning of state-vector simulation for
EvolutionandOrbitalRotationgates by supplying the exact fixed-sector operator trace to SciPy’s matrix exponential routine.
Added
FermionicSuzukiTrotter, a higher-order product formula for decomposing anEvolutiongate in fermionic space. WhereFermionicLieTrotterapplies each factor once, this composes them symmetrically to cancel lower-order error terms, and itsrepsargument divides the evolution into several shorter steps:Evolution(num_modes, operator, time=1.0, synthesis=FermionicSuzukiTrotter(order=2, reps=4))
Because it operates on the fermionic operator, it splits it along its
groupswhere they are assigned – a partition that is no longer available to a product formula applied after the fermion-to-qubit mapping. On a six-mode Fermi-Hubbard chain grouped into three flow sets,order=2withreps=4reached a Trotter error roughly two times lower than a second-order qubit-side formula, at slightly fewer two-qubit gates.FermionicLieTrotteris the first-order member of this family and is now implemented as such, which also gives it therepsargument it previously lacked. The two are interchangeable at equalreps.Note that a higher order buys accuracy with depth: an order-
kformula emits roughly5**((k-2)/2)times as many factors as an order-2 one. Note also that the accuracy of a decomposed circuit is governed by the weaker of the fermionic and the fermion-to-qubit formula, so raising the order here while the latter stays first-order buys little.
Added
FermionicTrotterization, a transpiler pass that selects the fermion-to-fermion synthesis method of everyEvolutiongate in a circuit:pm.optimization = FermionicPassManager( [FermionicTrotterization(FermionicSuzukiTrotter(order=2, reps=4))] )
Choosing a synthesis method per gate means threading it through everything that constructs an
Evolution– includingUCCandUCJ, which build their own internally. This pass makes the choice once for a whole pipeline instead. An optionalfilterpredicate restricts it to a subset of the gates, which is worth using when a circuit mixes evolutions that benefit from a higher order with ones that do not, such as the all-commuting diagonal-Coulomb operators of aUCJ.The pass selects a method rather than expanding the evolution immediately, so each
Evolutionstays a single node for the passes that follow – notablyRelabelModes, which needs whole operators to build its mode-relabeling model. This is the opposite choice fromQDriftTrotterization, whose random one-shot sampling cannot be deferred.
Added direct Jordan-Wigner mappers for the three remaining operator data structures:
majorana_jordan_wigner(),edge_vertex_jordan_wigner()andtransfer_vertex_jordan_wigner().
jordan_wigner()now dispatches on all four operator types rather than onlyFermionOperator, delegating to whichever direct implementation matches the operator it is given. Passing one of the other three operator types previously raised aTypeError.
Added the same three mappers to the C API, alongside the existing
qf_ferm_op_jordan_wigner():qf_maj_op_jordan_wigner(),qf_edge_op_jordan_wigner()andqf_transfer_op_jordan_wigner().
The
is_hermitian()method is now part of theOperatorTraitprotocol. Every operator class already provided it, so it can now be called on any value typed as anOperatorTraitrather than only on a concrete operator class.Note that the strength of this check varies by operator type, which the protocol documents as its weakest guarantee: a
Trueresult is always reliable, while aFalseresult is conservative for operator types whose normal form is not a genuine canonical form. Seeis_hermitian()for the one such case.
Added two adapters that wrap a mapper function to control the Pauli term order it produces, which
MapperFnEvolutionSynthesisnow preserves through synthesis.simplify()simplifies the mapped operator, merging duplicate Pauli terms and pinning a canonical term order.group_wise()maps an operator onegroupsentry at a time and sums the results. The operator is unchanged, but the terms of each group come out adjacent rather than interleaved, which lets those acting on disjoint qubits share a circuit layer:MapperFnEvolutionSynthesis(group_wise(jordan_wigner))
Evolutioncan now be simulated for any operator type of this package, not onlyFermionOperator. An operator of another type is converted through its fermionic image (theSupportsFermionOperatorprotocol) before being simulated, so evolving aMajoranaOperator,EdgeVertexOperatororTransferVertexOperatorno longer raisesNotImplementedError.
FermionOperatornow implementsffsim.SupportsTracethrough a newSupportsTraceprotocol, soffsim.trace()can compute the trace of an operator on a fixed(norb, nelec)sector. This is what preconditionsscipy.sparse.linalg.expm_multiply()along the evolution path.
Upgrade Notes¶
The
qiskit_fermions.linalg.apply_unitaryandqiskit_fermions.linalg.linear_operatorfunctions have been removed. They were thin wrappers around theSupportsApplyUnitaryandSupportsLinearOperatorprotocol methods, duplicatingffsim.apply_unitary()andffsim.linear_operator(). Call ffsim’s functions instead, or, when ffsim is not installed, the protocol method on the object directly:# before from qiskit_fermions.linalg import apply_unitary, linear_operator vec = apply_unitary(vec, gate, norb, nelec) linop = linear_operator(operator, norb, nelec) # after (with ffsim) vec = ffsim.apply_unitary(vec, gate, norb=norb, nelec=nelec) linop = ffsim.linear_operator(operator, norb=norb, nelec=nelec) # after (without ffsim) vec = gate._apply_unitary_(vec, norb, nelec, copy=True) linop = operator._linear_operator_(norb, nelec)
The protocols themselves are unchanged.
The
simulationoptional dependency has been renamed toffsim, sopip install "qiskit-fermions[simulation]"becomespip install "qiskit-fermions[ffsim]". The extra names the dependency it installs rather than a capability. Installingqiskit-fermions[all]is unaffected.
MapperFnEvolutionSynthesisno longer simplifies the operator returned by itsmapper_fn. Simplifying sorts the Pauli terms into a canonical order, and a product formula synthesizes them in the order it receives them, so the previous behavior discarded whatever order the mapper had chosen.This changes the synthesized circuit for existing pipelines: the gate count is unaffected, but the order the rotations are emitted in (and hence the two-qubit depth) may differ. The evolution being approximated is unchanged.
Note also that the term order a mapper produces is not guaranteed to be stable between runs, because the operators of the Rust core do not preserve the order their terms were added in. Wrap the mapper in the new
simplify()to restore the previous behavior and pin a canonical order:MapperFnEvolutionSynthesis(simplify(jordan_wigner))
The double factorization utilities have been removed from
qiskit_fermions.linalg:double_factorized_t2,double_factorized_t2_alpha_beta,reconstruct_t2,reconstruct_t2_alpha_betaanddouble_factorized_2body. Thet2variants existed to serveUCJ.from_t_amplitudes, which now lives in ffsim, anddouble_factorized_2bodyhad no caller. Useffsim.linalg.double_factorized_t2(),ffsim.linalg.double_factorized_t2_alpha_beta()andffsim.linalg.double_factorized()instead; the last is a superset of the removed two-body routine, additionally offering an optimized (optimize=True) decomposition.givens_decomposition()andgivens_decomposition_slater()are unaffected: they backOrbitalRotationandPrepareSlaterDeterminantsynthesis and remain ffsim-independent, as does the native FCI kernel behindSupportsLinearOperator.
Simulation now requires ffsim. The native Rust FCI (full configuration interaction) kernel that used to back
SupportsLinearOperatorhas been removed, andSupportsLinearOperator._linear_operator_()is now implemented by converting aFermionOperatorinto anffsim.FermionOperatorand delegating toffsim.linear_operator().Simulation is ffsim’s concern: this package focuses on fermionic mappers and the mapper-agnostic circuit and its transpilation. Because ffsim depends on PySCF, which does not support Windows, simulation is consequently unavailable on Windows; the rest of the package (building operators, mapping them and transpiling the resulting circuits) is unaffected on every platform. Windows users who need to simulate can do so through the Windows Subsystem for Linux.
Calling a simulation entry point without ffsim installed now raises
MissingOptionalLibraryError.
The
qiskit_fermions.linalg.fcimodule has been removed along with the kernel, including itsFciLinearOperatorclass and theslater_determinant_statevectorandoccupation_axis_maskfunctions. ffsim provides equivalents:ffsim.slater_determinant()andffsim.addresses_to_strings()respectively.
OrbitalRotationno longer falls back to a generator-plus-exponential path when ffsim is absent; it always delegates toffsim.apply_orbital_rotation(). The results are unchanged when ffsim is installed.
An operator that does not conserve particle number, or the z-component of spin in the spinful case, is now rejected by ffsim rather than by this package’s own check, so the
ValueErrorthatEvolutionsurfaces when simulating one carries a different message.
The
UCCgate is now constructed from one of ffsim’s UCCSD operators, which is its only constructor argument. The spin variant and the number of modes are read off that operator, so thevariantargument and theUCC.Variantenum are gone:# before ansatz = UCC("restricted", t1, t2) # after ansatz = UCC(ffsim.UCCSDOpRestrictedReal(t1=t1, t2=t2))
Accordingly,
UCC.from_t_amplitudes,UCC.num_parameters,UCC.from_parametersandUCC.to_parametershave been removed, as have thespinlessvariant and the opt-inantisymmetricparameterization, which have no ffsim equivalent. ffsim’s operators providen_params(),from_parameters()andto_parameters()with identical conventions. To build an ansatz outside that family (a spinless one, or an antisymmetrized \(t_2\)), construct anEvolutionover your own cluster operator directly, which also gives you control over the Trotter ordering of its terms.The wrapped operator is available as
UCC.uccsd_op, so its amplitudes are reachable asgate.uccsd_op.t1andgate.uccsd_op.t2; the gate no longer mirrors them as attributes of its own.UCC.cluster_operator()is unchanged. Afinal_orbital_rotationcarried by the ffsim operator is now appended as a closingOrbitalRotation.Since ffsim is now the gate’s input type rather than an optional accelerator, constructing a
UCCrequires theffsimextra (pip install "qiskit-fermions[ffsim]") and raisesMissingOptionalLibraryErrorwithout it. ffsim does not support Windows, so the gate is unavailable there; use WSL.
The
UCJgate is now constructed from one of ffsim’s UCJ operators, which is its only constructor argument. The spin variant, the number of spatial orbitals and the number of modes are read off that operator, so thevariantargument and theUCJ.Variantenum are gone:# before ansatz = UCJ.from_t_amplitudes(nelec, t2, t1=t1, n_reps=2) ansatz = UCJ("balanced", diag_coulomb_mats, orbital_rotations) # after ansatz = UCJ(ffsim.UCJOpSpinBalanced.from_t_amplitudes(t2, t1=t1, n_reps=2)) ansatz = UCJ(ffsim.UCJOpSpinBalanced(diag_coulomb_mats, orbital_rotations))
Accordingly,
UCJ.from_t_amplitudes,UCJ.num_parameters,UCJ.from_parametersandUCJ.to_parametershave been removed: ffsim’s operators providefrom_t_amplitudes(),n_params(),from_parameters()andto_parameters()with identical conventions, and additionally offer the compressed (optimize=True) double factorization andfrom_cisd_vec(), which this package never implemented. The wrapped operator is available asUCJ.ucj_op, so its tensors are reachable asgate.ucj_op.diag_coulomb_matsand so on; the gate no longer mirrors them as attributes of its own.Since ffsim is now the gate’s input type rather than an optional accelerator, constructing a
UCJrequires theffsimextra (pip install "qiskit-fermions[ffsim]") and raisesMissingOptionalLibraryErrorwithout it. ffsim does not support Windows, so the gate is unavailable there; use WSL.
Bug Fixes¶
Fixed the excessive memory consumption of
fermion_jordan_wigner()(and therefore ofjordan_wigner()when applied to aFermionOperator). The mapper accumulated the mapped terms using an addition that concatenates rather than merges duplicate Pauli terms, so the intermediate observable grew with the number of Pauli terms emitted instead of the number of distinct ones. Mapping a large Hamiltonian could therefore exhaust the available memory even though the simplified result was orders of magnitude smaller. The accumulators are now canonicalized once they have grown by a factor over their previously merged size, which bounds the memory they hold in terms of the operator they actually represent.Peak memory still grows with the number of worker threads: the terms are handed to whichever thread is free rather than partitioned by the Pauli strings they produce, so each accumulator ends up holding roughly a full copy of the mapped operator. What changed is the factor each one carries – previously proportional to the number of Pauli terms emitted, now to the number of distinct ones. Reducing the thread count through rayon’s
RAYON_NUM_THREADSenvironment variable therefore lowers the peak, roughly in proportion, and is the control to reach for when memory is tight.The mapped operator is unchanged: canonicalization only merges duplicate terms, so the result represents exactly the same observable as before.
fermion_jordan_wigner()no longer copies the operator it is given. The Python binding took its argument by value, which duplicated every term buffer of the inputFermionOperatorpurely in order to read it.
Fixed a decomposition of the
Evolutiongate that never terminated. The evolution of a single operator term used to decompose into an identical single-termEvolution, so repeated expansion made no progress. Most visibly this madeinverse()raise aRecursionError, since it recurses through the gate’s definition.A factor emitted by a
FermionicEvolutionSynthesisis now markedEvolution.atomicand is left in place bydecompose()instead of being expanded again. Decomposing anEvolutionrepeatedly therefore reaches a fixed point.
Fixed
decompose()producing non-unitary factors when applied more than twice to an operator carrying groups. Each group was split further, term by term, but an individual term is generally not Hermitian even when the group containing it is – the conjugate pairs of aUCCcluster generator being the motivating example. The exponential of such a factor is not unitary.The fermion-to-qubit stage rejected those factors with a
ValueErrorabout complex coefficients, but state-vector simulation applied them without complaint and returned a non-normalized state. Since a group is now atomic, the split that produced them no longer happens.
Evolution.inverse()is now implemented directly, returning anEvolutionthat evolves the same operator for the negated time and preserves the gate’ssynthesismethod. Previously the inherited implementation recursed through the gate’s definition and returned a plainGate, discarding both the operator and the synthesis method.
0.1.0¶
Prelude¶
This is the first release of Qiskit Fermions, an extension of Qiskit with tools for fermionic systems. It provides operator data structures, a framework and library for converting those operators to qubit form (mappers), and a framework and library for synthesizing the corresponding quantum circuits. Following Qiskit’s design philosophy, the core of this package is written in Rust and exposed through first-party bindings for both Python and C.