Skip to content

[Bug]: Handling of double-entanglement is inconsistent #339

@thierry-martinez

Description

@thierry-martinez

Graphix does not handle double-entanglement consistently.

This has been reported in Mateo's comment: #332 (comment).

When a pair of qubits is entangled twice, simulators consider that the second entanglement cancels the first one, which is expected: $CZ ∘ CZ = I$. However, when the underlying graph of a pattern is computed (in Pattern.get_graph), the second entanglement is ignored, which makes flow analyses and Pauli presimulation ignore the second entanglement.

For instance, the following test currently fails, revealing that the round-trip between patterns and open graphs is distinguishable by simulation.

def test_double_entanglement() -> None:
    pattern = Pattern(input_nodes=[0, 1], cmds=[command.E((0, 1)), command.E((0, 1))])
    pattern2 = OpenGraph.from_pattern(pattern).to_pattern()
    state = pattern.simulate_pattern()
    state2 = pattern2.simulate_pattern()
    assert np.abs(np.dot(state.flatten().conjugate(), state2.flatten())) == pytest.approx(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions