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

Remove deepcopy usage in dag_to_circuit #1431

Merged
merged 14 commits into from
Dec 6, 2018

Conversation

mtreinish
Copy link
Member

Summary

This commit attempts to improve the performance of dag_to_circuit by
removing the deepcopy usage. Instead this switches to creating a
circuit object using the normal constructors while iterating over the
dag.

Details and comments

This commit attempts to improve the performance of dag_to_circuit by
removing the deepcopy usage. Instead this switches to  creating a
circuit object using the normal constructors while iterating over the
dag.
@nonhermitian
Copy link
Contributor

When done, can you do a timeit to see the improvement?

@mtreinish
Copy link
Member Author

Yeah, once I get this passing all the tests I'm planning to add a comment here with some benchmarks.

But, at least on this version of the PR I've done some preliminary timing with compiling a large qasm file (with like ~3.5k lines) from aqua that @ajavadia provided and got a significant speedup in that case. Calling compile() took ~3.1secs with this patch and ~3310.3 secs without this patch.

@jaygambetta
Copy link
Member

Can you do the timing on transpile not complie

@mtreinish
Copy link
Member Author

mtreinish commented Dec 6, 2018

Ok, I've fixed the issue caused by cx_base vs cx now the only failing test is: https://travis-ci.org/Qiskit/qiskit-terra/jobs/464115683#L1397 Not sure what I did to break it there, but the expected counts are nowhere near what they should be.

@mtreinish mtreinish changed the title [WIP] Remove deepcopy usage in dag_to_circuit Remove deepcopy usage in dag_to_circuit Dec 6, 2018
@mtreinish
Copy link
Member Author

I'm still running numbers (without this patch transpile can take a long time) but so far I've finished the tests with and without this patch just parsing the same large qasm file from aqua I mentioned before and getting an unrolled dag from that and then timing how long dag_to_circuit() takes on that dag. With this patch that operation ~0.40 secs and without it took ~0.95 secs. The raw numbers for that test were:

With Patch:
0.397959
0.411044
0.405604
0.410246
0.401071
0.406355
0.404786
0.406011
0.403361
0.409036
0.405321
0.416254
0.400951
0.404211
0.400891

Without Patch:
0.950606
0.961483
0.988895
0.957507
0.952986
0.955229
0.952623
0.963022
0.959569
0.954256
0.95801
0.959481
0.954618
0.95338
0.952434

I'm running the transpile benchmarks using that same large qasm file now. I've finished the runs with this patch and it takes ~1.4 secs to run transpile(). The runs without this patch are taking a lot longer, the script is still running (only doing 5 samples) but it's taking ~3300 seconds to run transpile() each time so far.

@ajavadia ajavadia merged commit b3af3f2 into Qiskit:master Dec 6, 2018
@mtreinish mtreinish deleted the improve-dag-to-circuit-performance branch December 6, 2018 21:25
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Remove deepcopy usage in dag_to_circuit

This commit attempts to improve the performance of dag_to_circuit by
removing the deepcopy usage. Instead this switches to  creating a
circuit object using the normal constructors while iterating over the
dag.

* Fix u_base name

* Fix CX is not cx

* Remove random_name

* CX is cx_base not cx

* Fix bit args mismatch when using coupling map

* Remove unused imports

* Fix handling of simulator instructions
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

Successfully merging this pull request may close these issues.

5 participants