Closed xabomon closed 4 years ago
Hey Xavi. This is a great question. To my knowledge we don't have this yet but it should be very high priority for us to develop that. Sure, open a PR! I would ask @mpharrigan to take a look at it. This is a fairly critical functionality however so @mpharrigan might have a lot of comments.
Hi @babbush , Thanks answering the question, if you agree I will close this issue.
I will open a PR with some stuff that I've done on putting QubitOperators to Cirq. I expect to get some feedback/help such that the functionalities are general enough, let's see how it goes.
Best, Xavi
Great. We'll keep this open to track the issue and can close when the PR is merged
Hi Matthew, No problem from my side to keep the issue open.
About the PR, I will probably make it with limited testing as I'm not (yet) familiar on how to test in Cirq. I will be very much grateful for any input you could provide me.
Best, Xavi
happy to help. briefly, each python module my_module.py
should have an associated my_module_test.py
file containing functions whose name end in _test()
that verifies the code is working via assertions
Did you ever happen to make any progress on this? I whipped together this naive implementation for my personal use:
def qubit_operator_to_pauli_sum(qubit_op):
psum = cirq.PauliSum()
for ind_ops, coeff in qubit_op.terms.items():
if ind_ops == tuple():
psum += coeff
continue
pstring = cirq.PauliString()
for ind, op in ind_ops:
if op == 'X':
op = cirq.X
elif op == 'Y':
op = cirq.Y
elif op == 'Z':
op = cirq.Z
pstring *= op(cirq.LineQubit(ind))
psum += pstring * coeff
return psum
Hi @mpharrigan ,
I actually do have something, and it is different than what you propose here. My function takes a qubit operator or a list of qubit operators and generates the first Trotter circuit of it.
If you think that it can be useful for other people I can take some time to finish up a decent PR.
Thanks for taking the time to write some code.
Best, Xavi
Hi Matt,
Just to follow up on the OpenFermion meeting, I think I have much clearer picture of OpenFermion-Cirq.
I will clean up what I had in mind and PR here. After that I will write code to pass between QubitOperator and PauliString and then we might decide how to move forward on this topic, and eventually extend it to other OpenFermion objects.
Best, Xavi
Opened https://github.com/quantumlib/OpenFermion-Cirq/issues/372 for that issue
This issue has been resolved in OF.
Hi all,
Sorry for bothering with this question.
I recently have been working with Cirq and OpenFermion-Cirq and I would like to ask if a module that allows one to go from QubitOperator (or any other OpenFermion object) to a circuit (potentially parametrized) already exist in either Cirq or OpenFermion-Cirq.
Before asking this I dug into the code but I was unable to find any type of serializer/util. However, I found that the PauliString object could be the thing that allows me to go from Pauli strings (as QubitOperators) to a circuit, so does it exist a function to initialize PauliString from QubitOperator? If not, I have been writing my own functions to do so, and I could commit them. Another question is where do they fit better, Cirq or OpenFermion-Cirq?
Best regards, Xavi