From 5fab5f896c85e70fb623f3ae7128e537fefe35c3 Mon Sep 17 00:00:00 2001 From: Manideep3969 Date: Wed, 19 Aug 2026 16:19:13 +0530 Subject: [PATCH] fix(#46): correct autotuning search space docs from 648 to 216 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docstring claimed 648 configs (3 routing × 3 layout × 4 opt × 3 seed × 2 fusion × 3 scheduling) but the implementation generates 216 configs (2 routing × 2 layout × 3 opt × 3 seed × 2 fusion × 3 scheduling). The 'vf2' routing method, 'trivial' layout, and optimization level 0 are intentionally excluded. Update module docstring, _generate_configurations docstring, and paper outline to match the actual 216-config search space. Add 4 regression tests verifying search space dimensions. --- docs/notes/06-paper-outline.md | 4 ++-- src/qc_compiler/autotuning.py | 12 ++++++------ tests/test_autotuning.py | 29 ++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/docs/notes/06-paper-outline.md b/docs/notes/06-paper-outline.md index 66ff8a5..d1cff7f 100644 --- a/docs/notes/06-paper-outline.md +++ b/docs/notes/06-paper-outline.md @@ -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. @@ -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) diff --git a/src/qc_compiler/autotuning.py b/src/qc_compiler/autotuning.py index f8b30bf..7b17c8c 100644 --- a/src/qc_compiler/autotuning.py +++ b/src/qc_compiler/autotuning.py @@ -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 @@ -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. diff --git a/tests/test_autotuning.py b/tests/test_autotuning.py index b37ac42..9d30277 100644 --- a/tests/test_autotuning.py +++ b/tests/test_autotuning.py @@ -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 \ No newline at end of file + 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} \ No newline at end of file