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

Small speedup to construct DagDependency #8078

Merged
merged 2 commits into from
May 17, 2022

Conversation

alexanderivrii
Copy link
Contributor

Summary

Checking whether gates are over disjoint sets of qubits: if so, they commute, and the more expensive check using matrix multiplication is not necessary.

This is just a quick optimization. See also #8020.

Details and comments

A few experiments on random clifford circuits:

    gates = ["i", "x", "y", "z", "h", "s", "sdg", "cx", "cz", "swap"]
    qc = random_clifford_circuit(num_qubits, num_gates, gates=gates, seed=0)
#qubits = 5,  #gates =  100  : size = 100,  depth = 26,   #edges = 138,  previous time = 0.29,    new time = 0.07
#qubits = 5,  #gates =  500  : size = 500,  depth = 146,  #edges = 722,  previous time = 3.51,    new time = 1.49
#qubits = 5,  #gates =  1000 : size = 1000, depth = 294,  #edges = 1500, previous time = 11.41,   new time = 4.32
#qubits = 5,  #gates =  5000 : size = 5000, depth = 1478, #edges = 7144, previous time = 250.84,  new time = 95.89
#qubits = 10, #gates =  100  : size = 100,  depth = 13,   #edges = 131,  previous time = 0.40,    new time = 0.06
#qubits = 10, #gates =  500  : size = 500,  depth = 91,   #edges = 741,  previous time = 4.57,    new time = 0.87
#qubits = 10, #gates =  1000 : size = 1000, depth = 182,  #edges = 1535, previous time = 12.10,   new time = 2.77
#qubits = 10, #gates =  5000 : size = 5000, depth = 868,  #edges = 7358, previous time = 292.63,  new time = 64.49
#qubits = 20, #gates =  100  : size = 100,  depth = 9,    #edges = 100,  previous time = 0.49,    new time = 0.05
#qubits = 20, #gates =  500  : size = 500,  depth = 52,   #edges = 714,  previous time = 6.88,    new time = 0.83
#qubits = 20, #gates =  1000 : size = 1000, depth = 99,   #edges = 1564, previous time = 21.00,   new time = 2.67
#qubits = 20, #gates =  5000 : size = 5000, depth = 475,  #edges = 7617, previous time = 339.75,  new time = 55.36
#qubits = 50, #gates =  100  : size = 100,  depth = 4,    #edges = 55,   previous time = 0.56,    new time = 0.06
#qubits = 50, #gates =  500  : size = 500,  depth = 26,   #edges = 659,  previous time = 12.40,   new time = 1.01
#qubits = 50, #gates =  1000 : size = 1000, depth = 44,   #edges = 1464, previous time = 37.57,   new time = 2.77
#qubits = 50, #gates =  5000 : size = 5000, depth = 219,  #edges = 7741, previous time = 456.01,  new time = 50.24

… qubits commute (and no matrix multiplication is necessary)
@alexanderivrii alexanderivrii requested a review from a team as a code owner May 17, 2022 12:07
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented May 17, 2022

Pull Request Test Coverage Report for Build 2341309331

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 84.373%

Totals Coverage Status
Change from base Build 2339583701: 0.005%
Covered Lines: 54530
Relevant Lines: 64630

💛 - Coveralls

Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes and speed-ups look good to me.

qiskit/dagcircuit/dagdependency.py Show resolved Hide resolved
@kdk kdk added performance Changelog: None Do not include in changelog automerge labels May 17, 2022
@kdk kdk added this to the 0.21 milestone May 17, 2022
@mergify mergify bot merged commit cbc801e into Qiskit:main May 17, 2022
@alexanderivrii alexanderivrii deleted the dag_dependency_speedup branch May 18, 2022 08:03
ajavadia pushed a commit to ajavadia/qiskit that referenced this pull request May 31, 2022
… qubits commute (and no matrix multiplication is necessary) (Qiskit#8078)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants