Skip to content

[BUG] Adjoint breaks Qualtran integration #8567

@cvjjm

Description

@cvjjm

Expected behavior

qml.to_bloq() should yield valid bloqs also for quantum functions that contain adjoint operations.

Actual behavior

Trying to call t_complexity() on a bloq made from a quantum function with adjoint leads to an Exception deep inside Qualtran:

AssertionError: Input register _QReg(qubits=(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), dtype=QAny(bitsize=18)) not found, suggesting a bug

Additional information

No response

Source code

import pennylane as qml
from qualtran.cirq_interop.t_complexity_protocol import t_complexity

bitstrings = ['100000101100000110', '010100110100111010']
angle_wires = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

def qrom_qfunc():
    # qml.QROM( # witout adjoint it works
    qml.adjoint(qml.QROM)(
        bitstrings=bitstrings,
        control_wires=[0],
        target_wires=angle_wires,
        work_wires=[],
    )
bloq = qml.to_bloq(qrom_qfunc)
tc = t_complexity(bloq)
print(tc)

Tracebacks

System information

Name: pennylane
Version: 0.43.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: 
Author: 
Author-email: 
License-Expression: Apache-2.0
Location: /fs/home/cvjjm/.conda/envs/.../lib/python3.13/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: covvqetools, pennylane_lightning, qualtran

Platform info:           Linux-5.14.0-427.13.1.el9_4.x86_64-x86_64-with-glibc2.34
Python version:          3.13.9
Numpy version:           1.26.4
Scipy version:           1.16.2
JAX version:             None
Installed devices:
- lightning.qubit (pennylane_lightning-0.43.0)
- default.clifford (pennylane-0.43.0)
- default.gaussian (pennylane-0.43.0)
- default.mixed (pennylane-0.43.0)
- default.qubit (pennylane-0.43.0)
- default.qutrit (pennylane-0.43.0)
- default.qutrit.mixed (pennylane-0.43.0)
- default.tensor (pennylane-0.43.0)
- null.qubit (pennylane-0.43.0)
- reference.qubit (pennylane-0.43.0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions