quantumlib / Cirq

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

Eliminate awful slowdown of `EigenGate._value_equality_values_` #6695

Closed pavoljuhas closed 3 months ago

pavoljuhas commented 3 months ago

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.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.