Skip to main content

qprof plugin for qiskit framework.

Project description

qprof_qiskit is a plugin for qprof. This plugin adds the support for the qiskit library to qprof.

Installation

qprof_qiskit being a Python module, it is installable with pip.

From Gitlab

git clone https://gitlab.com/qcomputing/qprof/qprof_qiskit.git
pip install qprof_qiskit/

From PyPi

Usage

Profiling

Profiling is performed with the qprof.profile function.

The qprof.profile function needs a quantum routine implemented with one of the supported frameworks along with the “base” gate times provided as a dictionary.

Example of profiling:

# Import the qprof tools
from qprof import profile

# Import the framework tools to generate a quantum routine
from qiskit.aqua.algorithms import Grover
from qiskit.aqua.components.oracles import LogicalExpressionOracle


# Generate the routine to benchmark.
input_3sat = """
c example DIMACS-CNF 3-SAT
p cnf 3 5
-1 -2 -3 0
1 -2 3 0
1 2 -3 0
1 -2 -3 0
-1 2 3 0
"""

oracle = LogicalExpressionOracle(input_3sat)
grover = Grover(oracle)
circuit = grover.construct_circuit()

# Hard-coded gate times retrieved by hand
gate_times = {"U1": 0, "U2": 89, "U3": 178, "CX": 930, "BARRIER": 0}

# Profile the resulting quantum circuit and use the "gprof" exporter
qprof_out = profile(circuit, gate_times, "gprof")

# Print to stdout the analysis report
print(qprof_out)

Full profiling example

Requirements for the example

You should have the dot tool installed on your machine, along with the gprof2dot tool that can be installed with pip install gprof2dot.

Profile the code

Let save the code of the previous section in a file profile.py.

You can generate the following graph with the command

python3 profile.py | gprof2dot | dot -Tpng -o profiling_result.png
docs/images/profile_result.png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qprof_qiskit-1.0.1.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

qprof_qiskit-1.0.1-py3-none-any.whl (19.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page