Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing wire_names raises ValueError: The circuit qubits are not in the connectivity graph. #1550

Open
BrunoLiegiBastonLiegi opened this issue Dec 20, 2024 · 5 comments

Comments

@BrunoLiegiBastonLiegi
Copy link
Contributor

BrunoLiegiBastonLiegi commented Dec 20, 2024

Running a circuit on the qw11q at the qrc cluster fails with a transpiler error if the wire_names are not specified, or if they are but don't have the names found in the runcard https://github.com/qiboteam/qibolab_platforms_qrc/blob/0.1/qw11q/parameters.json.

from qibo import Circuit, gates, set_backend, get_transpiler, get_backend

c = Circuit(5)
c.add(gates.GPI2(0, 0.))
c.add(gates.GPI2(1, 0.))
c.add(gates.GPI2(2, 0.))
c.add(gates.M(0, 1, 2))

wire_names = [
        "A1",
        "A2",
        "A3",
        "A4",
        "A5",
    ]

#c.wire_names = wire_names

c.draw()

bkd = get_backend()
transp = get_transpiler()

c, _ = transp(c)

r = bkd.execute_circuit(c)

print(r.frequencies())
2024-12-20 09:24:08,180 - qm - INFO     - Starting session: ea445a24-c586-43f9-899e-51a6144f7a9d
Traceback (most recent call last):
  File "/nfs/users/andrea.papaluca/test.py", line 36, in <module>
    c, _ = transp(c)
  File "/home/users/andrea.papaluca/envs/qibo/lib/python3.10/site-packages/qibo/transpiler/pipeline.py", line 84, in __call__
    circuit = transpiler_pass(circuit)
  File "/home/users/andrea.papaluca/envs/qibo/lib/python3.10/site-packages/qibo/transpiler/optimizer.py", line 23, in __call__
    raise_error(
  File "/home/users/andrea.papaluca/envs/qibo/lib/python3.10/site-packages/qibo/config.py", line 46, in raise_error
    raise exception(message)
ValueError: The circuit qubits are not in the connectivity graph.
srun: error: fahid: task 0: Exited with exit code 1

I am not sure whether this is an expected behaviour, but if it is I would argue it is not very user friendly.

@alecandido
Copy link
Member

alecandido commented Dec 20, 2024

I am not sure whether this is an expected behaviour, but if it is I would argue it is not very user friendly.

The "not-the-best" issues are not extremely useful. If we had many more issues to triage, I'd be tempted to close them right away.

In general, you should qualify an issue as either a bug report or feature request. That in the end boil down to the same resolution process: clarify what is happening, and aim for something different. In short, they both require a proposal of an alternative behavior (more or less specific).

If you do not have any clear plan for anything better, but you'd like to discuss an alternative anyhow, to stimulate ideas from other contributors, a discussion (https://github.com/qiboteam/qibo/discussions/) may be more appropriate.

Notice that you can always convert between the two kinds.
image

@BrunoLiegiBastonLiegi
Copy link
Contributor Author

BrunoLiegiBastonLiegi commented Dec 20, 2024

Well, this is pretty clearly a problem in my opinion. I did not mark it as a bug (yet) because I usually wait until someone who is more familiar with the specific part of the code confirms that it is indeed a problem.

I clarified the problem and provided the code to reproduce it (the proposal is somewhat implicit: don't require the user to know which are the names of the qubits in the runcard), thus, this to me has the dignity to remain an issue.

@alecandido
Copy link
Member

I clarified the problem and provided the code to reproduce it, thus, this to me has the dignity to remain an issue.

The comment above was not much directed to the problem (which I'm just not judging) or its description (which is arguably detailed). But rather what you would expect as a solution.

Whenever there is something ambiguous in the specification, failing is a decent alternative. Surprises are much worse than failures, and harder to debug. The error itself is also pretty telling.

You may still desire a different behavior, and discussing it would be definitely appreciated. But you should then explain which is the behavior that you wish/would expect.

@BrunoLiegiBastonLiegi
Copy link
Contributor Author

Sorry, I edited the answer to add it.
As I wrote above the proposed preferred behaviour is somewhat implicit: not making the user look for the name of the qubits in the runcard to run a circuit on the device through automatic transpilation.

(which is arguably detailed)

let me know which other details you need.

Btw, I did not find any documentation about the use of the wire_names in combination with the transpiler and how you are supposed to use the global transpiler to run a circuit with qibolab. Actually, there is not even an API reference page on the transpiler, but just a code example showing how to define a custom transpiler, which would definetly benefit from a second look. This could be part of the issue as well, if you wish.

@alecandido
Copy link
Member

Btw, I did not find any documentation about the use of the wire_names in combination with the transpiler and how you are supposed to use the global transpiler to run a circuit with qibolab. Actually, there is not even an API reference page on the transpiler, but just a code example showing how to define a custom transpiler, which would definetly benefit from a second look. This could be part of the issue as well, if you wish.

This was the purpose of this PR, #1531, which should not be released yet.
But if you want to expand it, you're definitely more than welcome.

As I wrote above the proposed preferred behaviour is somewhat implicit: not making the user look for the name of the qubits in the runcard to run a circuit on the device through automatic transpilation.

As it has been discussed during some presentation, the idea is that you want to look at the platform and select the qubits you prefer. Or at least you want to be able to do that.

Now, you may argue that you also want automatic placement to happen if you do not specify any. I'm not sure why it's not happening with the default transpiler, but if it's what you want, it should be fairly simple to implement.

In any case, since Qibo is not deployed on any production system, automatic placement is something that is barely useful in practice, because it would not take into account the qubits calibration (this is what @csookim started working on at the end of November), and the result of anything else would be poor and unusable.
Still, you may directly aim for the long term, and make automatic placement happen immediately if .wire_names are not specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants