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

Importing qualtran is very slow (~3.2s) #947

Open
anurudhp opened this issue May 13, 2024 · 3 comments
Open

Importing qualtran is very slow (~3.2s) #947

anurudhp opened this issue May 13, 2024 · 3 comments

Comments

@anurudhp
Copy link
Contributor

anurudhp commented May 13, 2024

import timeit

t = timeit.timeit('import qualtran', number=1)
print(t)

averages around 3.2s. Perhaps some dependency is causing this.

(Alternatively run python -m timeit -n 1 -r 1 "import qualtran")

@mpharrigan
Copy link
Collaborator

do you want to do some profiling to figure out what might be the cause?

@anurudhp
Copy link
Contributor Author

I ran python -X importtime -c "import qualtran" (after #949), it seems import cirq takes up most of the time:

import time: self [us] | cumulative | imported package
...
import time:      1377 |    1072314 |     cirq
import time:      4683 |    1076997 |   qualtran._infra.gate_with_registers
...
import time:       349 |    1564730 | qualtran

@mpharrigan
Copy link
Collaborator

It would be nice if we could defer importing cirq "as needed" as well. Ideally, this would only happen if you were using a bloq that wraps a cirq gate or uses cirq functionality somehow (or if using any of the cirq interop). It's blocked by the fact that GateWithRegisters is in the top-level namespace and descends from cirq.Gate.

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