Configuration

When implementing a circuit on a specific physical device, we want to be able to automatically compile operations and circuits into cycles that can be implemented with natively available gates. This is to avoid the time-consuming process of compiling circuits by hand for each device.

To facilitate integration with devices True-Qᵀᴹ defines a configuration standard that, for a particular device, specifies which gates can be implemented natively, which operations are allowed to proceed in parallel, and which sequence of gates should be used to implement a synthesized unitary.

Specifying Gates

In a configuration file, users can specify native gates by providing either unitary matrix or a list of Pauli strings with corresponding rotation angles.

../_images/matrix_vs_ham.svg

When gates cannot be implemented in parallel with operations on specific other qudits, that can be specified in the config file and will be taken into account when circuits are transpiled for the system.

../_images/multiple_gates_desc.svg

In this case, two CNOTs are defined, one between (0, 2) and another between (1, 2), but both of these gates also restrict the chip, in that operations cannot be performed on other qubits (highlighted in red) in parallel with these gates. This is common in practice, where some operations, such as the Cross Resonance gate, frequently have to be performed independently from other operations.

True-Qᵀᴹ also allows users to define gates with variable parameters, for example:

../_images/parameterized_gates.svg

Example (Config file)

The below example shows a configuration file for a device named “Test,” which is comprised of qubits (specified by the Dimension), and which will implement synthesized unitaries via a series of gates of the form [("Z", angle1), ("X", 90), ("Z", angle2), ("X", 90), ("Z", angle3)] (specified by the Mode).

Name: Test
Dimension: 2
Mode: ZXZXZ

Gate CNOT:
  Matrix:
    - [1, 0, 0, 0]
    - [0, 1, 0, 0]
    - [0, 0, 0, 1]
    - [0, 0, 1, 0]
  Involving:
    (0, 1): (3)

Gate X(phi):
  Hamiltonian:
    - ['X', phi]
  Involving:
    (0,): ()
    (1,): (4,5,6)
    (2,): (4,5,6)
    (5,): (7,)

Gate Y(phi):
  Hamiltonian:
    - ['Y', phi]
  Involving:
    (0,): ()
    (1,): (4,5,6)
    (2,): (4,5,6)
    (5,): (7,)

Gate Z(phi):
  Matrix:
    - [1, 0]
    - [0, exp(1j*phi/180*pi)]
  Involving:
    (0,): ()
    (1,): (4,5,6)
    (2,): (4,5,6)
    (5,): (7,)

Gate CZ(theta, phi):
  Matrix:
    - [1, 0, 0, 0]
    - [0, 1, 0, 0]
    - [0, 0, exp(1j*phi*pi/180), 0]
    - [0, 0, 0, exp(1j*(theta+phi)*pi/180)]
  Involving:
    (0, 2): (3)

Gate MS(phi):
  Hamiltonian:
    - ['XX', phi]
  Involving:
    (0, 1): (3)
    (1, 2): (0)
    (1, 4): (0,3)

Gate Dip:
  Hamiltonian:
    - ['XX', 90]
    - ['YY', 90]
    - ['ZZ', -180]
  Involving:
    (0, 1): (3)
    (1, 2): (0)
    (1, 4): (0,3)

Gate FSim:
  Matrix:
    - [exp(1j*a*pi/180),       0,      0,          0]
    - [        0,  cos(b*pi/180), sin(b*pi/180),          0]
    - [        0, -sin(b*pi/180), cos(b*pi/180),          0]
    - [        0,       0,       0, exp(1j*c*pi/180)]
  Involving:
    (0, 1): ()
    (1, 2): ()
    (2, 3): ()

Example (Loading config file)

If the above example is saved in a file named test_config.yaml, it can be loaded as follows:

#
# Loading config example.
# Copyright 2019 Quantum Benchmark Inc.
#

import trueq as tq
import numpy as np

# Load the config file.
config = tq.Config("config.yaml")

# Get a gate as defined in the config file.
config.ms(phi=np.pi / 2)
Traceback (most recent call last):
  File "/home/user/jenkins/workspace/release trueq (centos)/.venv/lib64/python3.6/site-packages/trueq-2.2.2-py3.6.egg/trueq/config/config.py", line 393, in _parse_yaml
    conf = CaseInsensitiveDict(conf)
  File "/home/user/jenkins/workspace/release trueq (centos)/.venv/lib64/python3.6/site-packages/requests/structures.py", line 44, in __init__
    self.update(data, **kwargs)
  File "/usr/lib64/python3.6/_collections_abc.py", line 846, in update
    for key, value in other:
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/jenkins/workspace/release trueq (centos)/.venv/lib64/python3.6/site-packages/trueq-2.2.2-py3.6.egg/trueq/config/config.py", line 197, in __init__
    self._parse_yaml(conf)
  File "/home/user/jenkins/workspace/release trueq (centos)/.venv/lib64/python3.6/site-packages/trueq-2.2.2-py3.6.egg/trueq/config/config.py", line 395, in _parse_yaml
    raise ValueError("Invalid Config file input.")
ValueError: Invalid Config file input.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "../../examples/loading_config.py", line 10, in <module>
    config = tq.Config("config.yaml")
  File "/home/user/jenkins/workspace/release trueq (centos)/.venv/lib64/python3.6/site-packages/trueq-2.2.2-py3.6.egg/trueq/config/config.py", line 205, in __init__
    raise ValueError("Either an invalid filename or incorrect YAML") from e
ValueError: Either an invalid filename or incorrect YAML