munich-quantum-toolkit / munich-quantum-toolkit/core

✨ Accept QIR 2.1 Base Profile programs as compiler input

Open
#1,120 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

c++ enhancement MLIR
Dominant language
C++
Stars
133
Forks
73
Avg merge
17h 34m
Merged PRs (30d)
261

Description

🤖 AI text below 🤖

Problem statement

MQT Core can emit QIR 2.1 Base Profile programs as LLVM assembly and bitcode. The MQT Compiler Collection cannot currently accept these programs as input. QIRProgram cannot be created from LLVM assembly or bitcode or converted to QCProgram. It is not part of CompilerInput, and neither the Python compiler interface nor mqt-cc accepts .ll or .bc input.

Add QIR 2.1 Base Profile programs as compiler input. Imported programs should be represented as QC programs and processed by the existing compiler pipeline.

Proposed solution
  • Add a QIR import library with public headers under mlir/include/mlir/Target/QIR and its implementation under mlir/lib/Target/QIR, next to the OpenQASM frontend. The library reads LLVM assembly and bitcode and uses LLVM/MLIR’s importer to create an MLIR LLVM-dialect module.
  • Add the semantic QIR-to-QC conversion under mlir/Conversion/QIRToQC. Keep file handling out of the conversion pass. Support the QIR entry point, QIS and runtime calls, static qubit and result references, measurements, resets, output recording, and the supporting LLVM constructs used by Base Profile programs.
  • Extend QIRProgram with factories for LLVM assembly and bitcode and a conversion to QCProgram.
  • Add QIRProgram to CompilerInput.
  • Expose QIR input through the public C++ API, the Python compiler interface, and mqt-cc.
  • Document the supported QIR version, profile, input forms, and constructs.

Adaptive Profile programs and arbitrary LLVM IR are outside the scope of this issue.

Acceptance criteria
  • LLVM assembly and bitcode containing supported QIR 2.1 Base Profile programs can be imported through QIRProgram and used through the C++, Python, and command-line compiler interfaces. Unsupported constructs produce a clear diagnostic.
  • A supported QIR program can be imported, processed by the existing compiler pipeline, and emitted again as QIR 2.1 Base Profile with equivalent observable behavior. The LLVM assembly or bitcode does not need to be identical.
  • Round-trip tests cover MQT-generated QIR and representative external QIR. They cover gates, parameters, controls, qubit references, measurements, and recorded results.
  • The QIR and compiler documentation describes the new input support and its limits.

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 the existing OpenQASM frontend alongside the proposed mlir/include/mlir/Target/QIR and mlir/lib/Target/QIR locations. Trace QIRProgram, CompilerInput, the Python compiler interface, and mqt-cc to understand current input paths. Done means supported QIR 2.1 Base Profile assembly and bitcode work through all three interfaces, round-trip tests pass, unsupported constructs diagnose clearly, and the documented limits are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend-api-design, compilers, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.