qdk_chemistry.data.term_partition module
Term-partition metadata for QubitOperator.
A TermPartition records how the Pauli terms of a
QubitOperator are organised into algorithm-
relevant subsets. Concrete subclasses include FlatPartition
(single-level groups) and LayeredPartition (group → layer
hierarchy).
The partition stores indices into
pauli_strings so that it
serialises trivially and remains small.
Lifecycle
The partition is optional metadata.
term_partition is Nonemeans the partition has not been computed for this Hamiltonian.Transformations that change the term ordering or qubit support (for example
to_interleaved()) must reset the partition toNoneon the new Hamiltonian.Algorithms that consume a partition should treat its presence as an explicit signal to exploit it (for example, by applying schedule-level Suzuki recursion or grouping measurements by basis).
- class qdk_chemistry.data.term_partition.FlatPartition(*, strategy, groups)[source]
Bases:
TermPartitionSingle-level partition: each group is a list of term indices.
Suitable for algorithms that only care about which terms belong together (for example, qubit-wise commuting groups for measurement basis selection).
The
groupsfield is a tuple of groups; each group is a tuple of term indices intopauli_strings.- Raises:
TypeError – If
groupsis not a sequence of sequences of integers.- Parameters:
- class qdk_chemistry.data.term_partition.LayeredPartition(*, strategy, groups)[source]
Bases:
TermPartitionTwo-level partition: each group is a sequence of parallelisable layers.
Suitable for Trotter-style decompositions where the outer level controls Strang/Suzuki splitting order and the inner level groups operators with disjoint qubit supports that can be applied in parallel.
The
groupsfield is a nested tuple(group, layer, term_index): outer = groups, middle = layers within a group, inner = term indices intopauli_strings.- Raises:
TypeError – If
groupsis not the expected nested-sequence shape.- Parameters:
- class qdk_chemistry.data.term_partition.TermPartition(*, strategy)[source]
Bases:
DataClassBase class for index-based partitions of Hamiltonian terms.
Use
FlatPartitionfor single-level partitions orLayeredPartitionfor hierarchical (group → layer) partitions.The
strategyfield is a free-form label identifying how the partition was produced (for example"geometry_coloring","commuting","qubit_wise_commuting").- Parameters:
strategy (str)
- __init__(*, strategy)[source]
Initialize the term partition.
- Parameters:
strategy (str) – Label identifying how the partition was produced.
- Return type:
None
- static from_json(data)[source]
Reconstruct a
TermPartitionfromto_json()output.- Return type:
- Parameters:
data (dict[str, Any]) – Dict produced by
to_json()of eitherFlatPartitionorLayeredPartition.- Returns:
The reconstructed partition.
- Raises:
ValueError – If
data["kind"]is not a recognised partition kind.
- classmethod from_hdf5(group)[source]
Load a
TermPartitionfrom an HDF5 group.- Return type: