Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Support for Qiskit v1.0.0 #210

Merged
merged 32 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
becb6c5
🎨 WIP for qiskit v1.0.0 support
nquetschlich Mar 15, 2024
9841855
🎨 pre-commit fixes
pre-commit-ci[bot] Mar 15, 2024
225ba47
📌 adjusted the BQSKit dependency temporarily
nquetschlich Mar 16, 2024
5fc5b21
Merge remote-tracking branch 'origin/qiskit_v1_update' into qiskit_v1…
nquetschlich Mar 16, 2024
9ec1d58
🚨
nquetschlich Mar 16, 2024
841a7a7
📌 adjusted MQT Bench Dependency
nquetschlich Mar 21, 2024
f6c1623
Merge branch 'main' into qiskit_v1_update
nquetschlich Apr 3, 2024
4368112
🎨 removed commented code
nquetschlich Apr 3, 2024
5fe46db
🐛 fixed bug when VF2Layout was not succesfull and no previous layout …
nquetschlich Apr 8, 2024
2153160
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 8, 2024
5a5bb40
📌 added lark dependency since pytket is depending on the (deprecated)…
nquetschlich Apr 8, 2024
62aaf59
💄improved ruff config
nquetschlich Apr 9, 2024
6484a14
📌 added pytket dependency explicitly since the lower bound of MQT Ben…
nquetschlich Apr 11, 2024
ed3022d
📌 updated dependency
nquetschlich Apr 11, 2024
138ba76
✅ adusted test to be faster
nquetschlich Apr 11, 2024
57cb0ff
✅ adusted test to be faster
nquetschlich Apr 11, 2024
9b63416
✅ adusted test to be faster
nquetschlich Apr 11, 2024
b7596f6
✅ adusted RL compilation test
nquetschlich Apr 11, 2024
d6237d0
✅ adusted RL compilation test
nquetschlich Apr 11, 2024
ca03b9a
📌 adjusted BQSKit dependency
nquetschlich Apr 15, 2024
270d3c4
Update pyproject.toml
nquetschlich Apr 15, 2024
dff5322
Update pyproject.toml
nquetschlich Apr 15, 2024
3ebbe4b
Update pyproject.toml
nquetschlich Apr 15, 2024
ceff819
Update pyproject.toml
nquetschlich Apr 16, 2024
3baa013
👷 adjusted pre-commit config
nquetschlich Apr 16, 2024
11fd66b
👷 updated pre-commit config and implemented feedback
nquetschlich Apr 16, 2024
273d14e
🔥 removed fragment from copying from mqt bench
nquetschlich Apr 16, 2024
af90feb
🔥 removed old configuration files which are now part of MQT Bench
nquetschlich Apr 16, 2024
c6be168
🔧 added warning to be ignored
nquetschlich Apr 16, 2024
0ad9df1
🐛 fixed a bug triggered by warning
nquetschlich Apr 16, 2024
db46432
✅ added noxfile
nquetschlich Apr 16, 2024
bc73c69
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ci:
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v4.6.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -30,11 +30,19 @@ repos:

# Handling unwanted unicode characters
- repo: https://github.com/sirosen/texthooks
rev: "0.6.4"
rev: "0.6.6"
hooks:
- id: fix-ligatures
- id: fix-smartquotes

# Check for common mistakes
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Clean jupyter notebooks
- repo: https://github.com/srstevenson/nb-clean
rev: "3.2.0"
Expand All @@ -45,8 +53,7 @@ repos:
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "wille, linz, fro, braket"]
exclude: "mqt/benchviewer/templates/legal.html"
args: ["-L", "wille,linz,fro"]

# Format configuration files with prettier
- repo: https://github.com/pre-commit/mirrors-prettier
Expand All @@ -56,7 +63,7 @@ repos:
types_or: [yaml, markdown, html, css, javascript, json]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -78,7 +85,7 @@ repos:
files: ^(src|tests)
args: []
additional_dependencies:
- pytket-qiskit
- pytket_qiskit
- qiskit_optimization
- qiskit_nature
- qiskit_finance
Expand All @@ -88,3 +95,19 @@ repos:
- types-requests
- types-tqdm
- types-flask

# Catch common capitalization mistakes
- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest|Mqt|Tum
exclude: (.joblib|.pre-commit-config.yaml)

# Check best practices for scientific Python code
- repo: https://github.com/scientific-python/cookie
rev: 2024.03.10
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
6 changes: 3 additions & 3 deletions docs/FigureOfMerit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ information needs to be collected, such as, e.g., gate/readout fidelities, gate
decoherence times. While for some devices, this information may be publicly available, for other
devices it may be estimated from comparable devices, previous records, or insider knowledge.

So far, two figures of merit are implemented: `expected_fidelity` and `critical_depth`.
So far, two figures of merit are implemented: ``expected_fidelity`` and ``critical_depth``.

Expected Fidelity
-----------------
Expand All @@ -27,10 +27,10 @@ with :math:`\mathit{\mathcal{F}}(g_i)` being the expected execution fidelity of
:math:`\mathit{\mathcal{F}_{RO}}(q_j)` being the expected execution fidelity of a measurement operation :math:`q_j` on its corresponding qubit and :math:`|G|` respectively :math:`m` being the number of gates and measurements in the compiled circuit.


This figure of merit determines an estimate of the probability that a quantum circuit will return the expected result, the so-called `expected fidelity`, which ranges between :math:`0.0` and :math:`1.0` with higher values being better.
This figure of merit determines an estimate of the probability that a quantum circuit will return the expected result, the so-called ``expected fidelity``, which ranges between :math:`0.0` and :math:`1.0` with higher values being better.


Critical Depth
--------------
A potential alternative could be the `critical depth` (taken from :cite:labelpar:`tomesh2022supermarq`)---a measure to describe the percentage of multi-qubit gates on the longest path through a compiled quantum circuit (determining the depth).
A potential alternative could be the ``critical depth`` (taken from :cite:labelpar:`tomesh2022supermarq`)---a measure to describe the percentage of multi-qubit gates on the longest path through a compiled quantum circuit (determining the depth).
A respective value close to 1 would indicate a very sequential circuit while a value of 0 would indicate a highly parallel one.
4 changes: 2 additions & 2 deletions docs/Usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ To compile a quantum circuit, use the ``qcompile`` method:
.. automodule:: mqt.predictor
:members: qcompile

Currently available figures of merit are `expected_fidelity` and `critical_depth`.
Currently available figures of merit are ``expected_fidelity`` and ``critical_depth``.

An example how `qcompile` is used can be found in the :doc:`quickstart <Quickstart>` jupyter notebook.
An example how ``qcompile`` is used can be found in the :doc:`quickstart <Quickstart>` jupyter notebook.

.. _pip_usage:

