Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions docs/notes/06-paper-outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ AutoTVM and Triton search over kernel implementation variants (tiling, unrolling

### 10.2 Quantum Adaptation

Qiskit's transpiler offers routing methods (stochastic, VF2), layout methods (trivial, VF2Layout, dense), and optimization levels (0–3). But there is no systematic autotuning over these options for a specific circuit-device pair.
Qiskit's transpiler offers routing methods (stochastic, sabre), layout methods (dense, VF2Layout), optimization levels (1–3), and scheduling methods (ASAP, ALAP, coherence-aware). But there is no systematic autotuning over these options for a specific circuit-device pair.

We propose **quantum autotuning**: search over transpilation configurations, benchmark each on the target device, and select the optimal one.

Expand Down Expand Up @@ -525,7 +525,7 @@ Algorithm:
**Objective:** Show that autotuning transpiler settings outperforms defaults.

**Protocol:**
1. Define search space: 3 routing × 3 layout × 4 opt_levels × 3 seeds × 2 fusion = 216 configurations
1. Define search space: 2 routing × 2 layout × 3 opt_levels × 3 seeds × 2 fusion × 3 scheduling = 216 configurations
2. For each benchmark circuit:
a. Transpile with each configuration, estimate error
b. Select top-5 configurations, run on hardware with 1024 shots (screening)
Expand Down
12 changes: 6 additions & 6 deletions src/qc_compiler/autotuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
device-optimal one, then caches results for similar circuit families.

The search space includes:
- routing_method: stochastic, vf2, sabre
- layout_method: trivial, dense, vf2_layout
- optimization_level: 0, 1, 2, 3
- routing_method: stochastic, sabre
- layout_method: dense, vf2_layout
- optimization_level: 1, 2, 3
- seed: 0, 1, 2 (randomness in routing/layout)
- gate_fusion: on/off
- scheduling_method: asap, alap, coherence_aware
Expand Down Expand Up @@ -260,9 +260,9 @@ def _generate_configurations(self) -> list[TranspileConfig]:

Returns a reduced set of configurations that covers the most
impactful parameter combinations. The full search space
(3 routing × 3 layout × 4 opt × 3 seed × 2 fusion × 3 scheduling
= 648 configs) is reduced by only varying the most impactful
parameters together.
(2 routing × 2 layout × 3 opt × 3 seed × 2 fusion × 3 scheduling
= 216 configs) varies the most impactful parameters
together.

Returns:
List of TranspileConfig objects to evaluate.
Expand Down
29 changes: 28 additions & 1 deletion tests/test_autotuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,31 @@ def test_search_with_backend_sets_best_circuit(self, tuner_with_backend):
qc, circuit_family="test_best_circuit"
)
if result.best_circuit is not None:
assert result.best_circuit.num_qubits == qc.num_qubits
assert result.best_circuit.num_qubits == qc.num_qubits


class TestSearchSpace:
"""Regression tests for autotuning search space size (issue #46)."""

def test_search_space_size_is_216(self):
tuner = AutoTuner(cost_model=CostModel())
configs = tuner._generate_configurations()
assert len(configs) == 216

def test_search_space_covers_all_routing_methods(self):
tuner = AutoTuner(cost_model=CostModel())
configs = tuner._generate_configurations()
routing_methods = {c.routing_method for c in configs}
assert routing_methods == {"stochastic", "sabre"}

def test_search_space_covers_all_layout_methods(self):
tuner = AutoTuner(cost_model=CostModel())
configs = tuner._generate_configurations()
layout_methods = {c.layout_method for c in configs}
assert layout_methods == {"dense", "vf2_layout"}

def test_search_space_covers_all_optimization_levels(self):
tuner = AutoTuner(cost_model=CostModel())
configs = tuner._generate_configurations()
opt_levels = {c.optimization_level for c in configs}
assert opt_levels == {1, 2, 3}
Loading