Configure `LinearDepthGreaterThan()` bloq to allow for multiple target qubits
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).
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.
Could you just add a CX gate controlled on the target of the original inequality target?
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.
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
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
- do greaterthan to output one bit
- 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