Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
129b60f
Update predictor(adding callbacks)
Mar 29, 2025
08889bd
Update
Apr 10, 2025
e2ff3fe
Restore helper.py and predictor.py to match upstream
Jul 29, 2025
1c32d15
Merge remote-tracking branch 'upstream/main'
Jul 29, 2025
78dc1aa
Implement new mapping actions
Jul 29, 2025
a3ba836
Fix: resolve pre-commit issues and add missing annotations
Jul 29, 2025
5935e6f
Fix: resolve pre-commit issues and add missing annotations
Jul 29, 2025
f71fb29
Fix: resolve pre-commit issues and add missing annotations
Jul 30, 2025
3c7592b
Fix: resolve pre-commit issues and add missing annotations
Jul 30, 2025
6db5c27
Fix mypy errors
Aug 1, 2025
47841c5
Fix mypy errors
Aug 1, 2025
b1ac8ce
Fix dependencies issues
Aug 3, 2025
5f8473c
Fix dependency issues
Aug 3, 2025
7491ec0
Add missing zip file
Aug 3, 2025
3346842
Fix issue with Python 3.13
Aug 3, 2025
6f7a73c
Merge branch 'main' into hybrid-mapping
Shaobo-Zhou Aug 3, 2025
6c67349
Remove Python 3.13 from noxfile.py due to compatibility issue
Aug 3, 2025
2692b96
Skip minimums session on Windows due to CI slowness
Aug 4, 2025
f4874e6
Fix bugs
Aug 5, 2025
54eec91
Fix bugs
Aug 5, 2025
845f7de
Use default Qiskit settings for VF2Layout and add assertion for nativ…
Shaobo-Zhou Aug 7, 2025
3418936
Debug
Shaobo-Zhou Aug 7, 2025
ae870cc
Fix missing argument
Shaobo-Zhou Aug 7, 2025
861bc62
Fix warning issues
Shaobo-Zhou Aug 7, 2025
fa989b6
Fix window runtime warning problem
Shaobo-Zhou Aug 7, 2025
405bd39
Fix window runtime warning problem
Shaobo-Zhou Aug 7, 2025
7b2f321
Add time limit for VF2PostLayout
Shaobo-Zhou Aug 7, 2025
b67d0a6
Fix windows runtime warning problem
Shaobo-Zhou Aug 7, 2025
bf7c9ee
Add new actions
Shaobo-Zhou Aug 29, 2025
6d2733f
Add new actions
Shaobo-Zhou Aug 29, 2025
878185a
Add evaluation code for baseline model
Shaobo-Zhou Sep 3, 2025
eae11a2
Set up code for testing new model
Shaobo-Zhou Sep 5, 2025
68306ec
Reset
Shaobo-Zhou Sep 5, 2025
fcba8fa
Add new actions
Shaobo-Zhou Sep 6, 2025
e5b7518
Fix dependencies
Shaobo-Zhou Sep 8, 2025
907ce2b
Fix dependencies
Shaobo-Zhou Sep 8, 2025
70dcd7d
Fix dependencies
Shaobo-Zhou Sep 8, 2025
e0364b1
Merge branch 'main' into new_structure
Shaobo-Zhou Sep 8, 2025
eb27098
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 8, 2025
2688c0e
Fix dependencies
Shaobo-Zhou Sep 8, 2025
840d23d
Fix multiprocessing on Python 3.13
Shaobo-Zhou Sep 9, 2025
ac406ac
Fix timeout watcher
Shaobo-Zhou Sep 9, 2025
97c81bb
Update comments and restructure
Shaobo-Zhou Sep 15, 2025
470365d
Adjust test circuits from ALG to INDEP
Shaobo-Zhou Sep 15, 2025
caaf224
Update max synthesis size for bqskit
Shaobo-Zhou Sep 15, 2025
468da2e
Add tests for more coverage
Shaobo-Zhou Sep 17, 2025
737a9f2
Update tests
Shaobo-Zhou Sep 18, 2025
94c25ab
Update override
Shaobo-Zhou Sep 18, 2025
3ff922e
Update comments
Shaobo-Zhou Sep 18, 2025
782caf8
Update noxfile.py and CHANGELOG.md
Shaobo-Zhou Sep 22, 2025
44e0e40
Clean up venv after each session to free up space
Shaobo-Zhou Sep 23, 2025
350bae5
Clean up venv after each session to free up space
Shaobo-Zhou Sep 23, 2025
91208d1
Clean up venv after each session to free up space
Shaobo-Zhou Sep 23, 2025
622d409
Clean up venv after each session to free up space
Shaobo-Zhou Sep 23, 2025
fa008a6
Update noxfile
Shaobo-Zhou Sep 25, 2025
0c98e56
Update ibm runtime dependency
Shaobo-Zhou Sep 25, 2025
34a1c7c
Update noxfile
Shaobo-Zhou Sep 25, 2025
a8d069a
Update noxfile
Shaobo-Zhou Sep 25, 2025
114b79b
Update noxfile
Shaobo-Zhou Sep 25, 2025
aaf14b1
Fetch update from main
Shaobo-Zhou Sep 26, 2025
46da095
Merge branch 'main' into new_structure
Shaobo-Zhou Sep 26, 2025
97af7bb
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 26, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel

