qdk_chemistry.algorithms.term_grouper package
Term-grouper algorithms for QubitOperator.
A term grouper takes a QubitOperator and
returns a new one with a populated
term_partition that downstream
algorithms can exploit.
Example
>>> from qdk_chemistry.algorithms import registry
>>> grouper = registry.create("term_grouper", "qubit_wise_commuting")
>>> grouped = grouper.run(my_hamiltonian)
>>> grouped.term_partition # FlatPartition with strategy="qubit_wise_commuting"
- class qdk_chemistry.algorithms.term_grouper.FullCommutingTermGrouper
Bases:
TermGrouperGroup terms by full Pauli commutation (
[P_i, P_j] = 0).The resulting
FlatPartitionstores aQubitOperatorpartition where every pair of terms in the same group commutes globally. Useful for Trotter-style decompositions, which can exponentiate a commuting block as a single ordered product without splitting error.
- class qdk_chemistry.algorithms.term_grouper.IdentityTermGrouper
Bases:
TermGrouperTrivial grouper — every term is placed in its own single-element group.
Useful to clear an existing
term_partitionwhile still passing through the standardterm_grouperinterface, or to disable downstream group-aware optimisation in a controlled way.
- class qdk_chemistry.algorithms.term_grouper.QubitWiseCommutingTermGrouper
Bases:
TermGrouperGroup terms by qubit-wise commutation.
Two labels qubit-wise commute when, on every qubit position, the two single-qubit Paulis individually commute (i.e. one is identity or both are equal). All members of a group can be measured in a single basis, which is the property exploited by
QdkExpectationEstimatorfor measurement-cost reduction.
- class qdk_chemistry.algorithms.term_grouper.TermGrouper
Bases:
AlgorithmAbstract base class for algorithms that partition Hamiltonian terms.
A
TermGrouperconsumes aQubitOperatorand returns a newQubitOperatorwhoseterm_partitionis populated with the grouping computed by the strategy.Subclasses implement
_run_impl, which must return a newQubitOperator(the input must not be mutated).- __init__()
Initialise the term grouper with default settings.
- class qdk_chemistry.algorithms.term_grouper.TermGrouperFactory
Bases:
AlgorithmFactoryFactory for
TermGrouperinstances.