Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

`CtrlSpec` add support for symbolic `Shaped` control values

Open anurudhp opened this issue 1 year ago • 2 comments

Useful when we know the number of controls, e.g. https://github.com/quantumlib/Qualtran/pull/1155#discussion_r1684923203

Related #786

anurudhp avatar Jul 20 '24 01:07 anurudhp

What is missing?

mpharrigan avatar Jul 23 '24 17:07 mpharrigan

Requires some fixes to how shapes and num_qubits are computed to work with symbolics, and updated type hints. Didn't want to over-complicate #1155, so this can be done in a follow-up.

anurudhp avatar Jul 23 '24 23:07 anurudhp

@anurudhp @mpharrigan I am finding that MultiControlX(symbolic n).controlled() is causing issues. This issue was linked in the build_call_graph function for MultiControlX with symbolic cvs - what's required to fix this?

Code to reproduce:

n = sympy.symbols('n', integer=True) bloq = MultiControlX(cvs=HasLength(n)).controlled(ctrl_spec=CtrlSpec(cvs=0)) cost = get_cost_value(bloq, QECGatesCost()).total_t_and_ccz_count()

fpapa250 avatar Nov 27 '24 04:11 fpapa250

@fpapa250 this will be fixed by #1492 (which removes the call graph override and uses the default from ControlledViaAnd). I tested the code snippet against that branch and it prints {'n_t': 0, 'n_ccz': n}

anurudhp avatar Nov 27 '24 09:11 anurudhp

Awesome! That will unblock https://github.com/quantumlib/Qualtran/pull/1489. Equals.controlled breaks down to that case and is causing issues with the symbolic cost unit test.

fpapa250 avatar Nov 27 '24 17:11 fpapa250