-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Change collect_1q_runs return for performance #5685
Conversation
Currently the return type from collect_1q_runs is being converted from the 'list(list(DAGNode))' which is returned by retworkx.collect_runs() to be 'set(tuple(DAGNode))' so that it is consistent with the return type from collect_runs(). However, this ends up adding significant overhead to the collect_1q_runs method and ends up being the bottleneck. We spend more time running the set expression to convert from the list than we do in rx.collect_runs() (mainly the filter function). Since collect_1q_runs hasn't been included in a release yet we can change the return type without breaking users and avoid this extra overhead. This commit does that and removes the set comprehension and just returns the nested list directly from retworkx.collect_runs().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Would it make sense to update the return type on the stable branch?
The collect_1q_runs method was rewritten in python as part of the backport of a larger bugfix in the Optimize1qGatesDecomposition transpiler pass in Qiskit#5655. However, it is not part of the public api in 0.16.x and was only backported to fix the bug in Optimize1qGatesDecomposition. Since the version included on the master branch will be subtlely different in return type (after Qiskit#5685) Since we don't want to advertise the method until it's included in the public api this commit prepends '_' making the method name _collect_1q_runs to indicate it is internal only as part of the 0.16.2 release.
We can but as part of: #5686 I marked the backported python version of the function as private. So we won't be breaking any potential backwards compatibility contract if someone starts using it in 0.16.2. |
* Prepare 0.16.2 release This commit prepares for the 0.16.2 release by bumping the version strings to reflect the new version. This is just a bugfix release that several fixes for bugs introduced in 0.16.1. * Mark DAGCircuit collect_1q_runs private The collect_1q_runs method was rewritten in python as part of the backport of a larger bugfix in the Optimize1qGatesDecomposition transpiler pass in #5655. However, it is not part of the public api in 0.16.x and was only backported to fix the bug in Optimize1qGatesDecomposition. Since the version included on the master branch will be subtlely different in return type (after #5685) Since we don't want to advertise the method until it's included in the public api this commit prepends '_' making the method name _collect_1q_runs to indicate it is internal only as part of the 0.16.2 release. * Cleanup release notes
Summary
Currently the return type from collect_1q_runs is being converted from
the 'list(list(DAGNode))' which is returned by retworkx.collect_runs()
to be 'set(tuple(DAGNode))' so that it is consistent with the return
type from collect_runs(). However, this ends up adding significant
overhead to the collect_1q_runs method and ends up being the bottleneck.
We spend more time running the set expression to convert from the list
than we do in rx.collect_runs() (mainly the filter function). Since
collect_1q_runs hasn't been included in a release yet we can change the
return type without breaking users and avoid this extra overhead. This
commit does that and removes the set comprehension and just returns the
nested list directly from retworkx.collect_runs().
Details and comments