qat.plugins.KAKCompression

This plugin merges consecutive one qubit gates and then decompose the computed unitary gate using a decomposition passed as argument of this plugin. The usage of this plugin is detailed in the compilation section

class qat.plugins.KAKCompression(variables: list = None, pattern: Union[list, DynamicPattern] = None, generator: Callable = None, gateset=None, include_matrix=True, decomposition: str = None)

Merge and decompose one qubit gates of a circuit. The decomposition of a gate could be defined using:

  • a pair (‘variables’, ‘pattern’): this pair describes the decomposition of any 1 qubit unitary gate

  • a ‘generator’: a generator is a function taking 4 arguments (one argument per value of the unitary gate) and returning a pattern corresponding to this unitary gate.

Arguments (‘variables’, ‘pattern’) and ‘generator’ are mutually exclusive, you can’t use both. This plugin requires a decomposition and can’t be instantiated without providing a (‘variables’, ‘pattern’) pair or a ‘generator’

Parameters
  • variables (list<VAR>, optional) – list of variables used in the pattern. The list should be of size 4, each variable corresponding to a value of the matrix

  • pattern (pattern like, optional) – pattern corresponding to the decomposition of the one qubit gate. Please refer to Writing patterns for more information

  • generator (Callable, optional) – pattern generator. A pattern generator is a function taking 4 arguments (one argument per value of the matrix) and returning a pattern

  • gateset (GateSet, optional) – gate set used to generate the gates. Default: default_gate_set()

  • include_matrix (bool, optional) – include the matrices in the gate dictionary of the circuit (Default: True)

  • decomposition (str, optional) – build the KAKCompression plugin from a decomposition key. Using this argument is equivalent to KAKCompression.from_decomposition(…)

compile(batch, specs)

Optimize single qubit gates by merging all consecutive one qubits gate and then by decomposing these new gates

Parameters