Skip to content

[Performance] Resource counting for a bloq.adjoint() needs a bloq decomposition even when my_static_cost or build_call_graph is implemented for the bloq #1841

@Axel-pappalardo

Description

@Axel-pappalardo

Using the call_graph example (but it applies similarly to qubit count/my_static_cost):

If one defines a Bloq with a build_call_graph, then calls bloq.adjoint().call_graph(), the current behaviour in Qualtran is to call for the bloq.adjoint() decomposition, which can, especially when working with big circuit, lead to performance issue.

However with most Bloq, the call_graph of bloq.ajdoint() is simply the "adjoint of the original bloq.call_graph()" ie, the original bloq.call_graph() with every element replace by its adjoint.
Do you think it is possible to get bloq.adjoint() call_graph to be the adjoint of the call_graph by default or via an optional argument ?
This could obviously raise issue in situation where the adjoint is very different (for example when doing measurement based uncomputing), which is why it should probably remain optional.

The same problem arise when using my_static_cost, for example when estimating qubit count, (and in this case, I believe the qubit count of bloq.adjoint() should always be the same as the bloq).

There is a similar issue when using bloq.controlled(), however this one is probably more complex.

Currently the solution I am using is to create a wrapper bloq for the adjoint version, but it does involve a lot of verbose which would be nice to avoid.

Let me know what you think.

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