Skip to content
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
f0a017e
first data classes for compilation visualization
linus-hologram Apr 1, 2026
78ca6b6
First Running Draft of the new tracer.py
linus-hologram Apr 4, 2026
d29b926
cleaned up tracer initialization
linus-hologram Apr 4, 2026
4fdddfb
extended capture of device metadata
linus-hologram Apr 4, 2026
ea7751e
included tracking of figure_of_merit over time
linus-hologram Apr 4, 2026
bf3bde3
adjusted gate counting & included feature vector values for compilati…
linus-hologram Apr 5, 2026
3ece49d
restructuring of CompilationTracer class
linus-hologram Apr 7, 2026
8a82b84
included tracing of MDP state evolution
linus-hologram Apr 7, 2026
4b3368a
CompilationStep now includes gate count per operation values
linus-hologram Apr 11, 2026
88b8fb6
expected_fidelity is now permanently included in tracing
linus-hologram Apr 11, 2026
2e24f21
included schema version & timestamp values
linus-hologram Apr 11, 2026
e84d0f5
added more doc comments
linus-hologram Apr 11, 2026
3cbd07a
Merge branch 'qce-experiments' of github.com:linus-hologram/predictor…
linus-hologram Apr 11, 2026
2b3bf4f
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 12, 2026
efc94a3
revert accidental inclusion of local model and gitkeep files
linus-hologram Apr 12, 2026
12fd41a
Merge remote-tracking branch 'origin/thesis-predictor-visualization' …
linus-hologram Apr 12, 2026
2c76fbc
Added test that checks tracer presence and superficial semantic corre…
linus-hologram Apr 13, 2026
6f2784a
adjusted CHANGELOG.md
linus-hologram Apr 13, 2026
14eb26d
Update CHANGELOG.md
linus-hologram Apr 13, 2026
d0f0506
incorporated changes from coderabbit :)
linus-hologram Apr 13, 2026
3935683
made unit test for tracer more powerful
linus-hologram Apr 13, 2026
62000bb
incorporate code rabbit feedback
linus-hologram Apr 13, 2026
90f4bb3
added missing PR link
linus-hologram Apr 13, 2026
42e5d40
tracer_path restoration of predictor singleton instance in predictor.…
linus-hologram Apr 13, 2026
a84658d
fixed incorrect key for last_step_data and added comment
linus-hologram Apr 13, 2026
e4d03c4
added model training in case test_tracer.py is ran out of order or se…
linus-hologram Apr 14, 2026
1dafd89
switched test to usage of rl_compile instead of qcompile
linus-hologram Apr 14, 2026
4564a55
incorporated first round of feedback
linus-hologram Apr 15, 2026
2424d3c
incorporated feedback
linus-hologram Apr 16, 2026
0c42d4a
minor cleanup
linus-hologram Apr 16, 2026
197ebc5
added rewritten, cleaner version of the calculate_reward function + f…
linus-hologram Apr 20, 2026
5c2ecd6
⏪ remove merge leftover line
flowerthrower Apr 20, 2026
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
- ✨ Improved the MDP and extended the RL predictor's action/state space (expanded observation vector, support for stochastic passes, wrapped stochastic actions) ([#449]) ([**@Shaobo-Zhou**])
- ✨ Added AIRouting and new optimization actions (KAKDecomposition, ElidePermutations) to the RL action set ([#449]) ([**@Shaobo-Zhou**])
- ✨ Improve RL reward design by adding intermediate rewards ([#526]) ([**@Shaobo-Zhou**])
- ✨ Added CompilationTracer that collects compilation information and exports it to a JSON file ([#641]) ([**@linus-hologram**])
- 🔧 Replace `mypy` with `ty` ([#572]) ([**@denialhaag**])
- 🐛 Fix instruction duration unit in estimated success probability calculation ([#445]) ([**@Shaobo-Zhou**])

Expand Down Expand Up @@ -65,6 +66,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[#393]: https://github.com/munich-quantum-toolkit/predictor/pull/393
[#385]: https://github.com/munich-quantum-toolkit/predictor/pull/385
[#360]: https://github.com/munich-quantum-toolkit/predictor/pull/360
[#641]: https://github.com/munich-quantum-toolkit/predictor/pull/641

<!-- Contributor -->

Expand All @@ -74,6 +76,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[**@denialhaag**]: https://github.com/denialhaag
[**@bachase**]: https://github.com/bachase
[**@Shaobo-Zhou**]: https://github.com/Shaobo-Zhou
[**@linus-hologram**]: https://github.com/linus-hologram

<!-- General links -->

Expand Down
8 changes: 7 additions & 1 deletion src/mqt/predictor/qcompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from mqt.predictor.rl import rl_compile

if TYPE_CHECKING:
from pathlib import Path

from qiskit import QuantumCircuit

from mqt.predictor.reward import figure_of_merit
Expand All @@ -24,16 +26,20 @@
def qcompile(
qc: QuantumCircuit,
figure_of_merit: figure_of_merit = "expected_fidelity",
tracer_output_path: str | Path | None = None,
) -> tuple[QuantumCircuit, list[str], str]:
"""Compiles a given quantum circuit to a device with the highest predicted figure of merit.

Arguments:
qc: The quantum circuit to be compiled.
figure_of_merit: The figure of merit to be used for compilation. Defaults to "expected_fidelity".
tracer_output_path: If provided, enables compiler tracing and exports the JSON log to this path/directory.

Returns:
A tuple containing the compiled quantum circuit, the compilation information, and the name of the device used for compilation.
"""
predicted_device = predict_device_for_figure_of_merit(qc, figure_of_merit=figure_of_merit)
res = rl_compile(qc, device=predicted_device, figure_of_merit=figure_of_merit)
res = rl_compile(
qc, device=predicted_device, figure_of_merit=figure_of_merit, tracer_output_path=tracer_output_path
)
return *res, predicted_device
16 changes: 6 additions & 10 deletions src/mqt/predictor/rl/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@

from __future__ import annotations

import os
import sys
import warnings
from collections import defaultdict
from dataclasses import dataclass
from enum import Enum
from typing import TYPE_CHECKING

from bqskit import MachineModel
from bqskit import compile as bqskit_compile
from pytket.architecture import Architecture
from pytket.passes import (
CliffordSimp,
Expand Down Expand Up @@ -78,7 +75,6 @@

from mqt.predictor.rl.parsing import (
PreProcessTKETRoutingAfterQiskitLayout,
get_bqskit_native_gates,
)

IS_WIN_PY313 = sys.platform == "win32" and sys.version_info[:2] == (3, 13)
Expand Down Expand Up @@ -366,7 +362,7 @@ def remove_action(name: str) -> None:
)
)

#register_action(
# register_action(
# DeviceDependentAction(
# "BQSKitO2",
# CompilationOrigin.BQSKIT,
Expand All @@ -380,7 +376,7 @@ def remove_action(name: str) -> None:
# num_workers=-1,
# ),
# )
#)
# )

register_action(
DeviceDependentAction(
Expand Down Expand Up @@ -526,7 +522,7 @@ def remove_action(name: str) -> None:
)
)

#register_action(
# register_action(
# DeviceDependentAction(
# "BQSKitMapping",
# CompilationOrigin.BQSKIT,
Expand All @@ -548,7 +544,7 @@ def remove_action(name: str) -> None:
# )
# ),
# )
#)
# )

register_action(
DeviceDependentAction(
Expand All @@ -561,7 +557,7 @@ def remove_action(name: str) -> None:
)
)

#register_action(
# register_action(
# DeviceDependentAction(
# "BQSKitSynthesis",
# CompilationOrigin.BQSKIT,
Expand All @@ -578,7 +574,7 @@ def remove_action(name: str) -> None:
# )
# ),
# )
#)
# )

register_action(
DeviceIndependentAction(
Expand Down
20 changes: 15 additions & 5 deletions src/mqt/predictor/rl/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
mdp: str = "paper",
path_training_circuits: Path | None = None,
logger_level: int = logging.INFO,
tracer_output_path: str | Path | None = None,
) -> None:
"""Initializes the Predictor object."""
logger.setLevel(logger_level)
Expand All @@ -49,6 +50,7 @@ def __init__(
device=device,
mdp=mdp,
path_training_circuits=path_training_circuits,
tracer_output_path=tracer_output_path,
)
self.device_name = device.description
self.figure_of_merit = figure_of_merit
Expand Down Expand Up @@ -178,6 +180,7 @@ def rl_compile(
device: Target | None,
figure_of_merit: figure_of_merit | None = "expected_fidelity",
predictor_singleton: Predictor | None = None,
tracer_output_path: str | Path | None = None,
) -> tuple[QuantumCircuit, list[str]]:
"""Compiles a given quantum circuit to a device optimizing for the given figure of merit.

Expand All @@ -186,6 +189,7 @@ def rl_compile(
device: The device to compile to.
figure_of_merit: The figure of merit to be used for compilation. Defaults to "expected_fidelity".
predictor_singleton: A predictor object that is used for compilation to reduce compilation time when compiling multiple quantum circuits. If None, a new predictor object is created. Defaults to None.
tracer_output_path: If provided, enables compiler tracing and exports the JSON log to the specified path.

Returns:
A tuple containing the compiled quantum circuit and the compilation information. If compilation fails, False is returned.
Expand All @@ -200,8 +204,14 @@ def rl_compile(
if device is None:
msg = "device must not be None if predictor_singleton is None."
raise ValueError(msg)
predictor = Predictor(figure_of_merit=figure_of_merit, device=device)
else:
predictor = predictor_singleton

return predictor.compile_as_predicted(qc)
predictor = Predictor(figure_of_merit=figure_of_merit, device=device, tracer_output_path=tracer_output_path)
return predictor.compile_as_predicted(qc)

# use singleton and restore tracer path afterward
predictor = predictor_singleton
original_tracer_output_path = predictor.env.tracer_output_path
predictor.env.tracer_output_path = tracer_output_path
try:
return predictor.compile_as_predicted(qc)
finally:
predictor.env.tracer_output_path = original_tracer_output_path
Loading
Loading