Closed mtreinish closed 2 months ago
One or more of the following people are relevant to this code:
@Qiskit/terra-core
@kevinhartman
@mtreinish
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
crates/accelerate/src/remove_diagonal_gates_before_measure.rs | 1 | 2 | 50.0% | ||
crates/circuit/src/packed_instruction.rs | 0 | 5 | 0.0% | ||
crates/accelerate/src/filter_op_nodes.rs | 25 | 34 | 73.53% | ||
crates/circuit/src/dag_circuit.rs | 0 | 15 | 0.0% | ||
<!-- | Total: | 30 | 60 | 50.0% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
crates/qasm2/src/lex.rs | 4 | 91.73% | ||
crates/qasm2/src/parse.rs | 6 | 97.61% | ||
<!-- | Total: | 10 | --> |
Totals | |
---|---|
Change from base Build 10725151093: | -0.03% |
Covered Lines: | 72623 |
Relevant Lines: | 81484 |
Summary
This commit ports the FilterOpNodes pass to rust. This pass is exceedingly simple and just runs a filter function over all the op nodes and removes nodes that match the filter. However, the API for the class exposes that filter function interface as a user provided Python callable. So for the current pass we need to retain that python callback. This limits the absolute performance of this pass because we're bottlenecked by calling python.
Looking to the future, this commit adds a rust native method to DAGCircuit to perform this filtering with a rust predicate FnMut. It isn't leveraged by the python implementation because of layer mismatch for the efficient rust interface and Python working with
DAGOpNode
objects. A function using that interface is added to filter labeled nodes. In the preset pass manager we only use FilterOpNodes to remove nodes with a specific label (which is used to identify temporary barriers created by qiskit). In a follow up we should consider leveraging this new function to build a new pass specifically for this use case.Details and comments
Fixes #12263 Part of #12208