### Changed

- 🔧 Changed test circuit level for RL predictor from ALG to INDEP
- 🔥 Drop support for x86 macOS systems ([#421]) ([**@denialhaag**])

## [2.3.0] - 2025-07-29
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ After setup, any quantum circuit can be compiled for the most suitable device wi
from mqt.predictor import qcompile
from mqt.bench import get_benchmark, BenchmarkLevel

uncompiled_qc = get_benchmark("ghz", level=BenchmarkLevel.ALG, circuit_size=5)
uncompiled_qc = get_benchmark("ghz", level=BenchmarkLevel.INDEP, circuit_size=5)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely add these (and some other major) changes to the changelog.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please do so in CHANGELOG.md.

compiled_qc, compilation_info, selected_device = qcompile(
uncompiled_qc, figure_of_merit="expected_fidelity"
)
Expand Down
23 changes: 21 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import argparse
import contextlib
import os
import pathlib
import shutil
import tempfile
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -57,6 +58,21 @@ def lint(session: nox.Session) -> None:
session.run("pre-commit", "run", "--all-files", *session.posargs, external=True)


def _cleanup(session: nox.Session) -> None:
"""Remove this session's virtualenv to save disk space in CI."""
version = session.python
if version != "3.13": # keep cache for last run
venv_dir = session.virtualenv.location
if venv_dir and pathlib.Path(venv_dir).exists():
shutil.rmtree(venv_dir, ignore_errors=True)
session.log(f"Cleaned up {venv_dir}")
shutil.rmtree(pathlib.Path("~/.cache").expanduser(), ignore_errors=True)
gha_temp = pathlib.Path("/home/runner/work/_temp/setup-uv-cache")
if gha_temp.exists():
shutil.rmtree(gha_temp, ignore_errors=True)
session.log(f"Cleaned GitHub Actions uv temp cache at {gha_temp}")


def _run_tests(
session: nox.Session,
*,
Expand Down Expand Up @@ -86,10 +102,12 @@ def _run_tests(
)


@nox.session(reuse_venv=True, python=PYTHON_ALL_VERSIONS)
@nox.session(reuse_venv=not os.environ.get("CI"), python=PYTHON_ALL_VERSIONS)
def tests(session: nox.Session) -> None:
"""Run the test suite."""
_run_tests(session)
if os.environ.get("CI"):
_cleanup(session)


@nox.session(reuse_venv=True, venv_backend="uv", python=PYTHON_ALL_VERSIONS)
Expand All @@ -103,7 +121,8 @@ def minimums(session: nox.Session) -> None:
)
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
session.run("uv", "tree", "--frozen", env=env)
session.run("uv", "lock", "--refresh", env=env)
if os.environ.get("CI"):
_cleanup(session)


@nox.session(reuse_venv=True)
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ dependencies = [
"mqt.bench>=2.0.0",
"qiskit>=1.3.3",
"pytket>=1.29.0", # lowest version that supports the used pytket AutoRebase pass instead of auto_rebase
"pytket_qiskit>=0.61.0",
"pytket_qiskit>=0.71.0",
# TODO(denialhaag): Remove once pytket_qiskit is updated
# https://github.com/munich-quantum-toolkit/predictor/issues/471
"qiskit-ibm-runtime>=0.30.0,<0.42.0",
"sb3_contrib>=2.0.0",
"stable-baselines3>=2.7.0",
"tqdm>=4.66.0",
"rich>=12.6.0",
"scikit-learn>=1.5.1",
Expand All @@ -49,6 +50,8 @@ dependencies = [
"numpy>=1.22,<2; sys_platform == 'darwin' and 'x86_64' in platform_machine and python_version < '3.13'", # Restrict numpy v2 for macOS x86 since it is not supported anymore since torch v2.3.0
"torch>=2.8.0,<2.9.0; sys_platform == 'darwin' and 'x86_64' in platform_machine and python_version < '3.13'", # Restrict torch v2.3.0 for macOS x86 since it is not supported anymore.
"typing-extensions>=4.1", # for `assert_never`
"qiskit-ibm-transpiler==0.13.1; python_version < '3.13'", # Do not support python 3.13 yet
"qiskit-ibm-ai-local-transpiler==0.4.2; python_version < '3.13'",
]

classifiers = [
Expand Down Expand Up @@ -130,6 +133,8 @@ filterwarnings = [
'ignore:.*qiskit.providers.models is deprecated since Qiskit 1.2*:DeprecationWarning:',
'ignore:.*The class ``qiskit.qobj.*`` is deprecated as of Qiskit 1.3.*:DeprecationWarning:',
'ignore:.*The property ``qiskit.circuit.instruction.Instruction.*`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:',
'ignore:.*Timeout is not supported on Windows\\.:RuntimeWarning',

]

[tool.coverage]
Expand Down Expand Up @@ -167,7 +172,7 @@ implicit_reexport = true
# recent versions of `gym` are typed, but stable-baselines3 pins a very old version of gym.
# qiskit is not yet marked as typed, but is typed mostly.
# the other libraries do not have type stubs.
module = ["qiskit.*", "joblib.*", "sklearn.*", "matplotlib.*", "gymnasium.*", "mqt.bench.*", "sb3_contrib.*", "bqskit.*", "qiskit_ibm_runtime.*", "networkx.*", "stable_baselines3.*"]
module = ["qiskit.*", "joblib.*", "sklearn.*", "matplotlib.*", "gymnasium.*", "mqt.bench.*", "sb3_contrib.*", "bqskit.*", "qiskit_ibm_runtime.*", "networkx.*", "stable_baselines3.*","qiskit_ibm_transpiler.*"]
ignore_missing_imports = true

[tool.ruff]
Expand Down Expand Up @@ -254,3 +259,8 @@ fom = "fom"

[tool.repo-review]
ignore = ["GH200"]

[tool.uv]
override-dependencies = [
"networkx==2.8.5", # Required by `qiskit-ibm-transpiler`
]
17 changes: 13 additions & 4 deletions src/mqt/predictor/ml/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

logger = logging.getLogger("mqt-predictor")

NO_PARALLEL = sys.platform == "win32" and sys.version_info >= (3, 13)


def setup_device_predictor(
devices: list[Target],
Expand Down Expand Up @@ -227,7 +229,10 @@ def compile_training_circuits(
with zipfile.ZipFile(str(path_zip), "r") as zip_ref:
zip_ref.extractall(path_uncompiled_circuits)

Parallel(n_jobs=num_workers, verbose=100)(
# On Windows + Python 3.13, joblib's default "loky" process backend is broken
# (missing `_posixsubprocess`). Fall back to no multiprocessing.
num_jobs = 1 if NO_PARALLEL else num_workers
Parallel(n_jobs=num_jobs, verbose=100)(
delayed(self._compile_all_circuits_devicewise)(
device, timeout, path_uncompiled_circuits, path_compiled_circuits, logger.level
)
Expand Down Expand Up @@ -267,7 +272,8 @@ def generate_training_data(
names_list = []
scores_list = []

results = Parallel(n_jobs=num_workers, verbose=100)(
num_jobs = 1 if NO_PARALLEL else num_workers
results = Parallel(n_jobs=num_jobs, verbose=100)(
delayed(self._generate_training_sample)(
filename.name,
path_uncompiled_circuits,
Expand All @@ -276,6 +282,7 @@ def generate_training_data(
)
for filename in path_uncompiled_circuits.glob("*.qasm")
)

for sample in results:
training_sample, circuit_name, scores = sample
if all(score == -1 for score in scores):
Expand Down Expand Up @@ -405,8 +412,10 @@ def train_random_forest_model(
if not training_data:
training_data = self._get_prepared_training_data()
num_cv = min(len(training_data.y_train), 5)
mdl = GridSearchCV(mdl, tree_param, cv=num_cv, n_jobs=8).fit(training_data.X_train, training_data.y_train)

num_jobs = 1 if NO_PARALLEL else 8
mdl = GridSearchCV(mdl, tree_param, cv=num_cv, n_jobs=num_jobs).fit(
training_data.X_train, training_data.y_train
)
joblib_dump(mdl, save_mdl_path)
logger.info("Random Forest model is trained and saved.")

Expand Down
3 changes: 3 additions & 0 deletions src/mqt/predictor/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ def estimated_success_probability(qc: QuantumCircuit, device: Target, precision:
if first_qubit_idx not in active_qubits:
continue

dt = device.dt # discrete time unit used in duration
res *= np.exp(
-instruction.duration
* dt
/ min(device.qubit_properties[first_qubit_idx].t1, device.qubit_properties[first_qubit_idx].t2)
)
continue
res *= 1 - device[gate_type][first_qubit_idx,].error

else:
second_qubit_idx = calc_qubit_index(qargs, qc.qregs, 1)
res *= 1 - device[gate_type][first_qubit_idx, second_qubit_idx].error
Expand Down
Loading
Loading