munich-quantum-toolkit / munich-quantum-toolkit/core-plugins-catalyst

🐛 Some bugs in `ToQuantumComputationPattern`

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

Nobody has claimed this yet.

bug c++
Dominant language
C++
Stars
8
Forks
2
Avg merge
5h 27m
Merged PRs (30d)
34

Description

System and Environment Information
  • Arch Linux
  • feature branch, but should be the same on main
  • C++, GCC 15.2.1
  • LLVM 21.1.0
Bug Description
  1. The current implementation cannot handle "normal" non-static parameters with a arith.constant. This should become easy to fix after the Dialect Rewrite since the constants will be accessible via the interface if I remember correctly. For now, I used a helper function (see here) to add the parameters here. This will lead to a crash because the parameters are access without any check since it is to be expected for e.g. a rotation gate to have exactly one parameter.
  2. The current implementation cannot handle operations without a target like GPhaseOp. This can be solved by a check here and here
  3. The name of the qubit registers (at least in OpenQASM 2) which is read here will result in a syntax error in OpenQASM because it will be something like %1 = "mqtopt.allocQubitRegister"() <{size_attr = 2 : i64}> : () -> !mqtopt.QubitRegister
  4. allocQubit is not supported yet and requires the code to be re-written using allocQubitRegister (not necessarily a bug)

Especially regarding the first issue, I think it makes sense to wait for the dialect rewrite which will require

Steps to Reproduce

While trying to use the ToQuantumComputationPattern to dump MLIR code as OpenQASM, I noticed some minor bugs in the current implementation. For this, I modified the round-trip pass to dump the MLIR code as OpenQASM code to verify it more easily.
While munich-quantum-toolkit/core-plugins-catalyst#46 already addresses some usability issues, I wanted to add actual bugs that need to be fixed in order to use it for its intended purpose outside of the "round-trip" test cases.

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 with mlir/lib/Dialect/MQTOpt/Transforms/ToQuantumComputationPattern.cpp, especially the referenced parameter, target, and register-name handling, and consult Helpers.h at the linked helper. Reproduce the cases through the modified round-trip pass that dumps MLIR as OpenQASM. Done means non-static parameters and targetless operations are handled safely, register names produce valid OpenQASM, and allocQubit is addressed or clearly bounded by the dialect rewrite.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.