Skip to content

cirq.unitary fails for bloq with And followed by And^dagger #1488

Open
@anurudhp

Description

@anurudhp
import attrs
import cirq
from qualtran import Bloq, Signature
from qualtran.bloqs.mcmt import And
from qualtran.cirq_interop import BloqAsCirqGate

@attrs.frozen
class MyBloq(Bloq):
    @property
    def signature(self):
        return Signature.build(a=1, b=1)

    def build_composite_bloq(self, bb, a, b):
        [a, b], c = bb.add(And(), ctrl=[a, b])
        [a, b] = bb.add(And().adjoint(), ctrl=[a, b], target=c)
        return dict(a=a, b=b)

MyBloq().tensor_contract() # works
cirq.unitary(BloqAsCirqGate(MyBloq())) # fails
TypeError: cirq.unitary failed. Value doesn't have a (non-parameterized) unitary effect.

type: <class 'qualtran.cirq_interop._bloq_to_cirq.BloqAsCirqGate'>
value: BloqAsCirqGate(MyBloq)

Metadata

Metadata

Assignees

No one assigned

    Labels

    cirq_interopIssues related to Cirq interop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions