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: 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 matrixpattern (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
KAKCompressionplugin from a decomposition key. Using this argument is equivalent tofrom_pattern()static method
- compile(batch, specs)
Optimize single qubit gates by merging all consecutive one qubits gate and then by decomposing these new gates
- Parameters:
batch (
Batch) – batch to optimizespecs (HardwareSpecs) – Hardware specs
- static from_pattern(pattern: str = 'ZXZ')
Builds an
KAKCompressiondirectly from a string representing a decomposition pattern.Acceptable strings are:
"ZXZ"for a \(RZ-RX-RZ\) decomposition"XZX"for a \(RX-RZ-RX\) decomposition"ZYZ"for a \(RZ-RY-RZ\) decomposition"aqt"for a \(RZ-PRX\) decomposition with AQT’s native PRX gate"ions"or"rx+"for a \(RZ-\sqrt{X}-RZ-\sqrt{X}^\dagger-RZ\) decomposition"ibm"or"u3"to have only U3 gates in the output circuit"ionq"for a \(GPi2-GPi-GPi2\) decomposition with IonQ’s native GPi and GPi2 gate"iqm"for a \(RZ-PRX\) decomposition with IQM’s native PRX gate"quobly"for a \(K-RZ-K\) decomposition with Quobly’s native K gate
- Parameters:
pattern (str) – decomposition name
- Returns:
configured plugin
- Return type: