Skip to content

RFC: API for lowering a cirq.Circuit to squin #295

@david-pl

Description

@david-pl

Looking for feedback on the API for #283, where we want to add interoperability with cirq.

There is already a draft PR here: #294

The currently chosen API there looks like this:

import cirq
from bloqade import squin

qubit = cirq.GridQubit(0, 0)
qubit2 = cirq.GridQubit(1, 0)

# Create a circuit.
circuit = cirq.Circuit(
        cirq.X(qubit),
        cirq.Y(qubit2),
        cirq.Z(qubit),
        cirq.H(qubit),
        cirq.S(qubit),
        cirq.T(qubit2),
        cirq.Rx(rads=math.pi / 4).on(qubit),
        cirq.Ry(rads=math.pi / 3).on(qubit2),
        cirq.Rz(rads=math.pi / 10).on(qubit),
        cirq.CX(qubit2, qubit),
        cirq.CZ(qubit, qubit2),
        cirq.measure(qubit, key="m"),  # Measurement.
    )

kernel = squin.load_circuit(circuit)

kernel.print()

The created kernel is a method as it would be when defined using the @squin.kernel decorator on a function. So we can then run passes / rewrites on that and throw it e.g. into a pyqrack simulator.

There are still some features missing (e.g. noisy circuits) and the API is still up for discussion.

Note, that we are also looking into potentially adding support to create a circuit from a kernel in the future. Just to keep that in mind, although there should no be discussion on this part in this issue.

Metadata

Metadata

Assignees

Labels

rfcRequest for Commentssquinsquin related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions