Skip to content

Projection circuits are really large #124

Description

@MDeiml

With the current implementation, the projection circuits grow exponentially with the number of actual tree levels (that cannot be compressed into tensor factors). This is because the result of each child is uncomputed again after computing the result of the parent

circuit = (
circuit + tq.gates.X(target=flag, control=intermediate_flags) + tq.gates.X(target=flag) + circuit.adjoint()
)

Subspace("000") & (Subspace("##") | (Subspace("#") | Subspace("0")))
circuit:
X(target=(2,))
X(target=(7,), control=(2,))
X(target=(7,), control=(2,))
X(target=(2,))
X(target=(1,), control=(2,))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(0, 1, 2))
X(target=(8,), control=(1, 2))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(2,))
X(target=(7,), control=(8, 2))
X(target=(7,), control=(2,))
X(target=(8,), control=(2,))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(0, 1, 2))
X(target=(0,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(7,))
X(target=(3,))
X(target=(4,))
X(target=(5,))
X(target=(6,), control=(7, 3, 4, 5))
X(target=(6,))
X(target=(5,))
X(target=(4,))
X(target=(3,))
X(target=(7,))
X(target=(1,), control=(2,))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(0, 1, 2))
X(target=(8,), control=(1, 2))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(2,))
X(target=(7,), control=(2,))
X(target=(7,), control=(8, 2))
X(target=(8,), control=(2,))
X(target=(0,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(0, 1, 2))
X(target=(0,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(8,), control=(1, 2))
X(target=(8,), control=(1, 2))
X(target=(1,), control=(2,))
X(target=(2,))
X(target=(7,), control=(2,))
X(target=(7,), control=(2,))
X(target=(2,))

This is of course good to reduce the number of needed ancillas, but on real hardware the number of bits is not the limiting factor, rather the number of operations.

Subspaces corresponding to Subspace.from_dim are especially inefficient. In the above case corresponding to dim=7 it would have been enough to exclude the 111 case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions