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

Align is not supported by OpenQASM #1478

Open
Rumoa opened this issue Oct 8, 2024 · 9 comments · May be fixed by #1481
Open

Align is not supported by OpenQASM #1478

Rumoa opened this issue Oct 8, 2024 · 9 comments · May be fixed by #1481
Labels
enhancement New feature or request

Comments

@Rumoa
Copy link

Rumoa commented Oct 8, 2024

Implementation of Align matrix is not supported by OpenQASM
I am trying to implement a delay gate, equivalent to the one from qiskit. Since in the documentation there is no delay gate, I thought Align could be used as it allows to add a delay as parameter function.

When trying to run a simple circuit with this gate:

from qibo import gates
from qibo.models import Circuit

from qiboconnection import API

api = API.login(username="insert_your_user_id", api_key="insert_your_api_key")



c = Circuit(1)
c.add(gates.X(0))
c.add(gates.Align(0, delay=int(1)))
c.add(gates.M(0))


job_id = api.execute(circuit=c, device_id=1)

result = api.get_job(job_id).result

the following errors appears:

[Qibo 0.2.8|ERROR|2024-10-08 12:35:57]: Align is not supported by OpenQASM

Is there any other way to implement the delay gate?

Thank you in advance

@Rumoa Rumoa added the bug Something isn't working label Oct 8, 2024
@alecandido alecandido added enhancement New feature or request and removed bug Something isn't working labels Oct 8, 2024
@alecandido
Copy link
Member

Align is the Delay, so it's not missing. And Delay would have been even a better name for the Qibo one, since we have a lower level Align instruction which is doing something slightly different (and Delay as well, which is what the Align gate is translated to on hardware).

However, here the problem is in the QASM translation, which is not turning Align into Delay, because it's mainly matching by name. But it could be patched. @BrunoLiegiBastonLiegi can estimate how much it may take to do that.

Btw, your example is incomplete, since you're using api without defining or importing it - please, try to provide a self-consistent reproduction.

@Rumoa
Copy link
Author

Rumoa commented Oct 8, 2024

Thank you for the clarification. I did not include the api part in the example bc of personal info, but now it has been fixed so it can be reproduced with an actual hardware credentials.

@BrunoLiegiBastonLiegi
Copy link
Contributor

If it's just a matter of renaming the Align in the to_qasm I can take care of that immediately.

@BrunoLiegiBastonLiegi
Copy link
Contributor

Qiskit apparently dumps the delay as a custom operation re-defined everytime:

OPENQASM 2.0;
include "qelib1.inc";
opaque delay(param0) q0;
qreg q[1];
delay(1.0) q[0];

thus, supporting the Delay in qibo's qasm is easy, but generating a qasm string that will be accepted by qiskit is slightly trickier. @Rumoa which one is the intended use here? Do you plan to export the qasm to qiskit or is it just for sending information to another qibo driven client?

@Rumoa
Copy link
Author

Rumoa commented Oct 8, 2024

In my case, I plan to use it in a hardware backend that uses qibo, not qiskit compatible.

@alecandido
Copy link
Member

In my case, I plan to use it in a hardware backend that uses qibo, not qiskit compatible.

Qibo does not require QASM for execution, so you can safely use Align() as it is.

The issue may be still relevant, but in principle you should be able to work with qibo-client even without that (there is a native Qibo serialization involved).

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi linked a pull request Oct 8, 2024 that will close this issue
4 tasks
@Rumoa
Copy link
Author

Rumoa commented Oct 8, 2024

In that case, I guess that I should not use the api interface and use the functions from qibo client instead of using the API to connect to the device. Also, I should get the token that somehow must be related to the username and the api_key, right? Is it preferable to work with the api instead of qibo client?

Thank you for fixing the issue.

@BrunoLiegiBastonLiegi
Copy link
Contributor

BrunoLiegiBastonLiegi commented Oct 8, 2024

I am not sure which endpoint you are trying to connect to, but now we have the qibo-cloud-backends that automatically take care (through qibo-client) of remote circuit execution.

@Rumoa
Copy link
Author

Rumoa commented Oct 8, 2024

The endpoint is a quantum computer hosted at qilimanjaro, and the instructions they provide only use the api framework.
I guess that I will have to ask them to see if there are other ways to connect to it via a token to use the different solutions you just pointed out.

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

Successfully merging a pull request may close this issue.

3 participants