-
Notifications
You must be signed in to change notification settings - Fork 575
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
Make tape mode default #1040
Make tape mode default #1040
Changes from 3 commits
4df4002
5951d93
973dc5b
016ea50
eea1885
573daa3
ff4aa03
2e1ae19
20c1b36
1d63f2c
bba5743
db93789
e470446
5ca97e4
1930dfa
a4f91cb
3416709
dc5f45d
4de4e28
a0c00c7
14149d4
883591b
52fdd9d
5372913
992bdbc
8c8c165
826aca1
8d367e0
05676ac
d06ad0e
3768dd7
77864ca
20e469a
027c2df
206fbe3
bc8dfbf
3580382
345be59
54fc9de
681d739
6c8bfc4
8156079
51a4120
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,10 +54,18 @@ def circuit(): | |
Returns: | ||
callable: The wrapper function | ||
""" | ||
# pylint: disable=import-outside-toplevel | ||
|
||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
with OperationRecorder() as rec: | ||
import pennylane as qml | ||
|
||
recorder_class = OperationRecorder | ||
|
||
if qml.tape_mode_active(): | ||
recorder_class = qml.tape.TapeOperationRecorder | ||
|
||
with recorder_class() as rec: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to understand, why is it not if qml.tape_mode_active():
import pennylane as qml
recorder_class = qml.tape.TapeOperationRecorder
else:
recorder_class = OperationRecorder There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If tape mode is active to reimport, else you use the old one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If PennyLane is already imported in the Python session, The I couldn't include this import at the top of the file due to circular imports, so that's the only reason it is inside the decorator :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. I never understood circular imports, maybe we should solve the issue once and for all... |
||
func(*args, **kwargs) | ||
|
||
return rec.queue | ||
|
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.
This import feels hacky and cyclical. Can't we import the needed modules at the top of this file?
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.
hahaha I tried so many combinations (including having it at the top of the file), and constantly ran into cyclical import errors. This was the only combination that didn't result in a cyclical import error.
I'm okay with this for now, since