Skip to content

Pass Manager for Swap Optimal circuits raises errors for linear Pauli Strings #1

@JanikSchoenmeierKromer

Description

@JanikSchoenmeierKromer

Describe the issue:

The PassManager in Step 2 "Apply Swap strategies" from the "how_to_build_qaoa_swap_circuit.ipynb" notebook raises an error message for "linear" Pauli Strings in the SparsePauliOp (e.g. 'ZIIIIIIIII'; containing only a single Z Pauli and Identities otherwise instead of the exemplary used two Z Pauli strings, e.g. 'ZZIIIIIIII') . These linear terms can be relevant for optimization problems.

Reproduce the code example:

Initializing the Sparse Pauli Operator in the notebook with an additional Pauli String and coeeficient of the form ['ZIIIIIIIII', 1.] and running the notebook reproduces the error.
E.g. Insert the following code instead of the second cell of the notebook and continue all steps including calling swapped_cost_layer = pm_pre.run(cost_layer).

from qiskit.quantum_info import SparsePauliOp

local_correlators = [['ZIIIIIIIII', 1.],['IIIIIZZIII', 1.], ['IIIIIIZIZI', 1.0], ['IIIIIIZIIZ', 1.0], ['ZIIIIZIIII', 1.0], ['IIIIZZIIII', 1.0], ['IIZIIIIZII', 1.0], ['IZZIIIIIII', 1.0], ['IIZZIIIIII', 1.0], ['IIIIIIIZZI', 1.0], ['IIIIZIIZII', 1.0], ['IIIIZIIIIZ', 1.0], ['IIIIIIIIZZ', 1.0], ['ZZIIIIIIII', 1.0], ['IZIZIIIIII', 1.0], ['ZIIZIIIIII', 1.0]]
cost_operator = SparsePauliOp.from_list(local_correlators)
print(cost_operator)

Error message:

    280 """Run all the passes on a ``circuit``.
    281 
    282 Args:
   (...)
...
    110 if len(edge) != 2:
--> 111     raise QiskitError(f"{pauli} does not have length two.")
    113 return edge

QiskitError: 'ZIIIIIIIII does not have length two.'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions