Skip to content

Commit

Permalink
Merge pull request #75 from BQSKit/0.5.1
Browse files Browse the repository at this point in the history
0.5.1
  • Loading branch information
edyounis committed Apr 16, 2022
2 parents 1a185b7 + 3dfa446 commit 62ad0f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
40 changes: 28 additions & 12 deletions bqskit/exec/runners/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from bqskit.compiler import CompilationTask
from bqskit.compiler import Compiler
from bqskit.compiler import MachineModel
from bqskit.exec.results import RunnerResults
from bqskit.exec.runner import CircuitRunner
from bqskit.ir.circuit import Circuit
Expand All @@ -19,6 +20,7 @@
from bqskit.ir.operation import Operation
from bqskit.ir.point import CircuitPoint
from bqskit.passes.control import ForEachBlockPass
from bqskit.passes.layout import SimpleLayoutPass
from bqskit.passes.partitioning import QuickPartitioner
from bqskit.passes.synthesis import LEAPSynthesisPass

Expand All @@ -43,6 +45,7 @@ def __init__(
pert: int = 100,
approx_threshold: float | None = None,
sample_size: int = 16,
model: MachineModel | None = None,
instantiate_options: dict[str, Any] = {},
) -> None:
"""
Expand Down Expand Up @@ -71,6 +74,8 @@ def __init__(
sample_size (int): The number of approximations to generate.
model (MachineModel | None): The model to compile to.
instantiate_options (dict[str, Any]): Options passed directly
to instantiation.
"""
Expand All @@ -81,6 +86,7 @@ def __init__(
self.pert = pert
self.approx_threshold = approx_threshold
self.sample_size = sample_size
self.model = model
self.instantiate_options = instantiate_options

def run(self, circuit: Circuit) -> RunnerResults:
Expand All @@ -91,12 +97,14 @@ def run(self, circuit: Circuit) -> RunnerResults:
store_partial_solutions=True,
instantiate_options=self.instantiate_options,
)
task = CompilationTask(
circuit.copy(), [
QuickPartitioner(self.block_size),
ForEachBlockPass(synthesis_pass),
],
)
pass_list = [
QuickPartitioner(self.block_size),
ForEachBlockPass(synthesis_pass),
]
if self.model is not None:
pass_list.insert(0, SimpleLayoutPass(self.model))

task = CompilationTask(circuit.copy(), pass_list)

started = False
if self.compiler is None:
Expand Down Expand Up @@ -307,6 +315,7 @@ def gen_approximate_circuits(
pert: int = 100,
approx_threshold: float | None = None,
sample_size: int = 16,
model: MachineModel | None = None,
instantiate_options: dict[str, Any] = {},
) -> list[Circuit]:
"""
Expand All @@ -332,6 +341,8 @@ def gen_approximate_circuits(
sample_size (int): The number of approximations to generate.
model (MachineModel | None): The model to compile to.
instantiate_options (dict[str, Any]): Options passed directly
to instantiation.
"""
Expand All @@ -340,12 +351,15 @@ def gen_approximate_circuits(
store_partial_solutions=True,
instantiate_options=instantiate_options,
)
task = CompilationTask(
circuit.copy(), [
QuickPartitioner(block_size),
ForEachBlockPass(synthesis_pass),
],
)
pass_list = [
QuickPartitioner(block_size),
ForEachBlockPass(synthesis_pass),
]
if model is not None:
pass_list.insert(0, SimpleLayoutPass(model))

task = CompilationTask(circuit.copy(), pass_list)

started = False
if compiler is None:
compiler = Compiler()
Expand All @@ -362,6 +376,8 @@ def gen_approximate_circuits(
pert,
approx_threshold,
sample_size,
model,
instantiate_options,
)

data = compiler.analyze(task, ForEachBlockPass.key)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = bqskit
version = 0.5.0
version = 0.5.1
description = Berkeley Quantum Synthesis Toolkit
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit 62ad0f3

Please sign in to comment.