qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Add DAGDependencyV2 and Converters

Open enavarro51 opened this issue 1 year ago • 3 comments

Summary

Add new DAGDependencyV2 and Converters

Details and comments

This PR is a replacement for #11310. In that PR, the new DAGDependencyV2 was created and the associated template matching code was modified to use it. This PR only creates the dag and the 2 converters required. The following changes were made,

  • There is a new DAGDependencyV2 which no longer uses DAGDepNode, but instead uses the existing DAGOpNode without modification. The makes for a cleaner and much reduced memory profile for the nodes.
  • Additional methods from DAGCircuit, such as find_bit were added to the DAGDependencyV2 and other methods were modified to more closely match the 2 dags.
  • The information stored previously in the node attributes would now be accessed in the template matching code through calls to the rustworkx functions once the template matching code is refactored.
  • A terminology change was made in DAGDependencyV2. direct_successors is now successors and successors is now descendants. Similarly for predecessors and ancestors. This mirrors the usage in rustworkx.

Doing some local tests on an 8000 gate circuit and converting the circuit to a dag dependency, V2 used ~300MB of memory and V1 used ~2.5GB of memory.

The next phase will be to refactor the template matching code to use V2 and to optimize the matching.

enavarro51 avatar Feb 01 '24 15:02 enavarro51

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

qiskit-bot avatar Feb 01 '24 15:02 qiskit-bot

Pull Request Test Coverage Report for Build 8705828497

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 204 of 281 (72.6%) changed or added relevant lines in 4 files are covered.
  • 84 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.1%) to 89.262%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/dag_visualization.py 0 3 0.0%
qiskit/dagcircuit/dagdependency_v2.py 170 244 69.67%
<!-- Total: 204 281
Files with Coverage Reduction New Missed Lines %
qiskit/synthesis/two_qubit/xx_decompose/circuits.py 1 92.86%
qiskit/transpiler/passes/routing/sabre_swap.py 2 96.82%
qiskit/synthesis/two_qubit/xx_decompose/decomposer.py 2 90.63%
crates/qasm2/src/lex.rs 5 92.37%
crates/qasm2/src/parse.rs 12 96.23%
qiskit/quantum_info/operators/symplectic/pauli.py 29 84.64%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 33 89.02%
<!-- Total: 84
Totals Coverage Status
Change from base Build 8614257652: -0.1%
Covered Lines: 60353
Relevant Lines: 67613

💛 - Coveralls

coveralls avatar Feb 01 '24 15:02 coveralls

Release note added and changes made.

enavarro51 avatar Feb 07 '24 21:02 enavarro51