pytket.partition

class pytket._tket.partition.GraphColourMethod

Enum for available methods to perform graph colouring.

Members:

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._tket.partition.GraphColourMethod, value: int) None
property name
class pytket._tket.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._tket.partition.MeasurementBitMap, circ_index: int, bits: Sequence[int], invert: bool = False) None

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

Parameters:
  • 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

static from_dict(arg0: dict) pytket._tket.partition.MeasurementBitMap

Construct MeasurementBitMap instance from dict representation.

to_dict(self: pytket._tket.partition.MeasurementBitMap) dict

JSON-serializable dict representation of the MeasurementBitMap.

Returns:

dict representation of the MeasurementBitMap

property bits

Bits to measure

property circ_index

Clifford circuit index

property invert

Whether result is inverted or not

class pytket._tket.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._tket.partition.MeasurementSetup) None

Constructs an empty MeasurementSetup object

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

Add a Clifford circuit that rotates into some Pauli basis

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

Add a new Pauli string with a corresponding BitMap

static from_dict(arg0: dict) pytket._tket.partition.MeasurementSetup

Construct MeasurementSetup instance from dict representation.

to_dict(self: pytket._tket.partition.MeasurementSetup) dict

JSON-serializable dict representation of the MeasurementSetup.

Returns:

dict representation of the MeasurementSetup

verify(self: pytket._tket.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.

Returns:

True or False

property measurement_circs

Clifford measurement circuits.

property results

Map from Pauli strings to MeasurementBitMaps

class pytket._tket.partition.PauliPartitionStrat

Enum for available strategies to partition Pauli tensors.

Members:

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

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

__init__(self: pytket._tket.partition.PauliPartitionStrat, value: int) None
property name
pytket._tket.partition.measurement_reduction(strings: Sequence[pytket._tket.pauli.QubitPauliString], strat: pytket._tket.partition.PauliPartitionStrat, method: pytket._tket.partition.GraphColourMethod = <GraphColourMethod.Lazy: 0>, cx_config: pytket._tket.circuit.CXConfigType = <CXConfigType.Snake: 0>) pytket._tket.partition.MeasurementSetup

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

Parameters:
  • 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

Returns:

a MeasurementSetup object

pytket._tket.partition.term_sequence(strings: Sequence[pytket._tket.pauli.QubitPauliString], strat: pytket._tket.partition.PauliPartitionStrat = <PauliPartitionStrat.CommutingSets: 1>, method: pytket._tket.partition.GraphColourMethod = <GraphColourMethod.Lazy: 0>) list[list[pytket._tket.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.

Parameters:
  • 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.

Returns:

a list of lists of QubitPauliString s