Skip to content

Conversation

@purva-thakre
Copy link
Contributor

No description provided.

@ACE07-Sev
Copy link
Contributor

For global phase, what is the issue exactly?

@purva-thakre
Copy link
Contributor Author

purva-thakre commented Nov 19, 2025

For global phase, what is the issue exactly?

Cirq's global phase gate's parameter is incompatible with the input parameter of Qrisp's global phase gate. For now, we are temporarily ignoring this gate in the conversion function until I figure out a generic mapping between the two.

@ACE07-Sev
Copy link
Contributor

Cirq takes np.exp(1j*theta) directly. You need to just pass that instead of pure theta. If you have an assertion for this, I can do it and give you what you'll need to put.

@purva-thakre
Copy link
Contributor Author

Not exactly that straightforward. Thanks for the offer. I have a couple of local implementations already but they are not completely generic.

@ACE07-Sev
Copy link
Contributor

Not exactly that straightforward

Could be that I'm misunderstanding what you're looking for then?

In any case, I wrote this for you so you can try it out and see if this is what you wanted :) .

from qrisp import *
import cirq
from numpy.testing import assert_almost_equal

def main():
    qv = QuantumBool()

    h(qv)
    gphase(0.1, qv)

    return qv.qs.statevector("array")

qc = cirq.Circuit()
q = cirq.LineQubit.range(1)

qc.append(cirq.ops.H(q[0]))
qc.append(cirq.ops.GlobalPhaseGate(np.exp(1j * 0.1))())

target = cirq.final_state_vector(qc)
current = main()

assert_almost_equal(target, current)

@purva-thakre purva-thakre marked this pull request as ready for review November 20, 2025 16:30
)

if op_i in ["gphase"]:
print(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the issue here? Why doesn't the global phase gate work? I know we discussed this but I still didn't fully understand.


if (op_i not in cirq_gates_filter) and instr.op.definition:
new_circ = instr.op.definition
cirq_circuit.append(convert_to_cirq(new_circ))
Copy link
Contributor

@positr0nium positr0nium Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is still an issue here. I'd expect that you somehow have to specify the relevant cirq qubits. This bugged example confirms my suspicion:

from qrisp import *

qc = QuantumCircuit(4)
qc.rxx(0.3, 0, 1)
qc.rxx(0.3, 2, 3)
print(qc.to_cirq())
# 0: ───H───@─────────────@───H───H───@─────────────@───H───
#           │             │           │             │
# 1: ───H───X───Z^0.095───X───H───H───X───Z^0.095───X───H───

@positr0nium
Copy link
Contributor

Apart from the mentioned issue, I think it's done - thank you :)
One final thing: Please also make sure to insert the method here and check if the generated docs look good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants