munich-quantum-toolkit / munich-quantum-toolkit/debugger

✨ Full Support of Classically-Controlled Operations is Missing

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

Nobody has claimed this yet.

c++ enhancement help wanted
Dominant language
C++
Stars
21
Forks
7
Avg merge
9h 28m
Merged PRs (30d)
42

Description

Problem Statement

IfElse Operations in OpenQASM can be based on more than just equality conditions.
The underlying MQT Core framework already supports all of the different types of IFElse Operations, such as different comparison conditions and checks that only use subsets of classical registers or single classical bits.

Furthermore, we currently only allow IfElse Operations that contain only a single instruction in the "then" block. This makes tracking the current operation easier, but obviously does not match the full OpenQASM standard. We should therefore implement support for multi-instruction bodies accordingly.

The following are some code examples that should work in standard OpenQASM but are not allowed/parsed correctly by the debugger:


qreg q[3];
creg c[3];

...

if (c == 0) {
  x q[0];
}

This only works without the if body:

if (c == 0) x q[0];

qreg q[3];
creg c[3];

...

if (c == 0) {
  x q[0];
}

This is not supported by the Debugger's parser at all.


if (c > 0) x q[0];

The debugger only supports equality conditions for if blocks, but the simulation backend supports other conditions, too, so this should be a straightforward enhancement.


Proposed Solution

In the DDSimDebug.cpp backend and the CodePreprocessor.cpp, support for the corresponding operation types should be added when stepping through the code.

Contributor guide

Open the contributing guide

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.

Research direction

Start by reading DDSimDebug.cpp and CodePreprocessor.cpp to trace how OpenQASM IfElse operations are parsed and stepped. Implement support for the listed comparison conditions, classical subsets or bits, and multi-instruction bodies, then verify the provided OpenQASM examples work through the debugger.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.