Skip to content

Commit

Permalink
[feature] Make SimplifyInitial opt-in (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Oct 5, 2023
1 parent 1bd4eb3 commit 8177183
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
~~~~~~~~~

Unreleased
----------

* Don't include ``SimplifyInitial`` in default passes; instead make it an option
to ``process_circuits()``.

0.7.0 (October 2023)
--------------------

Expand Down
19 changes: 12 additions & 7 deletions pytket/extensions/iqm/backends/iqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass:
passes.append(DelayMeasures())
passes.append(self.rebase_pass())
passes.append(RemoveRedundancies())
if optimisation_level >= 1:
passes.append(
SimplifyInitial(
allow_classical=False, create_all_qubits=True, xcirc=_xcirc
)
)
return SequencePass(passes)

@property
Expand All @@ -203,7 +197,13 @@ def process_circuits(
) -> List[ResultHandle]:
"""
See :py:meth:`pytket.backends.Backend.process_circuits`.
Supported kwargs: `postprocess`.
Supported `kwargs`:
- `postprocess`: apply end-of-circuit simplifications and classical
postprocessing to improve fidelity of results (bool, default False)
- `simplify_initial`: apply the pytket ``SimplifyInitial`` pass to improve
fidelity of results assuming all qubits initialized to zero (bool, default
False)
"""
circuits = list(circuits)
n_shots_list = Backend._get_n_shots_as_list(
Expand All @@ -216,6 +216,7 @@ def process_circuits(
self._check_all_circuits(circuits)

postprocess = kwargs.get("postprocess", False)
simplify_initial = kwargs.get("postprocess", False)

handles = []
for i, (c, n_shots) in enumerate(zip(circuits, n_shots_list)):
Expand All @@ -224,6 +225,10 @@ def process_circuits(
ppcirc_rep = ppcirc.to_dict()
else:
c0, ppcirc_rep = c, None
if simplify_initial:
SimplifyInitial(
allow_classical=False, create_all_qubits=True, xcirc=_xcirc
).apply(c0)
instrs = _translate_iqm(c0)
qm = {str(qb): _as_name(cast(Node, qb)) for qb in c.qubits}
iqmc = IQMCircuit(
Expand Down

0 comments on commit 8177183

Please sign in to comment.