Skip to content
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

Avoid infinite recursion in decomposition of Controlled #468

Merged
merged 4 commits into from
Jan 19, 2024
Merged

Conversation

dime10
Copy link
Contributor

@dime10 dime10 commented Jan 19, 2024

The qml.matrix falls back to decomposition of the supplied operator if the matrix cannot be computed. Since we explicitly map the decomposition function of an operator to a qml.matrix call, this can lead to infinite decomposition loop.

Avoid the problem by invoking op.matrix() directly.

fixes #463
[sc-54969]

The `qml.matrix` falls back to decomposition of the supplied operator if the matrix cannot be computed. Since we explicitly map the decomposition function of an operator to a `qml.matrix` call, this can lead to infinite decomposition loop.

Avoid the problem by invoking `op.matrix()` directly.
@dime10
Copy link
Contributor Author

dime10 commented Jan 19, 2024

Adding a test shortly.

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c559403) 99.56% compared to head (8dc026a) 99.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #468   +/-   ##
=======================================
  Coverage   99.56%   99.56%           
=======================================
  Files          43       43           
  Lines        7662     7666    +4     
  Branches      514      514           
=======================================
+ Hits         7629     7633    +4     
  Misses         17       17           
  Partials       16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

... when Controlled decomposition to matrix fails.
@dime10 dime10 merged commit cc62f65 into main Jan 19, 2024
19 of 20 checks passed
@dime10 dime10 deleted the dime10-patch-2 branch January 19, 2024 23:18
@dime10 dime10 added the bug Something isn't working label Jan 29, 2024
@dime10 dime10 mentioned this pull request Jan 29, 2024
josh146 pushed a commit that referenced this pull request Jan 29, 2024
The `qml.matrix` falls back to decomposition of the supplied operator if
the matrix cannot be computed. Since we explicitly map the decomposition
function of an operator to a `qml.matrix` call, this can lead to
infinite decomposition loop.

Avoid the problem by invoking `op.matrix()` directly.

fixes #463 
[sc-54969]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

maximum recursion depth exceeded in computing the catalyst.ctrl of qml.QSVT
2 participants