Skip to content

Isometry is phase-incorrect for [-1,0] #15465

@Cryoris

Description

@Cryoris

Environment

  • Qiskit version: 2.3.0rc1 (& others)
  • Python version: 3.11
  • Operating system: macOS

What is happening?

Isometry does not correctly set the global phase if the input state is the single-qubit $-|0\rangle$, i.e. [-1, 0]. For all other global phases and more than single-qubit states it works, though. This affects Initialize and StatePreparation, too, since they are based on Isometry.

How can we reproduce the issue?

from qiskit.circuit.library import Isometry, Initialize
from qiskit.quantum_info import Statevector
import numpy as np

vecs = [
  [np.exp(1j * np.pi), 0], # -|0>, doesn't work
  [np.exp(1j * np.pi * 0.9999), 0], # close to -|0>, works
  [np.exp(1j * np.pi), 0, 0, 0], # -|00>, works
]

for vec in vecs:
  sv = Statevector(Isometry(vec, 0, 0).definition)
  print(sv)

What should happen?

The output circuit should have the correct phase of pi.

Any suggestions?

Isometry does a bunch of tests checking if matrices are the identity up to global phase. We can probably fix this by correcting the global phase there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions