Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Synthesis efficiency for extended_stabilizer simulator #7041

Open rabeehic opened 3 years ago

rabeehic commented 3 years ago

Information

What is the current behavior?

I used extended stabilizer simulator as my circuit has many qubits. But, I got this errors:

/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db544b20>] and got       ┌────┐┌────┐
qr_0: ┤ √X ├┤ √X ├
      └────┘└────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)
/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db560e80>, <qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db4f4040>] and got global phase: 2π
      ┌────┐┌────┐┌────────┐
qr_0: ┤ √X ├┤ √X ├┤ P(π/4) ├
      └────┘└────┘└────────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)
/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db560160>, <qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db560ac0>] and got global phase: 7π/4
      ┌────────┐┌────┐┌─────────┐
qr_0: ┤ P(π/2) ├┤ √X ├┤ P(-π/2) ├
      └────────┘└────┘└─────────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)
/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db5604c0>] and got global phase: 7π/4
      ┌────────┐┌────┐┌────────┐
qr_0: ┤ P(π/2) ├┤ √X ├┤ P(π/2) ├
      └────────┘└────┘└────────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)
/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db563c40>, <qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db4f4100>] and got global phase: 7π/4
      ┌────────┐┌────┐┌────────┐
qr_0: ┤ P(π/2) ├┤ √X ├┤ P(π/4) ├
      └────────┘└────┘└────────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)
/opt/conda/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py:166: UserWarning: Resynthesized [<qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db4f9520>, <qiskit.dagcircuit.dagnode.DAGNode object at 0x7f87db563a00>] and got global phase: 7π/4
      ┌────────┐┌────┐┌────────┐
qr_0: ┤ P(π/4) ├┤ √X ├┤ P(π/2) ├
      └────────┘└────┘└────────┘, but the original was native and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)

Steps to reproduce the problem

extended_stabilizer_simulator = AerSimulator(method='extended_stabilizer')
tranqc = transpile(qc, extended_stabilizer_simulator)
extended_stabilizer_result = extended_stabilizer_simulator.run(tranqc, shots=1).result()

What is the expected behavior?

I got this same warning when used for the small circuits as well.

Suggested solutions

Actually, I don't know much about qiskit-terra. I saw it asks to report by opening an issue here and did.

1ucian0 commented 3 years ago

It seems duplicated with https://github.com/Qiskit/qiskit-terra/issues/7033.

ecpeterson commented 3 years ago

@rabeehic Can you provide an example value of qc that triggers the warning? The smaller, the better.

levbishop commented 3 years ago

The extended_stabilizer simulator has the basis 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'sx', 'sxdg', 'swap', 'u0', 't', 'tdg', 'u1', 'p', 'ccx', 'ccz', 'delay', 'pauli' and the notion of efficient synthesis for this backend (roughly: minimize non-clifford gates) is different than for other hardware backends (minimize rabi pulses). Probably a different synthesis pass or cost function should be used for this backend. It's unclearto me where the best place in the compiler that has the context to implement this logic.

Nevertheless I can't see how the first warning got issued and briefly playing around I wasn't able to reproduce it, so there appears to be an additional bug within this pass.

1ucian0 commented 3 years ago

ping @rabeehic ?