-
Notifications
You must be signed in to change notification settings - Fork 50
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
Controlled versions of non-THRU bloqs #1304
Comments
Controlled(ZeroState(), CtrlSpec()).call_classically(ctrl=0)
|
Is there a more concrete example for why this is odd? Does this cause unintuitive behavior in a real world use case? The original reasoning was -
With this reasoning, the Assuming qubit allocation is by default in the |
It just seems like a leaky abstraction to me to consider
|
For a |
I can definitely be convinced that "controlled state preparation"'s non-controlled version prepares the zero state. Do you have any references (e.g. circuits from the literature) where it's tacitly assumed that a zero state is returned when the control line is inactive? More evidence would be if we have state prep bloqs in Qualtran with right registers that we want to control. In the docs, we have https://qualtran.readthedocs.io/en/latest/bloqs/state_preparation/state_preparation_via_rotation_tutorial.html#using-the-bloq-in-a-circuit which can be interpreted either way
As seen in #1305, there's really no where in the library where we control right registers. Except for I always have a preference for including a restriction like this until we have a demonstrated use case to lift it; at which point we can lift it |
I think everywhere we do a controlled QROM read; this is the assumption because when costing algorithms people always assume Controlled QROMs are used at multiple places in algorithms; for example: Fig 5 of https://arxiv.org/pdf/2011.03494. As you would notice; the diagram explicitly shows that a bloq was initialized in the 0 state and used as a target for loading data Here is the cost explanation of the figure: Notice that Step-6 makes sense only when you assume target was initially 0 and should be left in 0; i.e. the The correct way to draw this figure in qualtran would use |
I think there are enough examples that indicate we shouldn't have this restriction. The only reason we don't have existing tests in Qualtarn is because we don't have that many end to end implementations of algorithms where we use these (relatively newly implemented) bloqs. Hopefully the example I give above is convincing enough. |
Thanks, I'm coming around to the idea that general-purpose controlled versions of allocating-bloqs-with-a-decomposition makes sense with an important caveat.
Now consider a composite bloq that allocates e.g. a plus state and does a unitary operation that we want to enclose in a bloq with a right register. Going off the same figure: imagine we had a
in summary, we can't completely get away from the question of what does |
for resource counting purposes, I'm actually okay with keeping the current behaviour of returning Controlled(...). we just need resource counting code to recognize that Controlled(And) and Controlled(MultiAnd) are just the original As to whether we should support Controlled of bloqs that have LEFt/RIGHT registers ... I will leave that to you Apart from this, Controlled(T) should be a leaf bloq, Craig had a decomposition that uses 4 |
I'd like to slow the increase of business logic in the gate counting code. |
|
From a practical perspective,
I'd advocate for merging #1305 until there's a clear design and need for |
With the discussion in #1272 #1273 , I have been reminded of how uncomfortable I feel about controlled versions of bloqs with RIGHT or LEFT (allocating / de-allocating) registers.
There are parts of the code that don't dis-allow this; Maybe we should dis-allow this.
Controlling a bloq can be thought of a special case of the
Select
operation: our control bit toggles between two possible operations, the identity (do nothing) and the operation in question. The two operations must have the same tensor shape.From inspection of the tensor simulation code for$\ket{0}$ -- which is a choice.
Controlled
, it 'supports' right- and left- registers. But it must make a choice for what the identity operation is. Assume the operation we're considering is a one-bit allocation. It says the "identity operation" isIt's a strange choice though. Assume our control bit is in equal superposition.
Controlled(OneState)
->Controlled(ZeroState)
->This "preferred direction" seems odd
The text was updated successfully, but these errors were encountered: