Add discussion of custom-pass implementation #14787
Open
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
This is the beginnings of better documentation around writing custom transpiler passes. Historically, we've somewhat implicitly assumed that people would look at the source code to get a feel for it, but really, this should always have been in guide-level documentation.
This commit adds some guiding information about the expectations of passes. It doesn't currently add worked examples; these should be added at some point.
The primary motivation for this commit was to add the discussion about expectations around determinism of passes, and tips for how to achieve that.
Details and comments
In particular, this commit makes explicit the assumptions that lead to the use of
DAGCircuit.structurally_equal
, proposed in #14762. The determinism of Qiskit preset pipelines have largely already relied on the behaviours expounded on here, so this is not intended to be new restrictions, but rather an explicit statement of previously unsaid ones.