mimiqcircuits.qcsresults

Classes

QCSResults([simulator, version, fidelities, ...])

Represents the results of quantum computations obtained from quantum cloud services (QCS).

class mimiqcircuits.qcsresults.QCSResults(simulator=None, version=None, fidelities=None, avggateerrors=None, cstates=None, zstates=None, amplitudes=None, timings=None)[source]

Bases: object

Represents the results of quantum computations obtained from quantum cloud services (QCS).

Parameters:
  • simulator (str) – The name of the quantum simulator.

  • version (str) – The version of the quantum simulator.

  • fidelities (list) – List of fidelity estimates from different executions.

  • avggateerrors (list) – List of average multi-qubit gate errors from different executions.

  • cstates (list) – List of classical states obtained from executions.

  • zstates (list) – Not used in the current implementation.

  • amplitudes (dict) – Dictionary of statevector amplitudes for different quantum states.

  • timings (dict) – Dictionary of timing information for different phases of the computation.

__init__(simulator=None, version=None, fidelities=None, avggateerrors=None, cstates=None, zstates=None, amplitudes=None, timings=None)[source]
histogram()[source]

Histogram of the obtained classical states’ occurrences.

Returns:

A dictionary of classical states (bitarray) and their occurrences (float).

Raises:

TypeError – If a non QCSResults object is passed.

histzvars()[source]

Histogram of the obtained zstates’ occurrences.

saveproto(file)[source]

Save QCSResults object to a Protocol Buffers file.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> import os
>>> import tempfile
>>> x, y = symbols("x y")
>>> c = Circuit()
>>> c.push(GateH(), 0)
1-qubit circuit with 1 instructions:
└── H @ q[0]

>>> conn = MimiqConnection()
>>> conn.connect(os.getenv("MIMIQUSER"), os.getenv("MIMIQPASS"))
MimiqConnection:
├── url: https://mimiq.qperfect.io
├── Max time limit per request: 360 minutes
├── Default time limit is equal to max time limit: 360 minutes
└── status: open
>>> job = conn.execute(c)
>>> res = conn.get_result(job)
>>> res
QCSResults:
├── simulator: MIMIQ-MPS 0.18.3
├── timings:
│    ├── amplitudes time: 1.65e-07s
│    ├── sample time: 0.000204869s
│    ├── parse time: 0.000296368s
│    ├── total time: 0.001337133s
│    ├── compression time: 0.000166837s
│    └── apply time: 0.0003098s
├── fidelity estimate: 1
├── average multi-qubit gate error estimate: 0
├── most sampled:
│    ├── bs"1" => 537
│    └── bs"0" => 463
├── 1 executions
├── 0 amplitudes
└── 1000 samples
>>> tmpfile = tempfile.NamedTemporaryFile(suffix=".pb", delete=True)
>>> res.saveproto(tmpfile.name)
7161
>>> res.loadproto(tmpfile.name)
QCSResults:
├── simulator: MIMIQ-MPS 0.18.3
├── timings:
│    ├── parse time: 0.000296368s
│    ├── sample time: 0.000204869s
│    ├── amplitudes time: 1.65e-07s
│    ├── total time: 0.001337133s
│    ├── compression time: 0.000166837s
│    └── apply time: 0.0003098s
├── fidelity estimate: 1
├── average multi-qubit gate error estimate: 0
├── most sampled:
│    ├── bs"1" => 537
│    └── bs"0" => 463
├── 1 executions
├── 0 amplitudes
└── 1000 samples
Note:

This example uses a temporary file to demonstrate the save and load functionality. You can save your file with any name at any location using:

res.saveproto("example.pb")
res.loadproto("example.pb")
static loadproto(file)[source]

Load QCSResults object from a Protocol Buffers file.

The loadproto() method is a static method and should be called on the class, not on an instance of the class.

Note

Look for example in QCSResults.saveproto()