Skip to content

Eliminate awful slowdown of EigenGate._value_equality_values_ #6695

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

Merged

Conversation

pavoljuhas
Copy link
Collaborator

Problem: The sympy.Expr.is_constant() introduced in #6669 is very
slow causing glacial-speed equality checks of parameterized gates.

Solution: Check if expression is sympy.Number instead which still
satisfies the equality fix added in #6669.

Timing of
check/pytest --numprocesses=0 --randomly-seed=0
cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py
Before: 945 s After: 18 s, Before #6669: 18 s.

Problem: The `sympy.Expr.is_constant()` introduced in quantumlib#6669 is very
slow causing glacial-speed equality checks of parameterized gates.

Solution: Check if expression is sympy.Number instead which still
satisfies the equality fix added in quantumlib#6669.

Timing of
  check/pytest --numprocesses=0 --randomly-seed=0 \
    cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py
Before: 945 s   After: 18 s,  Before quantumlib#6669: 18 s.
@pavoljuhas pavoljuhas requested review from vtomole and a team as code owners August 1, 2024 07:25
@CirqBot CirqBot added the Size: XS <10 lines changed label Aug 1, 2024
@pavoljuhas pavoljuhas requested a review from viathor August 1, 2024 07:25
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.82%. Comparing base (c25678e) to head (1529ba0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6695   +/-   ##
=======================================
  Coverage   97.82%   97.82%           
=======================================
  Files        1074     1074           
  Lines       92126    92126           
=======================================
  Hits        90124    90124           
  Misses       2002     2002           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pavoljuhas pavoljuhas merged commit 60ab3c0 into quantumlib:main Aug 1, 2024
34 checks passed
@pavoljuhas pavoljuhas deleted the fix-tests-slowdown-after-6669 branch August 1, 2024 17:24
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…tumlib#6695)

Problem: The `sympy.Expr.is_constant()` introduced in quantumlib#6669 is very
slow causing glacial-speed equality checks of parameterized gates.

Solution: Check if expression is sympy.Number instead which still
satisfies the equality fix added in quantumlib#6669.

Timing of
  check/pytest --numprocesses=0 --randomly-seed=0 \
    cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py
Before: 945 s   After: 18 s,  Before quantumlib#6669: 18 s.
BichengYing pushed a commit to BichengYing/Cirq that referenced this pull request Jun 20, 2025
…tumlib#6695)

Problem: The `sympy.Expr.is_constant()` introduced in quantumlib#6669 is very
slow causing glacial-speed equality checks of parameterized gates.

Solution: Check if expression is sympy.Number instead which still
satisfies the equality fix added in quantumlib#6669.

Timing of
  check/pytest --numprocesses=0 --randomly-seed=0 \
    cirq-core/cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py
Before: 945 s   After: 18 s,  Before quantumlib#6669: 18 s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: XS <10 lines changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants