bqskit icon indicating copy to clipboard operation
bqskit copied to clipboard

Usign the with_mapping=True option in bqskit.compiler() does not return a full mapping when no qubits are remapped

Open n-ion opened this issue 8 months ago • 2 comments

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.

     ┌───┐      
q_0: ┤ X ├──────
     └─┬─┘┌────┐
q_1: ──┼──┤ √X ├
       │  └────┘
q_2: ──■────────
                

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]?

n-ion avatar Jun 26 '24 03:06 n-ion