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

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

Open
richrines1 opened this issue Mar 27, 2024 · 1 comment
Assignees
Labels
good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@richrines1
Copy link
Contributor

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
@richrines1 richrines1 added the kind/bug-report Something doesn't seem to work. label Mar 27, 2024
@pavoljuhas pavoljuhas added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. labels Mar 27, 2024
@ericdequ
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. no QC knowledge needed Want to contribute to Cirq, but don't know quantum computing? This issue is for you. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

No branches or pull requests

3 participants