# How to convert Pennylane decompose_hamiltonian to Cirq PauliString?

I have a matrix that I would like to decompose into a Pauli String. Pennylane's qml.utils.decompose_hamiltonian does this and returns a list of coefficients and a list of operations representing the decomposition.

Is there any simple way to convert the format of the returned operations, i.e. from Identity(wires=[0]) @ PauliZ(wires=[1]) (Pennylane syntax) to cirq.PauliString(cirq.I(qubits[0]), cirq.Z(qubits[1]))?

Use Pennylane's pauli_word_to_string function to convert Identity(wires=[0]) @ PauliZ(wires=[1]) to string. Then use cirq.DensePauliString(str).sparse() to convert this string to PauliString:

coeffs, obs_list = decompose_hamiltonian(A)

# Get PauliStrings:
for op in obs_list:
print(cirq.DensePauliString(pauli_word_to_string(op)).sparse())

# Get PauliSum:
pauli_sum = cirq.PauliSum.from_pauli_strings([
cirq.DensePauliString(pauli_word_to_string(op), coefficient = coeffs[index]).sparse()
for index, op in enumerate(obs_list)
])