-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-level dynamic decompositions #6881
Conversation
…o cond_dynamic_decomp
…o cond_dynamic_decomp
…o cond_dynamic_decomp
…o cond_dynamic_decomp
Hello. You may have forgotten to update the changelog!
|
…o cond_dynamic_decomp
…o cond_dynamic_decomp
…o cond_dynamic_decomp
…pennylane into multi_level_decomp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @PietropaoloFrisoni for the great addition! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Pietro, I left one comment. Let me know what you think about it. I feel the way that I mentioned in the comment because if we can avoid changing the signature of methods defined in the base class, we should.
…ennylane into multi_level_decomp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I left a non-blocking suggestion. If it's not addressed in this PR, could you create a shortcut story to track it?
Also one question about testing, but also non-blocking.
Context: After implementing the first minimum working prototype in #6859, we consider the case where operators in the dynamic decompositions have another dynamic decomposition available. That is, another
compute_plxpr_decomposition
method.Description of the Change: The interpreter can now handle both the
max_expansion
andgate_set
arguments.Benefits: More flexible and powerful implementation
Possible Drawbacks: The idea at the current stage is that the
compute_plxpr_decomposition
should always be preferred over the old staticcompute_decomposition
method if it has been defined for an operator. However, there is one exception to this logic, which is a limitation in the current implementation due to code structure and time estimates.In the dynamic decomposition of an operator with a
compute_plxpr_decomposition
method, if we encounter an operator without acompute_plxpr_decomposition
method along the decomposition, then we switch to the current decomposition logic, which disables the program capture mechanism and decomposes recursively until we reach a max depth or a stopping condition, then re-actives program capture again at the end of the decomposition.Because of this, if in the dynamic decomposition of an operator we encounter an operator without a
compute_plxpr_decomposition
and therefore we call thecompute_decomposition
method of that operator, if an operator with acompute_plxpr_decomposition
is returned, we ignore that and proceed with the usualcompute_decomposition
method. See thetest_nested_decomp_no_plxpr_decomp_max_exp
test for a concrete example.This is a convenient compromise that appears because:
compute_plxpr_decomposition
defined for just a few operators, and acompute_decomposition
is always present for such operators.In the future, this will not be an issue since we'll have a unique new way of performing decompositions.
Related GitHub Issues: None,
Related ShortCut Stories: [sc-83111]