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

Symbolic analysis for bloqs that expect a sequence of objects as inputs but only care about the length of the sequence for symbolic costs #801

Closed
tanujkhattar opened this issue Mar 18, 2024 · 2 comments
Labels

Comments

@tanujkhattar
Copy link
Collaborator

tanujkhattar commented Mar 18, 2024

I couldn't find a way to define a sequence (list / tuple) using sympy where the length of the sequence is a symbolic parameter. This is often useful to specify costs of Bloqs which expect sequences as inputs but the call graph really only depends upon the length of this sequence. This is useful for a variety of Bloqs, like

  1. Bloqs that expect control values - Add symbolic support to Bloqs that expect control values as cvs: Tuple[int, ...] #786
  2. GQSP - [GQSP] Negative powers and Hamiltonian simulation #669 (comment)
  3. QROM - The T-cost depends mainly on the iteration length of the data while the clifford cost depends upon the actual values of the data
    (I'm sure there are more Bloqs that we should append to this list)

Let's figure out a way to support this. One way would be to have a custom wrapper class for sequences that can be instantiated via either just shape (which can be symbolic) or the actual data (in which case shape can be derived). Open to other suggestions.

cc @mpharrigan

@mpharrigan
Copy link
Collaborator

Yeah, we could have a class that just has a shape and either raises an error if you try to index into it or yields sympy symbols like Shaped(name='x', shape=(3,))[2] = Symbol('x_2')

Do we want to wrap our data or just accept Union[NDArray, Shaped]. This is consistent with how we generally do n: Union[int, sympy.Expr]

@mpharrigan
Copy link
Collaborator

implemented in #867

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

No branches or pull requests

2 participants