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
Expectation value of observables non diagonal in the computational basis #1489
Expectation value of observables non diagonal in the computational basis #1489
Changes from 17 commits
e756691
2ced672
ed8b641
db41268
6fd2bf1
e4b3591
761eaa8
4cdfe6b
63b1ce7
2b34b5c
68d4e55
63fba04
84191d9
1ddb2c2
e8480b5
0dfb4a8
9a10b11
e2d1c05
ea570bf
f9943d7
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 understand this is useful only for hardware execution, right? Since in simulation you could just simulate the circuit and use
expectation
directly, which should also be more efficient (and exact).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.
Yes I had exactly in mind hardware execution for this. But even for simulation, you wouldn't want the exact expectation from the final state (is this what you are suggesting? not sure) as this is supposed to be sample dependent.
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.
Yes, above I meant to get the exact expectation from the final state, however you can still get a sample dependent estimate by first simulating the circuit with shots, getting the samples and using
expectation_from_samples
. I would expect this to be faster than usingexpectation_from_circuit
for simulation, since in the first case the "state preparation" circuit is only simulated once, whileexpectation_from_circuit
will repeat the simulation of the same circuit for every basis.On hardware, or if you are simulating with noise, it is probably a different story.
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 yeah, I see, I've been thinking about doing the state preparation first and then just measuring for simulation. To do that though, we should probably move (at least some part of) the
expectation_from_circuit
inside the backend, which I am not against by the way, but for the moment I decided to keep it simple. In any case, I was assuming that sinceexecute_circuits
launches several parallel jobs, if I am not mistaken, the overhead of running several copies of the same simulation would have been reduced, assuming you have many cores available.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 think we don't need to do anything about this, since it is already available by executing the circuit manually and then calling
expectation_from_samples
. This is a bit more manual for the user, but it is still fairly simple and it is not the best idea to provide multiple ways (almost equally simple) to do the same thing as it would increase maintenance from our side.