Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of operation and/or gate equivalence tooling #16

Open
tyleratrigetti opened this issue Jul 29, 2024 · 0 comments
Open

Implementation of operation and/or gate equivalence tooling #16

tyleratrigetti opened this issue Jul 29, 2024 · 0 comments

Comments

@tyleratrigetti
Copy link
Contributor

Custom pyLIQTR gates and ops don't seem to have a way of quickly and easily assessing if two operations or gates are the same. This is useful when performing decomposition for the purposes of resource estimation. For example, if two operations only differ by a qubit relabelling, it would be useful to re-use cached downstream resource estimates (for example, via Rigetti's estimation tool.

It appears that many cirq gates and operations provide such tooling via the @value.value_equality decorator and related _value_equality_values_ method. For example in the definition of the PhasedXPow gate or the definition for the PauliStringPhasor.

Here is a trivial example:

@value.value_equality(distinct_child_types=True)
class MyGate(gate_features.InterchangeableQubitsGate,raw_types.Gate):
    def __init__(self,angle):
        super(MyGate, self)
        self._angle = angle
        
    def _num_qubits_(self):
        return 2

    def _unitary_(self):
        return np.array([
            [1.0,  1.0],
            [-1.0, 1.0]
        ]) / np.sqrt(2)

    def _circuit_diagram_info_(self, args):
        return "G"
    
    def _value_equality_values_(self):
        return self._angle

Establishing when two ops/gates are equivalent may be non-trivial to determine, as it may be context dependent. For example, for the purposes of resource estimation, the gates/ops might be equivalent, but for simulation/compilation they may not be. If possible, it might be useful to provide tooling for the user to specify the context under which they are performing the equivalence check. This might be outside of the scope of cirq gates/ops, but due to pyLIQTR's awareness of resource estimation, it may be useful to separate unitary equivalence and resource equivalence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant