qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
288 stars 57 forks source link

Transpiler padding #1429

Open alecandido opened 3 weeks ago

alecandido commented 3 weeks ago

Currently, the transpiler is already providing some padding https://github.com/qiboteam/qibo/blob/ecbd16d7d8f2b6780bacbb7b92c9f2b3fc44087b/src/qibo/transpiler/optimizer.py#L19-L33 but just applying the basic approach, i.e. padding at the end.

However, there is not much more that can be done at the moment, since Qibolab does not support using its own qubits' names in circuits. https://github.com/qiboteam/qibolab/issues/1009

As soon as that will be available, it would be interesting to offer the option to choose which subset of qubits should be targeted. And applying padding only at the end.

This last part could be done even immediately: sometimes it may be interesting to route a circuit on a subset of the whole qubits and connectivity (even though some subsets will make impossible to execute some circuits), so padding as preprocessing and padding as postprocessing are truly two different features, and only the first is currently available (unless I'm missing something).

alecandido commented 3 weeks ago

@Simone-Bordoni can you take a look at the description? I'm not asking you to implement anything of what I described. And maybe it's not even urgent to anything at all. But at least I would have a consistent issue for when someone will be able to take over the project.

csookim commented 3 weeks ago

Similarly, I'd like to open an issue about the naming of qubits and nodes in the connectivity graph. Would it be better to discuss this here, or should I create a separate issue?

alecandido commented 3 weeks ago

Similarly, I'd like to open an issue about the naming of qubits and nodes in the connectivity graph. Would it be better to discuss this here, or should I create a separate issue?

The two things are related, and they will be most likely solved together. Feel free to discuss it even here :) (but if you have a different opinion, do what you consider best)

csookim commented 3 weeks ago

Currently, the transpiler is designed to interpret integer connectivity graph nodes i as string physical qubit names "q" + str(i).

https://github.com/qiboteam/qibo/blob/21732ad59d31740e8c0641921abe98e49a1ea8c1/src/qibo/transpiler/placer.py#L203-L205

For example, consider the connectivity graph:

Screenshot 2024-08-29 at 19 56 06

and the physical-to-logical mapping:

{'q0': 4, 'q1': 0, 'q2': 2, 'q3': 1, 'q4': 3}.

If we want to enable custom string names for qubits, the naming scheme will need to be updated.

Possible options are:

  1. Use the same names for connectivity graph nodes and physical qubits.
  2. Only allow numerical names for hardware qubits.
  3. Continue using the current method when hardware qubit names are numerical; otherwise, use the same names for both nodes and qubits.
Simone-Bordoni commented 3 weeks ago

At the moment it is possible to select a subset of qubits in the connectivity when defining a transpiling pipeline (PR #1121). You can't restric the connectivity if using a single transpiler step, however in that case it would be just sufficient to manually remove the nodes from the connectivity graph. On the other hand, i think it would be important to allow for general names of the names of the graph (not only "qi"). However, i think it is important to have the requirement that the names of the connectivity graph match the names of the hardware qubits in order to avoid confusion.

alecandido commented 3 weeks ago

However, i think it is important to have the requirement that the names of the connectivity graph match the names of the hardware qubits in order to avoid confusion.

Yes, indeed. That's why I linked immediately https://github.com/qiboteam/qibolab/issues/1009, as a "dependency" of this issue (there are parts of this issue that could be worked on before, but that has to be solved first to complete this).

csookim commented 3 weeks ago

Thanks, then I will update the Placer and test files to use the same names for connectivity graph nodes and hardware qubit names (wire_names) in qibo side.