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.
Summary
When converting from a
DAGCircuit
to aDAGDependency
, in some cases it would be useful to compute and return additional information related to this conversion, such as the mappings between the inputDAGOpNode
s and the outputDAGDepNode
s. In particular, this would allow analysis passes that translate aDAGCircuit
to aDAGDependency
, collect blocks of nodes from theDAGDependency
(exploiting the commutativity information offered by the latter structure), find the lists of corresponding nodes in the originDAGCircuit
and (for example) resynthesize these nodes. A direct application would be to extend the newStarPreRouting
pass to collect and resynthesize "star-shaped" pieces of the circuit while also exploiting the commutativity between the nodes.This PR adds a new class
CircuitConversionData
that stores the mappings and extends the conversion functions todag_to_dagdependency_with_data
and_dag_to_dagdependency_v2_with_data
(all of the code pertaining toDAGDependency_V2
is private for now).The reason that
CircuitConversionData
is a class rather than a mapping is that we might want to store more information in the future, and we would not need to keep extending the API. And it would also probably be easier to convert this to Rust in the future.I am wondering whether I should make the class
CircuitConversionData
also private or also extend other circuit converters such ascircuit_to_dagcircuit
, etc. What do you think?