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

circuit deepcopy too slow: singleton gates #3800

Closed
ajavadia opened this issue Feb 6, 2020 · 4 comments · Fixed by #10314
Closed

circuit deepcopy too slow: singleton gates #3800

ajavadia opened this issue Feb 6, 2020 · 4 comments · Fixed by #10314
Assignees
Labels
short project type: enhancement It's working, but needs polishing
Milestone

Comments

@ajavadia
Copy link
Member

ajavadia commented Feb 6, 2020

It is currently very slow to copy a circuit. Among other things, one reason is that circuits are defined over gate instances. So a circuit with 2000 H gates and 5000 CX gates will go through that many copy operations, clearly a waste. Can we modify the datastructures to optimize this?

Along the same lines, there are currently other kinds of information in a gate instance that should be static and known before instantiation, like the name, number of qubits, or definitions (for non-parameterized gates, but also maybe for parameterized ones). It seems like a refactoring is in order.

@Avhijit-Nair
Copy link

Avhijit-Nair commented Dec 16, 2021

This issue has been solved in qiskit-terra 0.19

@1ucian0
Copy link
Member

1ucian0 commented Dec 16, 2021

A series of merged PR probably fixed this issue. Closing it. Feel free to reopen it if more specific optimization can be done.

@1ucian0 1ucian0 closed this as completed Dec 16, 2021
@Cryoris
Copy link
Contributor

Cryoris commented Dec 17, 2021

I believe this issue is about making gates singletons and only copying the necessary information instead of the entire gate instances. Currently, we still do store 2000 X-gate instances if we have 2000 X gates in a circuit so I don't think this issue can be closed.

@1ucian0 1ucian0 reopened this Dec 17, 2021
@1ucian0 1ucian0 changed the title circuit deepcopy too slow circuit deepcopy too slow: singleton gates Dec 17, 2021
@1ucian0
Copy link
Member

1ucian0 commented Dec 17, 2021

Reopening. The expected change is refactoring gates as singletons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
short project type: enhancement It's working, but needs polishing
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants