qiboteam/qibo

Transpiler fails if run twice on the same circuit

Closed this issue · 0 comments

Running the transpiler example in the docs fails if you try to transpile a copy of the initial circuit a second time.
Namely, doing something like:

transpiled_circ, final_layout = custom_pipeline(circuit)
custom_pipeline(circuit.copy())

raises the error:

[Qibo 0.2.9|ERROR|2024-06-10 10:49:06]: You are defining more than one placer pass.
---------------------------------------------------------------------------
TranspilerPipelineError                   Traceback (most recent call last)
Cell In[4], line 1
----> 1 custom_pipeline(circuit.copy(True))

File ~/git/qibo/src/qibo/transpiler/pipeline.py:238, in Passes.__call__(self, circuit)
    236         self.initial_layout = transpiler_pass(circuit)
    237     else:
--> 238         raise_error(
    239             TranspilerPipelineError,
    240             "You are defining more than one placer pass.",
    241         )
    242 elif isinstance(transpiler_pass, Router):
    243     transpiler_pass.connectivity = self.connectivity

File ~/git/qibo/src/qibo/config.py:46, in raise_error(exception, message)
     39 """Raise exception with logging error.
     40 
     41 Args:
     42     exception (Exception): python exception.
     43     message (str): the error message.
     44 """
     45 log.error(message)
---> 46 raise exception(message)

TranspilerPipelineError: You are defining more than one placer pass.

I am not sure whether this is an intended behaviour, but if that's the case a warning in the docs or a more detailed error should be provided.