When running bqskit.compile() with the with_mapping=True parameter, if the compiler does not do any qubit re-mapping or re-routing, then the returned values of initial_mapping and final_mapping appear to be [0], instead of a list with length equal to the number of qubits. Would it be better to return the initial unremapped layout instead for consistency?
For example, the following circuit, when compiled with optimization level 1 or 2 does not seem to cause any re-mapping or re-routing.
The compiler therefore returns [0] for both initial_mapping and final_mapping .
However, when compiled with optimization level 4, some re-mapping occured and the compiler returned [0, 1, 2] for initial_mapping and [2, 1, 0] for final_mapping (I assume this is only one possible remapping, it could change from run to run).
In this scenario, would it be more consistent if the returned value for initial_mapping and final_mapping in the optimization level 1 case was just [0, 1, 2]?
Yes, definitely! Good catch. We should be returning the trivial mapping in the case where nothing is done. Is this something you would be interested in fixing?
Looking at this line, I would expect this to be the case already. It seems this is, therefore, a bug.
When running
bqskit.compile()
with thewith_mapping=True
parameter, if the compiler does not do any qubit re-mapping or re-routing, then the returned values ofinitial_mapping
andfinal_mapping
appear to be[0]
, instead of a list with length equal to the number of qubits. Would it be better to return the initial unremapped layout instead for consistency?For example, the following circuit, when compiled with optimization level 1 or 2 does not seem to cause any re-mapping or re-routing.
The compiler therefore returns
[0]
for bothinitial_mapping
andfinal_mapping
.However, when compiled with optimization level 4, some re-mapping occured and the compiler returned
[0, 1, 2]
forinitial_mapping
and[2, 1, 0]
forfinal_mapping
(I assume this is only one possible remapping, it could change from run to run).In this scenario, would it be more consistent if the returned value for
initial_mapping
andfinal_mapping
in the optimization level 1 case was just[0, 1, 2]
?