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

get_transpiler() crashes if called before get_backend() #1543

Open
BrunoLiegiBastonLiegi opened this issue Dec 14, 2024 · 1 comment
Open

Comments

@BrunoLiegiBastonLiegi
Copy link
Contributor

BrunoLiegiBastonLiegi commented Dec 14, 2024

This fails with a AttributeError: 'NoneType' object has no attribute 'qubits' for me

from qibo import get_transpiler, get_backend

get_transpiler()
get_backend()

whereas the opposite works

get_backend()
get_transpiler()

presumably because get_backend sets some kind of global variable that is used by get_transpiler.

@alecandido
Copy link
Member

It does (though everything is local to the _Global class, which on its turn is global - making everything global as a consequence).

The solution is just to replace

qubits = cls._backend.qubits
natives = cls._backend.natives

with a call to get_backend, i.e.

    qubits = cls.backend().qubits
    natives = cls.backend().natives

In this way, the second invocation will get the actual value set, and the first one will set it, only if there is none yet.

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