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
Add function to apply instantiated operations to queuing contexts #1433
Add function to apply instantiated operations to queuing contexts #1433
Changes from 9 commits
fea2b6f
6b8e2fd
8b7abbe
cd7fb7e
cf5fb68
4a792f0
bba80d8
07e9edb
535c82e
a784aa4
693a61b
ac6e336
ec77ce6
a48c8cd
53b8071
13aaea2
80940d8
0593611
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.
I'm not sure I understand the
init
argument?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.
Ah - the queuing logic was previous occuring at the exact same time as the
Tensor
datastructure was being computed.That is, within
__init__
, there was a single for loop that did two things:obs
list of constituent observables.I originally split it into two separate for loops in order to separate out the logic, but realized that it would result in looping through the observable list twice. Which is fine... but as the number of qubits increases, this could be a bottleneck.
So I combined it back into a single for loop, but use
init=True
to ensure that building the datastructure only happens on instantiation, while queuing happens every time.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.
Trying to understand this 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.
Ah, this one is weird.
QueuingContext.append
is a class method, so doesn't take self into account. Here, we are in a subclass, and simply overriding the inherited class methods.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 cool, makes total sense!
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.
There are two tests in this test function; one that tests Hamiltonian queuing for a Hamiltonian created outside the context, and one that tests Hamiltonian queuing for a Hamiltonian created inside the context.
This variable
queue
is the expected result for the Hamiltonian outside the context. If you scroll down, you can see that the addition of these two elements makes it consistent with the expected result for the Hamiltonian inside the context.