Fix CollectCliffords to index nodes using their ids#13484
Fix CollectCliffords to index nodes using their ids#13484alexanderivrii wants to merge 3 commits into
CollectCliffords to index nodes using their ids#13484Conversation
Needed because this field is named differently in DAGOpNode and DAGDepNode.
|
One or more of the following people are relevant to this code:
|
CollectCliffords to index nodes using their ids
Pull Request Test Coverage Report for Build 11994394990Details
💛 - Coveralls |
| self.dag = dag | ||
| self._pending_nodes: list[DAGOpNode | DAGDepNode] | None = None | ||
| self._in_degree: dict[DAGOpNode | DAGDepNode, int] | None = None | ||
| self._in_degree: dict[int, int] | None = None |
There was a problem hiding this comment.
This is problematic, using the node ids is only safe for a single dag. If we want to switch this to be keyed on node ids we can not cache it. We could get away with the cache with the DAGNode storage because the hash and eq implementations are unique; either pre-rust dagcircuit where it was object id based or post-rust dag where this is an actual implementation. But node ids are not unique between dags and the indices are reused between dags and will refer to different nodes.
There was a problem hiding this comment.
I see the point, but a single BlockCollector class only makes sense for a single DAG, in which case we should be fine using node ids, correct?
|
Closing this. |
Summary
Fixes #13457.
This PR changes the internal field
in_degreeinBlockCollectorto be indexed by the ids of the nodes rather than by nodes themselves. See also #13424 for a related discussion.In particular, this avoids hashing the nodes as python objects, both making the code faster and avoiding problems for things like
PauliLindbladErrorcoming fromqiskit_aer.Details and comments
I am not sure if this change really deserves a release note, but I have decided to add one, given that it does address a reported bug.