OpenQASM import and export

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust
Domain
api, backend

Research direction

Start with src/circuit.rs, especially Label and how instructions retain names and angles; inspect the circuit API for import and export entry points. The issue outlines OpenQASM 2 and 3 edge cases, unsupported import statements, and unitary decomposition, so first map the supported gates and conditions. Done means circuits can be imported from and exported to the described QASM versions with clear errors for unsupported cases.

Written by the indexing model from the issue text.

Description

enhancement
What you want to do

Move circuits between qsengine and Qiskit, other simulators, or hardware. Today there is no way
in or out except rebuilding the circuit gate by gate.

Implementation notes
  • Each instruction already keeps its name and angles (Label in src/circuit.rs, described as
    kept "for drawing and later for export").
  • OpenQASM 2 limits:
    • if (c == v) compares the whole register, but qsengine conditions on any subset of bits.
      Export conditions only when they cover the whole register; otherwise raise and point to version 3.
    • p / cp are u1 / cu1 in qelib1.inc.
  • unitary gates have no name in QASM. Export them as U(θ,φ,λ) from a ZYZ decomposition
    (record the global phase as gphase in QASM 3). Controlled unitary gates need a controlled-U
    decomposition, or should raise.
  • Import: parse the subset qsengine supports, and give a clear error naming the first unsupported
    statement (custom gate definitions, loops and so on).
What it could look like
qc = qsengine.QuantumCircuit.from_qasm(open("bell.qasm").read())
print(qc.to_qasm())            # OpenQASM 3 by default
print(qc.to_qasm(version=2))
Contributing
  • I would like to open a pull request for this (see CONTRIBUTING.md).
Dominant language
Rust
Stars
1
Forks
0
Avg merge
12m
Merged PRs (30d)
4

Getting set up

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 kaiwave/qsengine

All issues in kaiwave/qsengine

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.