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

Deprecate DAGNode.sort_key attribute #13744

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mtreinish
Copy link
Member

Summary

Prior to having the DAGCircuit in rust the sort_key attribute was added as a cache to speed up the lexicographical topological sort. Prior to having this attribute the topological sort method would compute the sort key as a string on the fly which ended up being a large bottleneck in transpilation (see: #4040 for more details). However, since migrating the DAGCircuit implementation to Rust this sort_key attribute isn't needed anymore because we call the rustworkx-core function with a tuple of bit objects instead of a string. The sort_key atribute was left on in place for backwards compatibility (it shouldn't have been public, this was a mistake in #4040) and when we create a python DAGNode object that will be returned to Python the creation of the sort key is unnecessary overhead (it takes roughly 1% of profile time to format the sort_key string during transpilation). Since nothing in DAGCircuit is actually using it this commit removes it to save the CPU cycles creating the string on each dag creation.

Details and comments

This attribute is removed in Qiskit 2.0.0 in #13736

Prior to having the DAGCircuit in rust the sort_key attribute was added
as a cache to speed up the lexicographical topological sort. Prior to
having this attribute the topological sort method would compute the sort
key as a string on the fly which ended up being a large bottleneck in
transpilation (see: Qiskit#4040 for more details). However, since migrating the
DAGCircuit implementation to Rust this sort_key attribute isn't needed
anymore because we call the rustworkx-core function with a tuple of bit
objects instead of a string. The sort_key atribute was left on in place
for backwards compatibility (it shouldn't have been public, this was a
mistake in Qiskit#4040) and when we create a python DAGNode object that will
be returned to Python the creation of the sort key is unnecessary
overhead (it takes roughly 1% of profile time to format the sort_key
string during transpilation). Since nothing in DAGCircuit is actually
using it this commit removes it to save the CPU cycles creating the
string on each dag creation.

This attribute is removed in Qiskit 2.0.0 in Qiskit#13736
@mtreinish mtreinish requested a review from a team as a code owner January 27, 2025 21:59
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@mtreinish mtreinish added the Changelog: Deprecation Include in "Deprecated" section of changelog label Jan 27, 2025
@mtreinish mtreinish added this to the 1.4.0 milestone Jan 27, 2025
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kevinhartman kevinhartman added this pull request to the merge queue Jan 27, 2025
Merged via the queue into Qiskit:stable/1.4 with commit da61465 Jan 27, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants