Skip to content

several SparsePauliOp methods ignore self.paulis.phase #12883

@aeddins-ibm

Description

@aeddins-ibm

Environment

  • Qiskit version: 1.1.1
  • Python version: 3.11.6
  • Operating system: macos

What is happening?

If I understand it right, SparsePauliOp.simplify() does not correctly take into account the phase attribute of its underlying PauliList.

The same also seems true for several SparsePauliOp methods under the header "LinearOp Methods", like conjugate, and adjoint, which update self.coeffs but AFAIK do not look at self.paulis.phase.

(I haven't looked exhaustively for other methods that do not handle paulis.phase.)

How can we reproduce the issue?

For example, define a SparsePauliOp, and then set its paulis attribute to a new value with nonzero phase:

spo = qi.SparsePauliOp(['X', 'X'])
spo.paulis = ['X','-X']
print(spo)
SparsePauliOp(['X', '-X'],
              coeffs=[1.+0.j, 1.+0.j])

So far so good. But now call simplify:

spo.simplify()
SparsePauliOp(['X'],
              coeffs=[2.+0.j])

AFAIK this is incorrect.

What should happen?

The example above should instead match this result where we construct the SPO differently:

spo_2 = qi.SparsePauliOp(['X','-X'])
spo_2.simplify()
SparsePauliOp(['I'],
              coeffs=[0.+0.j])

Any suggestions?

Either we need to fix all the methods to consider paulis.phase, or (probably better) we need to more strictly require that the paulis attribute never has any phase, e.g. updating the paulis() setter to move the phase into the coeffs (don't know what else would need to change).

Another example:

spo_1 = qi.SparsePauliOp(['X'])
spo_1.paulis = qi.PauliList(['-1jX'])
spo_1
SparsePauliOp(['-iX'],
              coeffs=[1.+0.j])

Now try conjugate():

spo_1.conjugate()
SparsePauliOp(['-iX'],
              coeffs=[1.-0.j])

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