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

qubitization_qpe_sparse_chem does not decompose #1364

Open
mpharrigan opened this issue Aug 29, 2024 · 1 comment
Open

qubitization_qpe_sparse_chem does not decompose #1364

mpharrigan opened this issue Aug 29, 2024 · 1 comment

Comments

@mpharrigan
Copy link
Collaborator

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
@fdmalone
Copy link
Collaborator

fdmalone commented Aug 29, 2024

I think this is related to #1351. There's some inconsistency currently with piping through all the junk registers when building the walk operators

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

No branches or pull requests

2 participants