True-Q Fundamentals

This section provides an overview of True-Q™’s basic building blocks and an introduction to True-Q™’s circuit description language.

../../_images/circuits_gate_etc.svg

A typical quantum circuit represented in True-Q™ consisting of a series of single- and multi-qubit (or -qudit) gates and measurements. Parallel [1] operations are captured in cycles.

We use the following high-level classes to define circuits, their components, and their results:

  • Operation: a quantum operation such as a gate

  • Cycle: a clock cycle of a circuit containing quantum operations

  • Circuit: a list of cycles and other metadata

  • Results: stores the results when a quantum circuit is run on hardware or a simulator

Using these, the circuit above can be implemented as follows:

import trueq as tq

cycle1 = {0: tq.Gate.h, 1: tq.Gate.h, 2: tq.Gate.h}
cycle2 = {(0, 1): tq.Gate.cz}
cycle3 = {(0, 2): tq.Gate.cz}
cycle4 = {1: tq.Gate.h, 2: tq.Gate.h}

circuit = tq.Circuit([cycle1, cycle2, cycle3, cycle4])
circuit.measure_all()

circuit.draw()
0 1 2 Key: Labels: (0,) Name: Gate.h Aliases: Gate.h Gate.f Gate.cliff12 Generators: Z: 127.28 X: 127.28 0.71 0.71 0.71 -0.71 H Labels: (1,) Name: Gate.h Aliases: Gate.h Gate.f Gate.cliff12 Generators: Z: 127.28 X: 127.28 0.71 0.71 0.71 -0.71 H Labels: (2,) Name: Gate.h Aliases: Gate.h Gate.f Gate.cliff12 Generators: Z: 127.28 X: 127.28 0.71 0.71 0.71 -0.71 H Labels: (0, 1) Name: Gate.cz Aliases: Gate.cz Locally Equivalent: CNOT Generators: ZZ: -90.00 ZI: 90.00 IZ: 90.00 1.00 1.00 1.00 -1.00 CZ CZ Labels: (0, 2) Name: Gate.cz Aliases: Gate.cz Locally Equivalent: CNOT Generators: ZZ: -90.00 ZI: 90.00 IZ: 90.00 1.00 1.00 1.00 -1.00 CZ CZ Labels: (1,) Name: Gate.h Aliases: Gate.h Gate.f Gate.cliff12 Generators: Z: 127.28 X: 127.28 0.71 0.71 0.71 -0.71 H Labels: (2,) Name: Gate.h Aliases: Gate.h Gate.f Gate.cliff12 Generators: Z: 127.28 X: 127.28 0.71 0.71 0.71 -0.71 H 1 Labels: (0,) Name: Meas M Labels: (1,) Name: Meas M Labels: (2,) Name: Meas M

And we can populate the Results by using our built-in Simulator:

sim = tq.Simulator()
sim.run(circuit, n_shots=100)

circuit.results.plot()
../../_images/index_1_0.png

The following pages cover all these basic building blocks in more detail. The Simulator is covered in Running Circuits.

  1. Example: Quantum Circuits in True-Q™

    A hands-on example that explains the basic circuit elements

  2. Circuit Components

    Reviews the fundamental True-Q™ classes for circuit construction

  3. Example: Quantum Circuits with Qudits

    An example showing how True-Q™ circuits can be constructed for qudits

  4. Advanced Qudit Framework

    Provides a formal introduction into the qudit formalism and mathematical background

  5. Keys: Storing and Filtering Metadata

    Gives an overview of the object Key that is used to store and filter metadata associated with circuits and estimates.

  6. Circuit Collections

    Gives an overview of the tools True-Q™ contains for storing, filtering, and manipulating collections of quantum circuits.

  7. Parsing Estimate Collections

    Gives an overview of how to effectively parse and extract information from the fitting routines of True-Q™.

  8. Example: Recording Results

    Shows how to work with the Resultsclass.

  9. Example: Saving and Loading Objects to Disk

    Shows how to save/load True-Q™ objects to/from disk.

Footnotes