quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.24k stars 1.01k forks source link

phase exponent ignored in approximate comparisons of `cirq.PhasedISwapPowGate` #6529

Open richrines1 opened 6 months ago

richrines1 commented 6 months ago

Description of the issue

PhasedISwapPowGate doesn't override the _value_equality_approximate_values_ implementation it inherits from EigenGate, which means its phase exponent attribute isn't included in approximate comparisons

the one exception is when its phase exponent is zero, in which case approximate comparison fails even when it shouldn't due to some of the same inconsistencies described for cirq.PhasedXPowGate in #6528

How to reproduce the issue

gate0 = cirq.PhasedISwapPowGate(phase_exponent=0)
gate1 = cirq.PhasedISwapPowGate(phase_exponent=1e-12)
gate2 = cirq.PhasedISwapPowGate(phase_exponent=2e-12)
gate3 = cirq.PhasedISwapPowGate(phase_exponent=0.345)

assert cirq.approx_eq(gate1, gate2)  # ok
assert cirq.approx_eq(gate1, gate0)  # fails, even though they are as close as the previous two
assert cirq.approx_eq(gate1, gate3)  # passes, but shouldn't

assert cirq.equal_up_to_global_phase(gate1, gate2)  # ok
assert cirq.equal_up_to_global_phase(gate1, gate0)  # fails, even though they are as close as the previous two
assert cirq.equal_up_to_global_phase(gate1, gate3)  # passes, but shouldn't

Cirq version

1.4.0.dev20240209232305
ericdequ commented 6 months ago

This is Eric from sync please assign me issue and hello everyone!

kitsiosvas commented 2 weeks ago

Hello is this still open ? Am interested