-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support for Projectors #3288
Comments
Discussed on Cirq Cynq:
|
Alrighty if we want to separate out this functionality, how do people like @viathor and @mpharrigan feel about something like this: 1st PR: Make a new module class StateProjector:
"""A projector onto a particular state and associated stuff."""" 2nd PR: In class ProjectorPauliSum(cirq.PauliSum): # Anyone got a better name ?
"""Many similar features to PauliSum only now incorporating StateProjector support.""" |
Regarding 1st PR: drop the "State", just "Projector", it's cooler? Regarding 2nd PR: Maybe we don't need that? Does LinearDict not fulfill your needs? If not, can we extend it so it does? |
Can do.
I'm not sure I follow. Don't I still need some new code to enable things like: a = cirq.Z(q) * cirq.X(q1) + cirq.Projector(..) ? |
You should be able to use such expressions (not 100%, maybe some magic functions are missing, in which case we should just add them). Resulting LinearDict should be of reasonable size. The exponential growth of terms in your original comment was a consequence of the distributive law, but in a = cirq.Z(q) * cirq.X(q1) + cirq.Projector(..) you don't multiply a result of addition so no such growth should occur. Note however that some of the terms will not be Paulis - I assume this is fine. |
Totally fine :) Couple concerns:
type(a) # => LinearDict ? It would be nice to have a more concrete type so in TFQ when input checking for various functions, I don't have to examine all the contents one by one any more than I have to.
a *= cirq.Z(q) If we stick with just a lineardict, would I still benefit from the luxuries of having the pauli expressions around my Projector being simplified ? (This would be a must have) |
I could be interested, if that's all right. Let me read up more and get back to you on this? |
That would be awesome @tonybruguier, thank you! |
It seems this will be a challenge for me. I am happy to work through it, but I wouldn't want to take too much of your time during the reviews. I'd be OK if you decide someone else is better suited. That said, I have this very draft commit: |
After the initial PR #3386 and chatting with both @MichaelBroughton and @viathor here is a rephrasing of requirements - comments, thoughts would be highly appreciated! Then when we have an agreed design, we can modify #3386 accordingly and prepare for the next PRs with a design in mind. Today, one can calculate the expectation value of an observable for a given a state by defining the observable as a This change should keep the convenience of PauliSum arithmetics with a better representation of frequently used projectors. For the first PR:
After the first PR:
Other ideas:
|
If we change Projector operators could very easily SupportChannels and maybe even in pure state simulation. https://algassert.com/quirk#circuit=%7B%22cols%22%3A%5B%5B%22H%22%5D%2C%5B%22%E2%80%A2%22%2C%22X%22%5D%2C%5B1%2C%22%7C0%E2%9F%A9%E2%9F%A80%7C%22%5D%5D%7D |
The
Oh, I might have misunderstood something - I thought channels should be trace-preserving - i.e. for Kraus operators A_i, \sum_i A_i A_i^{\dagger} should be the identity. For a projector like P=|0><0|, you just get P^2 = P, which is not I. In my understanding that is a quantum operator but not a channel. |
Hi, |
Recording an idea from a discussion in cirq sync: The core of the original issue is that at present cirq only implements Pauli basis representation of operators (via PauliSum class) and this basis is unsuitable for certain applications since it leads to very large expressions (see first comment above). It seems a little awkward to fix this problem by providing an expansion in terms of projectors, because projectors do no form a basis (as can be readily seen by a simple counting argument). However, there is a natural basis that includes projectors: the basis of "butterfly" operators |i><k|. These incorporate computational basis projectors when i==k. In addition to being more elegant and complete this approach is likely to serve other uses, e.g. Kraus operators for some interesting channels (such as the amplitude dumping channel) take the form of these "butterfly" operators. Two additional tools would make working with these easier:
|
Thanks! So do we have consensus on going to butterfly or is it something for later? The current approach might be faster to commit, but I'm ok with doing the butterfly approach too. Just let me know, so that I don't accidently wait for you when you are waiting for me. Thanks a lot for all the guidance! |
I was a little unclear whether we reached a consensus on this idea. Let's hear from a few more people. Regarding doing projectors first and then extending to butterfly operators: It seems to me that an implementation that targets butterfly operators directly (and obtains projectors as a special case when i==k, see above) is likely to be simpler and cleaner. I'm sorry I haven't thought of this earlier. |
I'm pro 🦋 and scratching the current direction. Key questions:
|
Here's a draft RFC: |
Thanks for the feedback, new version (and new URL) of the RFC at: https://tinyurl.com/ketbra |
@MichaelBroughton |
For issue #3288 I noticed that some code was missing when working on integrating with TFQ: tensorflow/quantum#623
For issue quantumlib#3288 I noticed that some code was missing when working on integrating with TFQ: tensorflow/quantum#623
For issue quantumlib#3288 I noticed that some code was missing when working on integrating with TFQ: tensorflow/quantum#623
Is your feature request related to a use case or problem? Please describe.
This is related to expanding functionality in TFQ here ( tensorflow/quantum#357 )
Describe the solution you'd like
It would be nice to support projectors in
cirq.PauliSum
so that more complex (and still valid) expressions incirq.PauliSum
can be compressed to a reasonable length. Maybe something like:Doing this right now in Cirq does not scale well:
What is the urgency from your perspective for this issue? Is it blocking important work?
P1 - I need this no later than the next release (end of quarter)
The text was updated successfully, but these errors were encountered: