qubitization_qpe_sparse_chem does not decompose
Opened this issue · 1 comments
mpharrigan commented
The bloq example "qubitization_qpe_sparse_chem" does not decompose all the way down. Minimal example is
bloq.as_composite_bloq().flatten()
ValueError Traceback (most recent call last)
File ~/qutran/qutran/qualtran/cirq_interop/_cirq_to_bloq.py:594, in decompose_from_cirq_style_method(bloq, method_name)
593 try:
--> 594 return cirq_optree_to_cbloq(
595 decomposed_optree, signature=bloq.signature, in_quregs=in_quregs, out_quregs=out_quregs
596 )
597 except ValueError as exc:
File ~/qutran/qutran/qualtran/cirq_interop/_cirq_to_bloq.py:516, in cirq_optree_to_cbloq(optree, signature, in_quregs, out_quregs)
515 # 3.1 Find input / output registers.
--> 516 all_op_quregs: Dict[str, NDArray[_QReg]] = {
517 k: np.apply_along_axis(_QReg, -1, *(v, reg_dtypes[i])) # type: ignore[arg-type]
518 for i, (k, v) in enumerate(split_qubits(bloq.signature, op.qubits).items())
519 }
521 in_op_quregs: Dict[str, NDArray[_QReg]] = {
522 reg.name: all_op_quregs[reg.name] for reg in bloq.signature.lefts()
523 }
File ~/qutran/qutran/qualtran/cirq_interop/_cirq_to_bloq.py:517, in <dictcomp>(.0)
515 # 3.1 Find input / output registers.
516 all_op_quregs: Dict[str, NDArray[_QReg]] = {
--> 517 k: np.apply_along_axis(_QReg, -1, *(v, reg_dtypes[i])) # type: ignore[arg-type]
518 for i, (k, v) in enumerate(split_qubits(bloq.signature, op.qubits).items())
519 }
521 in_op_quregs: Dict[str, NDArray[_QReg]] = {
522 reg.name: all_op_quregs[reg.name] for reg in bloq.signature.lefts()
523 }
File ~/qutran/py311-cf/lib/python3.11/site-packages/numpy/lib/shape_base.py:376, in apply_along_axis(func1d, axis, arr, *args, **kwargs)
375 except StopIteration:
--> 376 raise ValueError(
377 'Cannot apply_along_axis when any iteration dimensions are 0'
378 ) from None
379 res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
ValueError: Cannot apply_along_axis when any iteration dimensions are 0
using the qubit counting code and/or some forthcoming better error messages you can track exactly where the error is coming from
RuntimeError: An unexpected error occurred when trying to compute qubit count for QubitizationQPE: An unexpected error occurred when trying to compute qubit count for QubitizationWalkOperator: An unexpected error occurred when trying to compute qubit count for ReflectionUsingPrepare: Unexpected error when decomposing ReflectionUsingPrepare: Cannot apply_along_axis when any iteration dimensions are 0