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

KeyError: 'GPI' #1093

Closed
scarrazza opened this issue Nov 3, 2024 · 15 comments
Closed

KeyError: 'GPI' #1093

scarrazza opened this issue Nov 3, 2024 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@scarrazza
Copy link
Member

After installing qibolab 0.1.10, the the following code:

import qibo
c = qibo.Circuit(17)
c.add(qibo.gates.GPI2(12,0))
c.add(qibo.gates.M(12))
result = c(nshots=100)
print(result.samples())
print(result.frequencies())

executed with module load qibo crashes on qw11q with:

2024-11-03 18:25:04,167 - qm - INFO     - Starting session: 903803b8-8d72-48e9-9dc3-0c438f6b5251
Traceback (most recent call last):
  File "/nfs/users/stefano.carrazza/h.py", line 14, in <module>
    result = c(nshots=100)
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/models/circuit.py", line 1116, in __call__
    return self.execute(initial_state=initial_state, nshots=nshots)
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/models/circuit.py", line 1105, in execute
    transpiler = _Global.transpiler()
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/backends/__init__.py", line 126, in transpiler
    cls._transpiler = cls._default_transpiler()
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/backends/__init__.py", line 163, in _default_transpiler
    Unroller(NativeGates[natives]),
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/transpiler/unroller.py", line 26, in __getitem__
    return reduce(or_, [cls[key] for key in keys])  # pylint: disable=E1136
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/transpiler/unroller.py", line 26, in <listcomp>
    return reduce(or_, [cls[key] for key in keys])  # pylint: disable=E1136
  File "/nfs/tools/qibo/lib/python3.10/site-packages/qibo/transpiler/unroller.py", line 25, in __getitem__
    return super().__getitem__(keys)
  File "/usr/lib/python3.10/enum.py", line 440, in __getitem__
    return cls._member_map_[name]
KeyError: 'GPI'

@csookim could you please check?

@scarrazza scarrazza added the bug Something isn't working label Nov 3, 2024
@stavros11
Copy link
Member

stavros11 commented Nov 3, 2024

I think the fix is in qiboteam/qibo#1504.

@alecandido
Copy link
Member

I think the fix is in qiboteam/qibo#1504.

Indeed, I believe that was the main motivation behind qiboteam/qibo#1504

@scarrazza
Copy link
Member Author

We should do more testing before making releases to avoid these kinds of bugs.

@alecandido
Copy link
Member

We should do more testing before making releases to avoid these kinds of bugs.

In this specific case, I believe Qibolab v0.1.10 is fine, we won't need to fix anything.

The problem is that the Qibo side has never been completed (we could have tested more in qiboteam/qibo#1440, but in principle that PR was about the global backend, while we're still waiting for the Qibolab-compatibility support).

@csookim
Copy link
Member

csookim commented Nov 4, 2024

We should do more testing before making releases to avoid these kinds of bugs.

The issue is on the Qibo side: Qibo was supposed to raise an error when it received a gate that cannot be used as a native gate.

https://github.com/qiboteam/qibo/blob/22d51946add6739a3e970f32ee8cdd0bd70f5d2d/src/qibo/transpiler/unroller.py#L67-L68

https://github.com/qiboteam/qibo/blob/22d51946add6739a3e970f32ee8cdd0bd70f5d2d/tests/test_transpiler_unroller.py#L19-L21

I have merged qiboteam/qibo#1504, and we should patch it to enable circuit execution. Do we need to wait for qibo 0.2.14?

@alecandido
Copy link
Member

I have merged qiboteam/qibo#1504, and we should patch it to enable circuit execution. Do we need to wait for qibo 0.2.14?

We need the .wire_names in any case, so we should complete qiboteam/qibo#1500. No reason to anticipate the next release before that.

Current testing can be done with master. Releasing before that may lead to a similar problem with the next one (missing required features/not enough testing).

@scarrazza
Copy link
Member Author

On top of that, we should try to propose symultaneously a set of runcards (or sliced runcards) that works for at least the lines we are calibrating (D and B) for qw11q. At the moment, setting more than 11 qubits will generate an error message.

@alecandido
Copy link
Member

Ok, this is pretty weird, since there are 16 qubits in the platform

https://github.com/qiboteam/qibolab_platforms_qrc/blob/9e80f12ee40436eb9c3582747b09499dbc0f692f/qw11q/parameters.json#L7-L24

(mostly not calibrated, but they should all be exposed)

@scarrazza
Copy link
Member Author

Thanks @alecandido, indeed with 16 qubits it works. I have installed the latest qibo main in the cluster.

@alecandido
Copy link
Member

@csookim could you investigate and report about the mentioned error?

@scarrazza
Copy link
Member Author

I believe this is okay @alecandido. My example was using 17 qubits instead of 16. Using 16 works fine.

@csookim
Copy link
Member

csookim commented Nov 4, 2024

@csookim could you investigate and report about the mentioned error?

The KeyError: 'GPI' error? Yes, this occurred because there wasn't a specific rule to handle native gates between qibo and qibolab. qiboteam/qibo#1504 resolved this issue. I am testing whether transpiler works well by creating qw5q_dummy and qw11q_dummy.

@scarrazza Could you give me permission to create a branch in qibolab_platforms_qrc? I would like to make a branch that includes the qw5q_dummy and qw11q_dummy models. This branch will not be merged; just for simulating the connection on the CPU.

@scarrazza
Copy link
Member Author

@csookim please go ahead, you should have write access now.

@alecandido
Copy link
Member

@scarrazza did you have a chance to test whether this problem is still there? Hopefully, now that qiboteam/qibo#1504 has been merged, it should have been finally solved :)

@scarrazza
Copy link
Member Author

Yes, we can close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants