-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Use toposort instead of topological_op_nodes for DAG reconstruction #15987
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
Open
mtreinish
wants to merge
8
commits into
Qiskit:main
Choose a base branch
from
mtreinish:topopo-topopo-topopo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+71
−42
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fba57cc
Use toposort instead of topological_op_nodes for DAG reconstruction
mtreinish db73d4e
Merge remote-tracking branch 'origin/main' into topopo-topopo-topopo
mtreinish b68b2e2
Add a dedicated rebuilder function instead of inlining toposort
mtreinish 400e11c
Merge remote-tracking branch 'origin/main' into topopo-topopo-topopo
mtreinish 729b8a7
Use expect() for toposort error
mtreinish d1ed24d
Merge remote-tracking branch 'origin/main' into topopo-topopo-topopo
mtreinish 39ebfcb
Merge remote-tracking branch 'origin/main' into topopo-topopo-topopo
mtreinish e826f0c
Merge remote-tracking branch 'origin/main' into topopo-topopo-topopo
mtreinish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does
copy_empty_likeactually need to be fallible? It looks like it's calling a lot ofadd_wire& similar methods which are fallible in general, but shouldn't actually be when copying a valid DAG.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.
There shouldn't be a reason it needs to fail, or at least not that I can think of. I think it is mostly a legacy of when there were more python things in the data model and we were potentially calling out to Python. But I would save any changes to that for a different PR.
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.
Yeah definitely not for this PR but it would be nice to resolve that so we don't have
unwraps flying around that look dangerous but aren't 😄Uh oh!
There was an error while loading. Please reload this page.
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.
Even so, please don't use
unwrap: at least useexpectwith the reason for why it can't panic, so if we're ever wrong we've got the debug information of the original assumption.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.
The
copy_empty_likemethods currently don't document how they might fail, so any assumption we write here isn't supported by our internal documentation - it'd be better pathing to either make this method fallible whilecopy_empty_likeis fallible and remove it later, or fixcopy_empty_likefirst so we can use it in this PR.I would like us to get out of the habit of using
unwrap/expecton long-range assumptions when the true fix is to fix the base interface, even for things that are expected to be ephemeral.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.
I dug into this and made the copy methods infallible as they actually are in: #16316 . A DAGCircuit can't have duplicate wires and the error condition being propagated wasn't possible from the copy methods.