Skip to content

Challenges of bidirectional cirq <-> bloqade transpilation: squin.cirq.emit_circuit. #383

@jon-wurtz

Description

@jon-wurtz

This is a blocker for QuEraComputing/bloqade#260.

Challenges with input and output values

circuit:cirq.Circuit = ...
kernel = squin.cirq.load_circuit(circuit,
                                 kernel_name="test",
                                 register_as_argument=False,
                                 return_register=True)

circuit2:cirq.Circuit = squin.cirq.emit_circuit(kernel)

which creates the qubits as part of the kernel and returns the qubits at the end-- aka, state prep. This throws an error EmitError: The method you are trying to convert to a circuit has a return value, but returning from a circuit is not supported.. Could any returns just be ignored?

Likewise,

circuit:cirq.Circuit = ...
kernel = squin.cirq.load_circuit(circuit,
                                 kernel_name="test",
                                 register_as_argument=True,
                                 return_register=False)

circuit2:cirq.Circuit = squin.cirq.emit_circuit(kernel)

Which inputs qubits from elsewhere and returns nothing at the end-- aka, an operator. This throws an error InterpreterError: SSAValue <BlockArgument[IList[Qubit, AnyType()]] q, uses: 15> not found which perhaps is reasonable (where are the qubits defined??) but nonetheless a bit unclear as an error message.

circuit:cirq.Circuit = ...
kernel = squin.cirq.load_circuit(circuit,
                                 kernel_name="test",
                                 register_as_argument=False,
                                 return_register=False)

circuit2:cirq.Circuit = squin.cirq.emit_circuit(kernel)

This does work, though that kernel functionally does nothing: it does state prep on some register, and then throws those registers away by forcing them to stay within its own scope.

Proposed simple solution: ignore any return values when transpiling back to cirq.

Challenges with conditional control

reg = cirq.LineQubit.range(8)
circuit = cirq.Circuit()
circuit.append(cirq.measure(reg[0], key="m"))
circuit.append(cirq.H(reg[1]).with_classical_controls("m"))

kernel = squin.cirq.load_circuit(circuit,
                                 kernel_name="test")
circuit2 = squin.cirq.emit_circuit(kernel)
kernel.print()

The forward works fine, but the reverse errors with the printed message else region must have a single block

Sub-issues

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions