Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Fully port `Depth` and `Size` passes to Rust #13040

Closed kevinhartman closed 2 months ago

kevinhartman commented 2 months ago

Summary

This has a bit of a click-bait title since they're technically already ported (the calls to DAGCircuit::depth and DAGCircuit::size made by the Python passes are already in Rust). But, this PR avoids an isinstance call that was being done for every node in the DAG on calls to these methods when the recurse parameter was specified as true, which should resolve the performance issues we were seeing with these passes.

I've also done this for DAGCircuit::count_ops.

Details

Resolves #12272, #12273

qiskit-bot commented 2 months ago

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

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10586731786

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


Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/dag_circuit.rs 67 72 93.06%
<!-- Total: 67 72 93.06% -->
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.73%
crates/circuit/src/interner.rs 4 92.0%
crates/circuit/src/packed_instruction.rs 8 96.56%
crates/qasm2/src/parse.rs 12 97.15%
crates/circuit/src/circuit_data.rs 26 92.18%
crates/circuit/src/dag_circuit.rs 300 89.02%
<!-- Total: 353 -->
Totals Coverage Status
Change from base Build 10563485346: -0.01%
Covered Lines: 71646
Relevant Lines: 80320

💛 - Coveralls