Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

Configure `LinearDepthGreaterThan()` bloq to allow for multiple target qubits

Open fpapa250 opened this issue 1 year ago • 5 comments

Add num_targets arg with default value 1 which allows us to have a bloq with multiple targets. Added functionality to classical simulation as well (for positive values).

fpapa250 avatar Mar 12 '24 23:03 fpapa250

Can you explain what's the use case for this? The interface looks very unintuitive to me.

I agree it's odd looking, but it's used in https://arxiv.org/abs/2306.08585 specifically in figure 7 for modular inverse. Open to thoughts on cleaning it up; this is what immediately made sense to me.

fpapa250 avatar Mar 12 '24 23:03 fpapa250

Could you just add a CX gate controlled on the target of the original inequality target?

fdmalone avatar Mar 12 '24 23:03 fdmalone

Could you just add a CX gate controlled on the target of the original inequality target?

Neither target will always be flipped from 0 to 1. So I don't think that would be an equivalent operation.

fpapa250 avatar Mar 12 '24 23:03 fpapa250

Neither target will always be flipped from 0 to 1. So I don't think that would be an equivalent operation.

We can always use a temporary ancilla and use that to do a multi target CX

tanujkhattar avatar Mar 13 '24 00:03 tanujkhattar

If you look at the construction, there already is an ancilla with the correct value that needs to be cnotted out to all the outputs. It's flanked by a compute/uncompute pattern per usual.

In an ideal world, we'd have these first-class flanking operations so you could define a partial GreaterThan register; maybe with a Side.DOWN register; and you could combine it with whatever output-like bloq you want. e.g.

MultiTarget(bloq=GreaterThan(), n_targets=5)

but that's sadly not the world we live in yet. So you could manually wrap the existing one-target greaterthan with a multitarget version composed of

  1. do greaterthan to output one bit
  2. do multi-target cnot to copy it to the n-1 other bits

all that being said -- this LinearDepthGreaterThan was introduced to track the referenced paper and it already doesn't really match the signature of GreaterThan so it might be fine to introduce the multi-target version directly for expediency

mpharrigan avatar Mar 18 '24 23:03 mpharrigan