-
Notifications
You must be signed in to change notification settings - Fork 616
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
Handle recursion errors in CompositeOp methods #6375
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6375 +/- ##
==========================================
- Coverage 99.71% 99.39% -0.32%
==========================================
Files 447 447
Lines 42365 42422 +57
==========================================
- Hits 42244 42167 -77
- Misses 121 255 +134 ☔ View full report in Codecov by Sentry. |
…o composite-op-recursion
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.
👍
I'm tempted to try and create a class decorator so we don't have to decorate every method and property, but I have a feeling that is too much black magic...
That was actually the first thing I tried, overriding the |
By default, `qml.sum` and `qml.prod` set `lazy=True`, which keeps its operands nested. Given the recursive nature of such structures, if there are too many levels of nesting, a `RecursionError` would occur when accessing many of the properties and methods. Catching these errors and re-raising a more sensible error message suggesting that the user could either set `lazy=False` or use the `+` and `@` operators instead, which sets `lazy=False`. **Update** Extending the behaviour to `SProd` Fixes #5948 [sc-67745]
By default, `qml.sum` and `qml.prod` set `lazy=True`, which keeps its operands nested. Given the recursive nature of such structures, if there are too many levels of nesting, a `RecursionError` would occur when accessing many of the properties and methods. Catching these errors and re-raising a more sensible error message suggesting that the user could either set `lazy=False` or use the `+` and `@` operators instead, which sets `lazy=False`. **Update** Extending the behaviour to `SProd` Fixes #5948 [sc-67745]
By default,
qml.sum
andqml.prod
setlazy=True
, which keeps its operands nested. Given the recursive nature of such structures, if there are too many levels of nesting, aRecursionError
would occur when accessing many of the properties and methods. Catching these errors and re-raising a more sensible error message suggesting that the user could either setlazy=False
or use the+
and@
operators instead, which setslazy=False
.Update
Extending the behaviour to
SProd
Fixes #5948
[sc-67745]