[core] Add Decomposition Pattern Selection logic #3644
+826
−77
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.
This PR introduces a "decomposition pattern graph", implemented in
DecompositionPatternSelection.cpp. For encapsulation, it is not exposed in any header file, and hence can only be used through the newselectDecompositionPatternsfunction exposed inDecompositionPatterns.h.The passes
DecompositionandBasisConversionare modified to use this new pattern selection mechanism whenever thebasisargument is specified andenable-patternsis empty. Thebasisargument was added to theDecompositionpass (and is optional).DecompositionGraphis constructed using the metadata exposed by #3587 on the available decomposition patterns. The graph captures how gates can be decomposed into other gates (edges are decomposition patterns, vertices are gate types). For any desired target gate set, the set of all "useful" decompositions can be inferred by traversing the graph backwards, starting from the target gate set.I have left the actual pass definitions in the target YAML files unchanged. It should be possible to substantially simplify them in a future PR, as using the
basisargument should make most explicit lists of enabled and disabled patterns superfluous.See also Jira issue CUDAQ-217