Skip to content

Commit

Permalink
Revert "Set sympy.evaluate(False) on frequent code paths for phase tr…
Browse files Browse the repository at this point in the history
…acking. (#6072)" (#6386)

With recent adoption of symengine for the performance critical path
with ParameterExpressions the workaround for large expression evaluation
in #6072 is no longer needed or applicable, except in environments
without symengine. However, with symengine available using the sympy
evaluate context adds noticeable overhead, both to import sympy (which
wouldn't be used otherwise) and to load the sympy evalue context
wrapper. This commit removes these as we shouldn't compromise performance
in the performance path to try and speed up a path with degraded
performance because symengine isn't available (32bit platforms).

This reverts commit f436f5a.

Co-authored-by: Kevin Krsulich <[email protected]>
  • Loading branch information
mtreinish and kdk authored May 12, 2021
1 parent a957172 commit 9b78934
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,7 @@ def substitute_node_with_dag(self, node, input_dag, wires=None):
in_dag.apply_operation_back(replay_node.op, replay_node.qargs, replay_node.cargs)

if in_dag.global_phase:
from sympy import evaluate

with evaluate(False):
self.global_phase += in_dag.global_phase
self.global_phase += in_dag.global_phase

if wires is None:
wires = in_dag.wires
Expand Down
5 changes: 1 addition & 4 deletions qiskit/transpiler/passes/basis/basis_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ def run(self, dag):
dag.substitute_node(node, dag_op, inplace=True)

if bound_target_dag.global_phase:
from sympy import evaluate

with evaluate(False):
dag.global_phase += bound_target_dag.global_phase
dag.global_phase += bound_target_dag.global_phase
else:
dag.substitute_node_with_dag(node, bound_target_dag)
else:
Expand Down

0 comments on commit 9b78934

Please sign in to comment.