Skip to content

Check that flows are focused in circuit extraction #474

Description

@matulni

As noted by @pranav97nair and @thierry-martinez in #445 , PauliExponentialDAG.from_focused_flow requires the flow to be focused but does not verify this. When the flow is obtained from OpenGraph.extract_pauli_flow, we don't need such a check since Pauli-flow extraction always returns a focused Pauli flow by construction, but this may not hold for arbitrary user-constructed flows (and following the same logic, we don't even check that the flow is well-formed). The current approach merely relies on the function name from_focused_flow to indicate that the flow should be focused (and well-formed, of course).

Another option would be to run is_well_formed and is_focused systematically, but that would lead to unnecessary checks in the common cases where flows come from extract_pauli_flow. This could be circumvented by adding a flag check_valid_flow to be set to False when performance is needed, but adding boolean flags to determine the function's behaviour is in general not a good practice.

@thierry-martinez suggests introducing FocusedPauliFlow and FocusedGFlow classes to indicate that a flow is focused at the type level (although this may render the API overly complex).

A related research question is open: are flows obtained from patterns via Pattern.extract_gflow focused ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions