Skip to content
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

Configure LinearDepthGreaterThan() bloq to allow for multiple target qubits #782

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fpapa250
Copy link
Contributor

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).

Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

qualtran/bloqs/arithmetic/comparison.py Outdated Show resolved Hide resolved
@fpapa250
Copy link
Contributor Author

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.

@fdmalone
Copy link
Collaborator

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

@fpapa250
Copy link
Contributor Author

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.

@tanujkhattar
Copy link
Collaborator

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

@mpharrigan
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants