Skip to content

Commit 2c657e8

Browse files
addressing more review comments
1 parent d25aaa0 commit 2c657e8

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

qiskit/transpiler/passes/synthesis/hls_plugins.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -1799,14 +1799,14 @@ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **
17991799

18001800
if data is None or input_qubits is None:
18011801
raise TranspilerError(
1802-
"HighLevelSynthesis: problem with the default plugin for annotated operations."
1802+
"The AnnotatedSynthesisDefault plugin should receive data and input_qubits via options."
18031803
)
18041804

18051805
if len(modifiers) > 0:
18061806
num_ctrl = sum(
18071807
mod.num_ctrl_qubits for mod in modifiers if isinstance(mod, ControlModifier)
18081808
)
1809-
total_power = sum(mod.power for mod in modifiers if isinstance(mod, PowerModifier))
1809+
power = sum(mod.power for mod in modifiers if isinstance(mod, PowerModifier))
18101810
is_inverted = sum(1 for mod in modifiers if isinstance(mod, InverseModifier)) % 2
18111811

18121812
# The base operation cannot use control qubits as auxiliary qubits.
@@ -1816,7 +1816,7 @@ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **
18161816
# their previous state, so clean qubits remain clean after each for- or while- loop.
18171817
annotated_tracker = tracker.copy()
18181818
annotated_tracker.disable(input_qubits[:num_ctrl]) # do not access control qubits
1819-
if total_power != 0 or is_inverted:
1819+
if power != 0 or is_inverted:
18201820
annotated_tracker.set_dirty(input_qubits)
18211821

18221822
# First, synthesize the base operation of this annotated operation.
@@ -1844,11 +1844,6 @@ def run(self, high_level_object, coupling_map=None, target=None, qubits=None, **
18441844
# a lot of sense to allow this in the future.
18451845
synthesized = self._apply_annotations(synthesized_base_op, operation.modifiers)
18461846

1847-
if not isinstance(synthesized, QuantumCircuit):
1848-
raise TranspilerError(
1849-
"HighLevelSynthesis: problem with the default plugin for annotated operations."
1850-
)
1851-
18521847
return synthesized
18531848

18541849
return None
@@ -1858,18 +1853,14 @@ def _apply_annotations(circuit: QuantumCircuit, modifiers: list[Modifier]) -> Qu
18581853
"""
18591854
Applies modifiers to a quantum circuit.
18601855
"""
1861-
1862-
if not isinstance(circuit, QuantumCircuit):
1863-
raise TranspilerError("HighLevelSynthesis: incorrect input to 'apply_annotations'.")
1864-
18651856
for modifier in modifiers:
18661857
if isinstance(modifier, InverseModifier):
18671858
circuit = circuit.inverse()
18681859

18691860
elif isinstance(modifier, ControlModifier):
18701861
if circuit.num_clbits > 0:
18711862
raise TranspilerError(
1872-
"HighLevelSynthesis: cannot control a circuit with classical bits."
1863+
"AnnotatedSynthesisDefault: cannot control a circuit with classical bits."
18731864
)
18741865

18751866
# Apply the control modifier to each gate in the circuit.
@@ -1901,17 +1892,14 @@ def _apply_annotations(circuit: QuantumCircuit, modifiers: list[Modifier]) -> Qu
19011892

19021893
if isinstance(circuit, AnnotatedOperation):
19031894
raise TranspilerError(
1904-
"HighLevelSynthesis: failed to synthesize the control modifier."
1895+
"AnnotatedSynthesisDefault: failed to synthesize the control modifier."
19051896
)
19061897

19071898
elif isinstance(modifier, PowerModifier):
19081899
circuit = circuit.power(modifier.power)
19091900

19101901
else:
1911-
raise TranspilerError(f"HighLevelSynthesis: Unknown modifier {modifier}.")
1912-
1913-
if not isinstance(circuit, QuantumCircuit):
1914-
raise TranspilerError("HighLevelSynthesis: incorrect output of 'apply_annotations'.")
1902+
raise TranspilerError(f"AnnotatedSynthesisDefault: Unknown modifier {modifier}.")
19151903

19161904
return circuit
19171905

0 commit comments

Comments
 (0)