Symbolic Shaped#867
Conversation
10fe6aa to
7ff633e
Compare
|
@mpharrigan @tanujkhattar could you take a look at this? |
| class Shaped: | ||
| shape: tuple[SymbolicInt, ...] = field(validator=validators.instance_of(tuple)) |
There was a problem hiding this comment.
Could you write a motivating docstring? This is a qualtran-specific concept that needs to be thoroughly documented: what it is, why we need it, how you might use it
There was a problem hiding this comment.
I attempted to explain it a bit, could you check how it looks?
mpharrigan
left a comment
There was a problem hiding this comment.
very cool. Some polish things in the comments
7dd5aa0 to
2342b88
Compare
fix expression for Jacobi-Anger degree add test using 1d ising walk op, fix call graph fix test fix hamsim nb `slen`, docstrings, generalize `is_symbolic` (to remove dep. on cirq) test shape with symbolic entries docstring refs: remove extra indent skip serialize test for symbolic hamsim
2342b88 to
17d6fa7
Compare
ca44e0b to
653ae04
Compare
|
|
||
| return soqs | ||
|
|
||
| def build_call_graph(self, ssa: 'SympySymbolAllocator') -> Set['BloqCountT']: |
There was a problem hiding this comment.
what happened to this?
There was a problem hiding this comment.
We don't need a specialization anymore, it works automatically through GeneralizedQSP's call graph.
Before this, there was no way to build GQSP without the exact polynomial, so I had to override it here.
| if len(args) != 1: | ||
| return any(is_symbolic(arg) for arg in args) | ||
|
|
||
| (arg,) = args |
There was a problem hiding this comment.
to my surprise, it seems any(...) for an empty generator returns False, so line 56 automatically handles this case
| return any(is_symbolic(arg) for arg in args) | ||
|
|
||
| (arg,) = args | ||
| if isinstance(arg, sympy.Basic): |
There was a problem hiding this comment.
I think we should be checking isinstance(arg, sympy.Expr), right?
There was a problem hiding this comment.
I'm not sure actually, I just copied it from the existing code.
It seems boolean expressions are instances of sympy.Basic but not sympy.Expr (https://docs.sympy.org/latest/explanation/glossary.html#term-Expr), which we may want to use for symbolic controls?
There was a problem hiding this comment.
Thanks. Interesting reading. Happy keeping this as Basic for now
mpharrigan
left a comment
There was a problem hiding this comment.
Very useful contribution for more symbolic costings!
Discussion: #801