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.
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
specs transform #1245
specs transform #1245
Changes from 27 commits
a3c5160
60b61eb
358eac4
dc2de57
fe9e845
116b528
f713ecd
535dfa6
7e51f07
ca8a56b
b1cba49
0d473f1
b11571f
e62c740
c410204
b0b874a
cb5c7e1
18b5d1f
5e2ee88
572ab7f
b0c8b20
927622a
76d70d5
5d704a3
1e87cb8
4d9e9c2
c70766c
2912d49
1c87df3
86196d2
73cdc8b
c42aa14
6da7a2c
6a4fbae
6e5637c
82fde2b
8e8bcbb
dce091e
6f19e42
e6b6e92
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
would
gate_sizes
andgate_types
not be much clearer?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 for the suggestion. I'm switching to that.
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 would not talk about tapes, since this is not user facing at all. Can we say
num_used_wires
then?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.
What about "circuit_depth"?
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.
Does this include the forward pass execution? E.g., if you set
requires_grad=False
forx
, this number is1
.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.
Also, how is this number
7
? Since we have4
params shouldn't it be9
?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.
Would this make sense as
num_device_executions
?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.
Side note: it'd be great to finally get rid of device wires for simulators, and only use as many wires as there are in the tape!
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.
Think it might be nicer to have a single-sentence summary here (e.g., same as what you have below), and then in the
![image](https://user-images.githubusercontent.com/49409390/121559506-9f767880-c9e4-11eb-8f94-6b6212a5272a.png)
Returns:
it can just be a word or two. Currently the docs renders the summary weirdly: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.
Nice, probably answers my question above.
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 wonder why this is needed?
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.
Is this for if someone asks for specs before actually having evaluated the gradient?
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.
Yep.
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.
How about finite diff and CV circuits? Maybe not too important for now, but might be worth considering later.
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've thought about it a little and will probably try to add them in later.
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 am not sure I understand what is going on in this function. Maybe some more explicit comments could help?
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.
Any better?
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 just realised
specs
doesn't work so well with circuits that include templates:Gives
Though in practice, there are many trainable params and there will be many param shift executions 🤔.
There may not be an easy fix for this though. And also things work nicely on the QNode level as expansion will have happened.
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.
Do you think this is something that needs fixing for this PR? Most users are not going to working with tapes, and there are multiple shortcomings to a tape with an unexpanded template.
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 agree, maybe something we can think about as we improve the
Operation
class. (I believe this subtlety is due to moving templates to operations, since they'd be automatically expanded before?)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.
Do we want to say when it will be removed?
E.g.
"
tape.get_resources
is now deprecated and will be removed in v0.17"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.
Perhaps this was decided on previously, but the names
"by_size"
and"by_name"
do not seem completely descriptive, how about pretending"ops_"
to them? e.g.,"ops_by_size"
, etc.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.
Due to Maria's suggestion, we are now using
"gate_sizes"
and"gate_types"
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.
Maybe another point could be adding information about the diagonalizing gates (if any).
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.
added
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.
How about the
"num_all_wires"
or simply"all_wires"
here?"num_tape_wires"
assumes knowledge about having quantum tapes represent quantum circuits. When querying a QNode, a user might not possess the knowledge that there's an underlying quantum tape in a QNode and might become confused.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.
Note: while all other information seems to be fairly cheap to get, here we need to construct the computational graph if it was not constructed already. Could it be worth having a flag for
specs
that is something likewith_circuit_depth=False
and if the user is curious about the circuit depth, they could explicitly mark the flag to beTrue
?Might not be a too common case, but could potentially add some unexpected overhead if
specs
is being during an optimization.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.
Would have to change from properties to functions.
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.
It'd be good to have a one sentence summary line, otherwise the docs look weird:
![image](https://user-images.githubusercontent.com/49409390/121568913-35fb6780-c9ee-11eb-9865-198ffa5dc857.png)
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.
Indeed, and worth including that a QNode construction is required to obtain data here.
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.
Just to understand, why do we give access to exactly that one? For example, I would find it much more useful to give user access to the stopping criterion for expansion, if anything...
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 just mirroring how QNode's work.
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 also wondered 🤔. If we have to expand to depth
N
for the device to execute, what would happen ifmax_expansion < N
? Wouldn't it just not work on the device? Although I guess you can still access the specs?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.
E.g.,
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.
Just to check, is this up to date? Maybe the diagonalizing gates one.
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.
Not up to date. Thanks for catching that! Tiny little changes having to get propagated to a million places.