Skip to content

Commit a3d4baa

Browse files
committed
Update docs and comments
1 parent 988a8f7 commit a3d4baa

File tree

5 files changed

+15
-25
lines changed

5 files changed

+15
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
1111

1212
### Changed
1313

14-
- 🔧 Changed test circuit level for RL predictor from ALG to INDEP
14+
- 🔧 Changed test circuit level for RL predictor from ALG to INDEP ([#449]) ([**@Shaobo-Zhou**])
1515
- ✨ Remove support for custom names of trained models ([#489]) ([**@bachase**])
1616
- 🔥 Drop support for x86 macOS systems ([#421]) ([**@denialhaag**])
1717

noxfile.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import argparse
1919
import contextlib
2020
import os
21-
import pathlib
2221
import shutil
2322
import tempfile
2423
from typing import TYPE_CHECKING
@@ -61,21 +60,6 @@ def lint(session: nox.Session) -> None:
6160
session.run("pre-commit", "run", "--all-files", *session.posargs, external=True)
6261

6362

64-
def _cleanup(session: nox.Session) -> None:
65-
"""Remove this session's virtualenv to save disk space in CI."""
66-
version = session.python
67-
if version != "3.13": # keep cache for last run
68-
venv_dir = session.virtualenv.location
69-
if venv_dir and pathlib.Path(venv_dir).exists():
70-
shutil.rmtree(venv_dir, ignore_errors=True)
71-
session.log(f"Cleaned up {venv_dir}")
72-
shutil.rmtree(pathlib.Path("~/.cache").expanduser(), ignore_errors=True)
73-
gha_temp = pathlib.Path("/home/runner/work/_temp/setup-uv-cache")
74-
if gha_temp.exists():
75-
shutil.rmtree(gha_temp, ignore_errors=True)
76-
session.log(f"Cleaned GitHub Actions uv temp cache at {gha_temp}")
77-
78-
7963
def _run_tests(
8064
session: nox.Session,
8165
*,
@@ -109,8 +93,6 @@ def _run_tests(
10993
def tests(session: nox.Session) -> None:
11094
"""Run the test suite."""
11195
_run_tests(session)
112-
if os.environ.get("CI"):
113-
_cleanup(session)
11496

11597

11698
@nox.session(python=PYTHON_ALL_VERSIONS, reuse_venv=True, venv_backend="uv", default=True)

src/mqt/predictor/rl/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import numpy as np
1818
from qiskit import QuantumCircuit
1919

20-
from mqt.predictor.utils import calc_supermarq_features, get_openqasm_gates
20+
from mqt.predictor.utils import calc_supermarq_features, get_rl_openqasm_gates
2121

2222
if TYPE_CHECKING:
2323
from numpy.random import Generator
@@ -71,7 +71,7 @@ def get_state_sample(max_qubits: int, path_training_circuits: Path, rng: Generat
7171

7272
def dict_to_featurevector(gate_dict: dict[str, int]) -> dict[str, float]:
7373
"""Calculates and returns a normalized feature vector of a given quantum circuit gate dictionary."""
74-
res_dct = dict.fromkeys(get_openqasm_gates(), 0.0)
74+
res_dct = dict.fromkeys(get_rl_openqasm_gates(), 0.0)
7575
exclude_from_total = {"barrier"}
7676
total = sum(val for key, val in gate_dict.items() if key not in exclude_from_total)
7777

src/mqt/predictor/rl/predictorenv.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
postprocess_vf2postlayout,
8383
prepare_noise_data,
8484
)
85-
from mqt.predictor.utils import get_openqasm_gates
85+
from mqt.predictor.utils import get_rl_openqasm_gates
8686

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

@@ -178,7 +178,7 @@ def __init__(
178178
self.has_parameterized_gates = False
179179
self.rng = np.random.default_rng(10)
180180

181-
gate_spaces = {g: Box(low=0, high=1, shape=(1,), dtype=np.float32) for g in get_openqasm_gates()}
181+
gate_spaces = {g: Box(low=0, high=1, shape=(1,), dtype=np.float32) for g in get_rl_openqasm_gates()}
182182

183183
spaces = {
184184
"num_qubits": Discrete(self.device.num_qubits + 1),
@@ -392,7 +392,15 @@ def fom_aware_compile(
392392
prop_set = dict(pm.property_set)
393393

394394
try:
395-
# Synthesize for lookahead fidelity (Mapping could insert non-local SWAP gates)
395+
# For fidelity-based metrics, do a cheap "lookahead" synthesis step:
396+
# routing may have introduced non-native SWAPs, so we translate the
397+
# circuit into the device's native basis before evaluating the metric.
398+
#
399+
# Note:
400+
# - BasisTranslator *only* performs basis conversion; it does not optimize.
401+
# - This isolates the effect of mapping (inserted SWAPs) on fidelity
402+
# without conflating it with further optimizations.
403+
396404
if maximize:
397405
synth_pass = PassManager([
398406
BasisTranslator(StandardEquivalenceLibrary, target_basis=device.operation_names)

src/mqt/predictor/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def calc_supermarq_features(
145145
)
146146

147147

148-
def get_openqasm_gates() -> list[str]:
148+
def get_rl_openqasm_gates() -> list[str]:
149149
"""Returns a list of all quantum gates within the openQASM 2.0 standard header."""
150150
# according to https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/qasm/libs/qelib1.inc
151151
# u,u0,u1,u2,u3 gates are excluded as they are not meaningful as RL features

0 commit comments

Comments
 (0)