qrisp_to_cirq raises on circuits containing a barrier

Open Beginner friendly
#1,551 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by locating the qrisp_to_cirq converter and its tests, then inspect how it passes circuit instructions to qrisp's to_cirq(). Filter out barrier instructions before conversion, as described in the issue. Verify that the supplied two-qubit example converts to Cirq and that the remaining gates are preserved.

Written by the indexing model from the issue text.

Description

bug 🐛 transpiler 🚊
Problem

qrisp_to_cirq raises on any qrisp circuit that contains a barrier. qrisp's Cirq converter has no mapping for barrier and can't decompose it. qrisp_to_pytket fails on barriers too, so transpile() has no qrisp → cirq path that works.

import qrisp
import qbraid

qc = qrisp.QuantumCircuit(2)
qc.h(0)
qc.barrier(qc.qubits)
qc.cx(0, 1)
qbraid.transpile(qc, "cirq")
ProgramConversionError: Failed to convert 'qrisp' to 'cirq' due to the following error(s):
Conversion qrisp -> cirq failed due to exception raised while converting from 'qrisp'.
ValueError: The following gates could not be decomposed into elementary instructions: barrier. ...
Conversion qrisp -> pytket -> cirq failed due to exception raised while converting from 'qrisp'.
Exception: Could not convert operation barrier to PyTket

The qasm2 route fails separately, on the openqasm3 1.0.2 breakage (qBraid/pyqasm#472).

qrisp 0.9.10, cirq 1.6.1. Found while reviewing #1536, which fixes cy, u3 and other gates on the same path, but not barriers.

Expected

The barrier is dropped, since Cirq has no barrier, and the rest of the circuit converts. In qrisp_to_cirq that means filtering barrier instructions out before calling to_cirq().

Dominant language
Python
Stars
117
Forks
66
Avg merge
1d 10h
Merged PRs (30d)
22

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from qBraid/qBraid

All issues in qBraid/qBraid

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.