jupytext | kernelspec | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
There are a number of types that are specific to Mitiq, the most important being mitiq.QPROGRAM
and {class}.QuantumResult
.
These types are both unions of a number of other types that make it easier to annotate other functions in Mitiq, independent of the user choice of frameworks.
The Mitiq-defined type mitiq.QPROGRAM
uses any of the program types from the supported platforms that are installed on the system.
For example, if you haven't installed PyQuil, then even though Mitiq supports it, you will not be able to use PyQuil programs in Mitiq until it is installed.
Mitiq only supports non-adaptive quantum programs without classical control flow or mid-circuit measurements. This class of programs is more commonly known as _circuits_ by many other tools and frameworks in quantum computing.
The Mitiq-defined type {class}.QuantumResult
is a union of the types defined in mitiq.typing
that are used to represent the results of running a quantum program.
For example, for hardware, the result can be a list of bitstrings (representing raw measurements) or an expectation value expressed as a real number.
For simulators, more information can be made available like the resulting density matrix, which is a valid object of the {class}.QuantumResult
type.
Mitiq can accept quantum circuit representations in a variety of formats from different tools or platforms. These input formats are referred to here as frontends. The frameworks currently supported are:
import mitiq
mitiq.SUPPORTED_PROGRAM_TYPES.keys()
with Cirq being used for the internal implementations of the mitigation methods. There is also frontend support for any circuit description that complies with the OpenQASM 2.0 standard.
With any of these frontends (with the exception of Cirq), the circuit representation will be converted internally to a Cirq circuit object with the relevant conversion methods in {py:mod}mitiq.interface
for each frontend.
For example, you can use {func}mitiq.interface.mitiq_braket.conversions.from_braket()
to convert a Braket circuit to a Cirq circuit.
Examples for using each of the frameworks to represent the input to a mitigation method are linked below.
- {ref}
Cirq <examples/cirq-ibmq-backends/setup-defining-a-circuit>
- {ref}
Qiskit <examples/ibmq-backends/setup-defining-a-circuit>
- {ref}
PyQuil <examples/pyquil_demo>
- {ref}
PennyLane <examples/ibmq-backends-pennylane/setup-defining-a-circuit>
- {ref}
Braket <examples/braket_mirror_circuit/define-the-circuit>
A backend is any simulator or hardware device that can be used to execute programs that are valid mitiq.QPROGRAM
objects.
These backends are usually installed separately as needed by the user.
Backends are used by Mitiq in the {class}.Executor
class to run the mitigated mitiq.QPROGRAM
objects.
Once you have selected a frontend and backend combination that are compatible, the next step is to set up the execution of a quantum program.
The {class}.Executor
class is used to execute quantum programs, and is constructed by providing a function with the following signature: mitiq.QPROGRAM
-> {class}.QuantumResult
.
For more information on executors, see the {doc}Executors <executors>
section of this guide.
You can also use the {class}.Executor
class to execute a batch of quantum programs all in one go.
To perform batched execution, you can use the same mitiq.Executor class constructor and pass a function with the following signature: T[mitiq.QPROGRAM] -> T[{class}".QuantumResult"]
where T is Sequence
, List
, Tuple
, or Iterable
.
For more information on batched executors and example code, see the {doc}Executors <executors>
section of this guide.