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

Basic Unary Iteration / QROM #721

Open
mpharrigan opened this issue Feb 29, 2024 · 3 comments
Open

Basic Unary Iteration / QROM #721

mpharrigan opened this issue Feb 29, 2024 · 3 comments

Comments

@mpharrigan
Copy link
Collaborator

unary iteration / qrom bloqs support a lot of features (multi-dimensional select; break) that obscure the key points of the design. They're also written cirq-style where each target op op[l] is a bundle of gates instead of one bloq per index. Writing an idiomatic "basic" 1d unary iteration and/or qrom bloq would be very instructive.

@mpharrigan
Copy link
Collaborator Author

A sketch of how this might look

class Set(Bloq):
  datum: int
  bitsize: int

  return Signature.build(x=bitsize)

  def decompose(bb, x):
    for bit in iter_bits(self.datum):
       if bit:
         bb.Add(XGate()
class ApplyL(Bloq):
  ops: List[Bloq]
  selection_bitsize: int = field(validator=len(ops) fits)
  target_bitsize: int

  return Signature.build(ctrl=1, selection=self.selection_bitsize, target=self.target_bitsize)

  def decompose(bb, ctrl, selection, target):
    selection = selection.split()
    l = 0
    for ...:
        # construct and ladder
        _, add_ctrl_op = self.ops[l].get_ctrl_system()
        s, target = add_ctrl_op(ctrl = [current selection bit], {'x': target})
        l += 1
        # unconstruct and ladder
qrom = ApplyL([Set(d, target_bitsize) for d in data], selection_bitsize, target_bitsize)

@tanujkhattar
Copy link
Collaborator

This should go in a tutorial notebook. We shouldn't have two QROM implementations.

@tanujkhattar
Copy link
Collaborator

After ApplyLthBloq and UnaryIterationGate, I think this can be closed. The "basic" unary iteration can be accessed using the ApplyLthBloq interface and power users can derive from UnaryIterationGate for more control.

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

No branches or pull requests

2 participants