class pytket.partition.GraphColourMethod

Enum for available methods to perform graph colouring.


Lazy : Does not build the graph before performing the colouring; partitions while iterating through the Pauli tensors in the input order.

LargestFirst : Builds the graph and then greedily colours by iterating through the vertices, with the highest degree first.

Exhaustive : Builds the graph and then systematically checks all possibilities until it finds a colouring with the minimum possible number of colours. Such colourings need not be unique. Exponential time in the worst case, but often runs much faster.

__init__(self: pytket.partition.GraphColourMethod, value: int) None
property name
class pytket.partition.MeasurementBitMap

Maps Pauli tensors to Clifford circuit indices and bits required for measurement. A MeasurementBitMap belongs to a MeasurementSetup object, and dictates which bits are to be included in the measurement. As Clifford circuits may flip the parity of the corresponding Pauli tensor, the MeasurementBitMap optionally inverts the result.

__init__(self: pytket.partition.MeasurementBitMap, circ_index: int, bits: List[int], invert: bool = False) None

Constructs a MeasurementBitMap for some Clifford circuit index and bits, with an option to invert the result.

  • circ_index – which measurement circuit the measurement map refers to

  • bits – which bits are included in the measurement

  • invert – whether to flip the parity of the result

property bits

Bits to measure

property circ_index

Clifford circuit index

property invert

Whether result is inverted or not

class pytket.partition.MeasurementSetup

Encapsulates an experiment in which the expectation value of an operator is to be measured via decomposition into QubitPauliStrings. Each tensor expectation value can be measured using shots. These values are then summed together with some weights to retrieve the desired operator expctation value.

__init__(self: pytket.partition.MeasurementSetup) None

Constructs an empty MeasurementSetup object

add_measurement_circuit(self: pytket.partition.MeasurementSetup, circ: pytket.circuit.Circuit) None

Add a Clifford circuit that rotates into some Pauli basis

add_result_for_term(self: pytket.partition.MeasurementSetup, term: pytket.pauli.QubitPauliString, result: pytket.partition.MeasurementBitMap) None

Add a new Pauli string with a corresponding BitMap

verify(self: pytket.partition.MeasurementSetup) bool

Checks that the strings to be measured correspond to the correct strings generated by the measurement circs. Checks for parity by comparing to the invert flag.


True or False

property measurement_circs

Clifford measurement circuits.

property results

Map from Pauli strings to MeasurementBitMaps

class pytket.partition.PauliPartitionStrat

Enum for available strategies to partition Pauli tensors.


NonConflictingSets : Build sets of Pauli tensors in which each qubit has the same Pauli or Pauli.I. Requires no additional CX gates.

CommutingSets : Build sets of mutually commuting Pauli tensors. Requires O(n^2) CX gates to diagonalise.

__init__(self: pytket.partition.PauliPartitionStrat, value: int) None
property name
pytket.partition.measurement_reduction(strings: List[pytket.pauli.QubitPauliString], strat: pytket.partition.PauliPartitionStrat, method: pytket.partition.GraphColourMethod = GraphColourMethod.Lazy, cx_config: pytket.transform.CXConfigType = CXConfigType.Snake) pytket.partition.MeasurementSetup

Automatically performs graph colouring and diagonalisation to reduce measurements required for Pauli strings.

  • strings – A list of QubitPauliString objects to be partitioned.

  • strat – The PauliPartitionStrat to use.

  • method – The GraphColourMethod to use.

  • cx_config – Whenever diagonalisation is required, use this configuration of CX gates


a MeasurementSetup object

pytket.partition.term_sequence(strings: List[pytket.pauli.QubitPauliString], strat: pytket.partition.PauliPartitionStrat = PauliPartitionStrat.CommutingSets, method: pytket.partition.GraphColourMethod = GraphColourMethod.Lazy) List[List[pytket.pauli.QubitPauliString]]

Takes in a list of QubitPauliString objects and partitions them into mutually commuting sets according to some PauliPartitionStrat, then sequences in an arbitrary order.

  • tensors – A list of QubitPauliString objects to be sequenced. Assumes that each Pauli tensor is unique, and does not combine equivalent tensors.

  • strat – The PauliPartitionStrat to use. Defaults to CommutingSets.

  • method – The GraphColourMethod to use.


a list of lists of QubitPauliString s