Expand Down
47 changes: 11 additions & 36 deletions evaluations/overall_evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@
"print(np.round(MQT_critical_depth, 2))"
]
},
{
"cell_type": "markdown",
"id": "bf93d18b-b61a-47ae-988c-590e25e2f203",
"metadata": {},
"source": [
"## Top 3 Bins"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e649aff4-7fb8-457f-9ec8-c1cd97bbc4ea",
"metadata": {},
"outputs": [],
"source": [
"def bins_labels(bins, **kwargs):\n",
" bin_w = (max(bins) - min(bins)) / (len(bins) - 1)\n",
" plt.xticks(np.arange(min(bins) + bin_w / 2, max(bins), bin_w), bins, **kwargs)\n",
" plt.xlim(bins[0], bins[-1])"
]
},
{
"cell_type": "markdown",
"id": "7efb6e96-22c3-4739-b480-75d7b9a42785",
Expand All @@ -95,7 +74,7 @@
"metadata": {},
"outputs": [],
"source": [
"def calculate_median(row, column_name):\n",
"def calculate_median(row: pd.core.series.Series, column_name: str) -> float:\n",
" columns = [col for col in row.index if col.endswith(column_name) and \"MQT\" not in col]\n",
" values = [value for col, value in row[columns].items() if value != -1]\n",
" return np.median(values) if values else None\n",
Expand Down Expand Up @@ -321,13 +300,11 @@
" axis=1,\n",
")\n",
"df_filtered_and_sorted_expected_fidelity[\"Rank_MQT_expected_fidelity\"] = (\n",
" len(\n",
" [\n",
" col\n",
" for col in df_filtered_and_sorted_expected_fidelity.columns\n",
" if col.endswith(\"_expected_fidelity\") and \"MQT\" not in col\n",
" ]\n",
" )\n",
" len([\n",
" col\n",
" for col in df_filtered_and_sorted_expected_fidelity.columns\n",
" if col.endswith(\"_expected_fidelity\") and \"MQT\" not in col\n",
" ])\n",
" - df_filtered_and_sorted_expected_fidelity.Rank_MQT_expected_fidelity\n",
")\n",
"plt.hist(\n",
Expand Down Expand Up @@ -509,13 +486,11 @@
" axis=1,\n",
")\n",
"df_filtered_and_sorted_critical_depth[\"Rank_MQT_critical_depth\"] = (\n",
" len(\n",
" [\n",
" col\n",
" for col in df_filtered_and_sorted_critical_depth.columns\n",
" if col.endswith(\"_critical_depth\") and \"MQT\" not in col\n",
" ]\n",
" )\n",
" len([\n",
" col\n",
" for col in df_filtered_and_sorted_critical_depth.columns\n",
" if col.endswith(\"_critical_depth\") and \"MQT\" not in col\n",
" ])\n",
" - df_filtered_and_sorted_critical_depth.Rank_MQT_critical_depth\n",
")\n",
"plt.hist(\n",
Expand Down
10 changes: 1 addition & 9 deletions evaluations/supervised_ml_models/evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"\n",
"from mqt.predictor import ml\n",
"\n",
"np.random.seed(10)\n",
"\n",
"predictor = ml.Predictor()\n",
"figure_of_merit = \"expected_fidelity\"\n",
"\n",
Expand Down Expand Up @@ -162,13 +160,7 @@
"\n",
"openqasm_qc_list = ml.helper.get_openqasm_gates()\n",
"feature_names = [openqasm_qc_list[i] for i in range(len(openqasm_qc_list))]\n",
"feature_names.append(\"num qubits\")\n",
"feature_names.append(\"depth\")\n",
"feature_names.append(\"prog. comm.\")\n",
"feature_names.append(\"crit. dept\")\n",
"feature_names.append(\"entang. ratio\")\n",
"feature_names.append(\"parallelism\")\n",
"feature_names.append(\"liveness\")\n",
"feature_names.extend((\"num qubits\", \"depth\", \"prog. comm.\", \"crit. dept\", \"entang. ratio\", \"parallelism\", \"liveness\"))\n",
"feature_names = [feature_names[i] for i in non_zero_indices]\n",
"\n",
"importances = clf.best_estimator_.feature_importances_\n",
Expand Down
63 changes: 63 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Nox sessions."""

from __future__ import annotations

import argparse
import os

import nox

nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv|virtualenv"

PYTHON_ALL_VERSIONS = ["3.10", "3.11", "3.12"]

BUILD_REQUIREMENTS = [
"setuptools>=61",
"setuptools_scm>=7",
]

if os.environ.get("CI", None):
nox.options.error_on_missing_interpreters = True


@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> None:
"""Lint the Python part of the codebase using pre-commit.

Simply execute `nox -rs lint` to run all configured hooks.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""Build the docs. Use "--non-interactive" to avoid serving. Pass "-b linkcheck" to check links."""
parser = argparse.ArgumentParser()
parser.add_argument("-b", dest="builder", default="html", help="Build target (default: html)")
args, posargs = parser.parse_known_args(session.posargs)

serve = args.builder == "html" and session.interactive
extra_installs = ["sphinx-autobuild"] if serve else []
session.install(*BUILD_REQUIREMENTS, *extra_installs)
session.install("--no-build-isolation", "-ve.[docs]")
session.chdir("docs")

if args.builder == "linkcheck":
session.run("sphinx-build", "-b", "linkcheck", ".", "_build/linkcheck", *posargs)
return

shared_args = (
"-n", # nitpicky mode
"-T", # full tracebacks
f"-b={args.builder}",
".",
f"_build/{args.builder}",
*posargs,
)

if serve:
session.run("sphinx-autobuild", *shared_args)
else:
session.run("sphinx-build", "--keep-going", *shared_args)
Loading
Loading