QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
97 stars 44 forks source link

Mapper doesn't take into account distance between communication qubits in an inter-core communication #476

Closed rturrado closed 1 year ago

rturrado commented 1 year ago

The code below, at OpenQL\src\ql\pass\map\qubits\map\detail\mapper.cc, doesn't take into account that two communication qubits in different cores are not mappable:

// Find minimum number of hops between real counterparts.
UInt d = platform->topology->get_min_hops(src, tgt);

if (d == 1) {

    // Just one hop, so gate is already nearest-neighbor and can
    // be mapped.
    QL_DOUT(". NN gate, to be mapped: " << gate->qasm() << " in real (q" << src << ",q" << tgt << ")");
    map_routed_gate(gate, past);
    QL_DOUT(". NN gate, to be set to completed: " << gate->qasm() );
    future.completed_gate(gate);
    found = true;    // a 2q quantum gate was found that was mappable
    // so on avlist= nonNN2q -> NN2q: the NN2q is done first
    break;

}

We should change it into something like:

if (platform->topology->qubits_are_nearest_neighbors(src, tgt) &&
    platform->topology->qubits_can_be_mapped(src, tgt)) {

    QL_DOUT(". NN gate, to be mapped: " << gate->qasm() << " in real (q" << src << ",q" << tgt << ")");
    map_routed_gate(gate, past);
    QL_DOUT(". NN gate, to be set to completed: " << gate->qasm() );
    future.completed_gate(gate);
    found = true;    // a 2q quantum gate was found that was mappable
    // so on avlist= nonNN2q -> NN2q: the NN2q is done first
    break;

}
rturrado commented 1 year ago

This is not an issue since get_min_hops can only return 1 for the case of two qubits in the same core.

I.e., for two communication qubits in different cores, get_min_hops won't return 1, so the code above doesn't take that case into account.

I will do a separate commit however with some other changes, including an update to get_min_hops code.