Randomized Compiling 2

In this example, two cycles have been marked with non-default markers. Note that the circuit depth increases in this instance because the random gates cannot be compiled into the adjacent cycles due to the mismatch in markers.

Note

Randomized compiling produces a new circuit collection after each call, so the output of this example will be different if it’s executed again.

Note

If the cycles in the circuit are all marked with 0, then cycles containing multi-qubit gates will automatically be uniquely marked by default. Randomized compiling will not attempt to compile new gates into cycles with marker 0. All new cycles inserted with randomized compilation will have default markers.

Import True-Q:

import trueq as tq

Define a circuit which applies alternating cycles, with an X gate on qubit 0 in one cycle and a controlled-Z gate on qubits 0 and 1 in the other cycle, and where the middle cycle with an X gate is marked:

cycle1 = tq.Cycle({(0,): tq.Gate.x})
cycle2 = tq.Cycle({(0, 1): tq.Gate.cz}, marker=3)
cycle3 = tq.Cycle({(0,): tq.Gate.x}, marker=5)
circuit = tq.Circuit([cycle1, cycle2, cycle3, cycle2, cycle1])

Display the original circuit:

circuit
True-Q formatting will not be loaded without trusting this notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking "File -> Trust Notebook".
Circuit
Key:
No key present in circuit.
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00
3
Marker 3
Compilation tools may only recompile cycles with equal markers.
(0, 1): Gate.cz
Name:
  • Gate.cz
Aliases:
  • Gate.cz
Likeness:
  • CNOT
Generators:
  • 'IZ': 90.0
  • 'ZI': 90.0
  • 'ZZ': -90.0
Matrix:
  • 1.00 1.00 1.00 -1.00
5
Marker 5
Compilation tools may only recompile cycles with equal markers.
(0): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00
3
Marker 3
Compilation tools may only recompile cycles with equal markers.
(0, 1): Gate.cz
Name:
  • Gate.cz
Aliases:
  • Gate.cz
Likeness:
  • CNOT
Generators:
  • 'IZ': 90.0
  • 'ZI': 90.0
  • 'ZZ': -90.0
Matrix:
  • 1.00 1.00 1.00 -1.00
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00


Call randomized compiling on the circuit:

compiled_circuit = tq.randomly_compile(circuit)

Display one of the randomly compiled circuits:

compiled_circuit[0]
True-Q formatting will not be loaded without trusting this notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking "File -> Trust Notebook".
Circuit
Key:
  • protocol: RC
  • twirl: Paulis on [0, 1]
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.id
Name:
  • Gate.id
Aliases:
  • Gate.id
  • Gate.i
  • Gate.cliff0
Likeness:
  • Identity
Generators:
  • 'I': 0
Matrix:
  • 1.00 1.00
(1): Gate.z
Name:
  • Gate.z
Aliases:
  • Gate.z
  • Gate.cliff3
Generators:
  • 'Z': 180.0
Matrix:
  • 1.00 -1.00
3
Marker 3
Compilation tools may only recompile cycles with equal markers.
(0, 1): Gate.cz
Name:
  • Gate.cz
Aliases:
  • Gate.cz
Likeness:
  • CNOT
Generators:
  • 'IZ': 90.0
  • 'ZI': 90.0
  • 'ZZ': -90.0
Matrix:
  • 1.00 1.00 1.00 -1.00
 
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.id
Name:
  • Gate.id
Aliases:
  • Gate.id
  • Gate.i
  • Gate.cliff0
Likeness:
  • Identity
Generators:
  • 'I': 0
Matrix:
  • 1.00 1.00
(1): Gate.z
Name:
  • Gate.z
Aliases:
  • Gate.z
  • Gate.cliff3
Generators:
  • 'Z': 180.0
Matrix:
  • 1.00 -1.00
5
Marker 5
Compilation tools may only recompile cycles with equal markers.
(0): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00
 
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.y
Name:
  • Gate.y
Aliases:
  • Gate.y
  • Gate.cliff2
Generators:
  • 'Y': -180.0
Matrix:
  • 1.00 -1.00
(1): Gate.y
Name:
  • Gate.y
Aliases:
  • Gate.y
  • Gate.cliff2
Generators:
  • 'Y': -180.0
Matrix:
  • 1.00 -1.00
3
Marker 3
Compilation tools may only recompile cycles with equal markers.
(0, 1): Gate.cz
Name:
  • Gate.cz
Aliases:
  • Gate.cz
Likeness:
  • CNOT
Generators:
  • 'IZ': 90.0
  • 'ZI': 90.0
  • 'ZZ': -90.0
Matrix:
  • 1.00 1.00 1.00 -1.00
 
 
Marker 0
Compilation tools may only recompile cycles with equal markers.
(0): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00
(1): Gate.x
Name:
  • Gate.x
Aliases:
  • Gate.x
  • Gate.cliff1
Generators:
  • 'X': 180.0
Matrix:
  • 1.00 1.00


Total running time of the script: ( 0 minutes 0.044 seconds)

Gallery generated by Sphinx-Gallery