quantumlib / Qualtran

Qᴜᴀʟᴛʀᴀɴ is a Python library for expressing and analyzing Fault Tolerant Quantum algorithms.
https://qualtran.readthedocs.io/en/latest/
Apache License 2.0
132 stars 35 forks source link

Remove `_t_complexity_` on `MultiAnd` and support symbolic `cvs` #1015

Closed tanujkhattar closed 1 month ago

tanujkhattar commented 1 month ago

Part of a larger effort to better support symbolic resource estimation across bloqs. I will update the cvs parameter on other bloqs in follow-up PRs.

tanujkhattar commented 1 month ago

Addressed all the comments. Also realized that its a bit annoying to have HasLength as a drop-in replacement where len(cvs) just returns a symbolic value because of the way python treats the __len__ dunder method. Explained in the docstring and added a workaround. Merging now

anurudhp commented 1 month ago

Also realized that its a bit annoying to have HasLength as a drop-in replacement where len(cvs) just returns a symbolic value because of the way python treats the __len__ dunder method.

@tanujkhattar fwiw, I faced the same issue when implementing Shaped, my workaround was to define slen: https://github.com/quantumlib/Qualtran/blob/5aabc66c37bd4c8e8b330a896b98178109c5bd34/qualtran/symbolics/math_funcs.py#L102-L105

We should extend this by adding HasLength to the input type here.

mpharrigan commented 1 month ago

and/or make HasLength be a subclass of Shaped