M2QCode: A Model-Driven Framework for Generating Multi-Platform Quantum Programs

Xiaoyu Guo, Shinobu Saito, Jianjun ZhaoarXiv 2025 · OpenReview

Abstract

With the growing interest in quantum computing, the emergence of quantum supremacy has marked a pivotal milestone in the field. As a result, numerous quantum programming languages (QPLs) have been introduced to support the development of quantum algorithms. However, the application of Model-Driven Development (MDD) in quantum system engineering remains largely underexplored. This paper presents an MDD-based approach to support the structured design and implementation of quantum systems. Our framework enables the automatic generation of quantum code for multiple QPLs, thereby enhancing development efficiency and consistency across heterogeneous quantum platforms. The effectiveness and practicality of our approach have been demonstrated through multiple case studies.

Introduction

As quantum computing transitions from theoretical research to industrial application, developers are increasingly hindered by a fragmented ecosystem of Quantum Programming Languages (QPLs). Major providers have developed proprietary standards—such as IBM’s Qiskit, Google’s Cirq, Microsoft’s Q#, and Amazon’s Braket—each featuring unique syntax, gate representations, and abstraction levels. For instance, a simple controlled-NOT operation might be represented as CX in one language and CNOT in another.

This lack of standardization makes porting algorithms across platforms labor-intensive and error-prone. Furthermore, real-world quantum applications are typically hybrid systems where classical logic (such as loops and conditionals) orchestrates quantum circuits. Existing development tools often struggle to manage this hybrid complexity. To address these challenges, we introduce M2QCode, a framework that applies Model-Driven Development (MDD) principles to the quantum domain, bridging the gap between high-level architectural design and platform-specific execution.

The M2QCode Framework

M2QCode facilitates a structured workflow that transforms a Platform-Independent Model (PIM) into executable code through an Intermediate Representation (IR). The framework architecture is designed to decouple the system design from the target hardware specifications.

The M2QCode framework architecture, illustrating the transformation from QuanUML specifications to multi-platform quantum and classical code.

Modeling with QuanUML

Developers begin by defining the system using QuanUML, an extension of the Unified Modeling Language tailored for quantum systems. This involves two primary diagram types:

  1. Class Diagrams: These define the structural architecture of the hybrid system, specifying how classical modules interact with quantum components.
  2. Sequence Diagrams: These model the behavioral logic of quantum circuits. Lifelines represent individual qubits, while messages between lifelines represent gate operations and measurements.
A QuanUML sequence diagram modeling a quantum circuit with Hadamard and CNOT gates followed by measurement operations.

Automated Code Generation

Once the model is defined, a custom JavaScript-based parser extracts the structural and behavioral data into a structured IR. This IR is then processed by two specialized generators:

  • Multiple Quantum Code Generation (MQCG): This component applies language-specific transformation rules to generate quantum code for Qiskit, Cirq, Q#, or Braket.
  • Hybrid Quantum System Generation (HQSG): This component generates the necessary Python boilerplate and classical structures required to integrate the quantum circuits into a larger software system.

Evaluation and Key Insights

We evaluated M2QCode using seven industry case studies (C1–C7) curated by Qiskit, covering diverse domains such as linear systems (HHL), optimization (QAOA), and chemistry (VQE). The framework achieved 100% precision and recall in identifying and generating quantum elements across all platforms.

Functional Equivalence via KL Divergence

A critical challenge in automated code generation is ensuring that the output is functionally correct, even if the text differs from a reference implementation. We found that traditional metrics like CodeBLEU are often insufficient because they penalize differences in variable naming that do not affect execution. Instead, we utilized Kullback–Leibler (KL) divergence to compare the probability distributions of measurement outcomes from the generated code against reference programs. In our tests, the KL divergence remained consistently low (< 0.1), confirming that M2QCode preserves the underlying quantum physics across different target languages.

Conclusion and Future Work

M2QCode demonstrates that MDD can significantly reduce the manual effort required for cross-platform quantum development while ensuring functional consistency. By providing a clear separation of concerns between classical and quantum logic, the framework makes complex hybrid systems easier to design and maintain.

Future iterations of M2QCode will focus on increasing the level of abstraction. Currently, the framework operates at the gate level, which can be cumbersome for very large circuits. We plan to introduce modular modeling, allowing developers to define and reuse high-level blocks or oracles. Additionally, we aim to extend support to Quantum Machine Learning (QML) frameworks like PennyLane and TensorFlow Quantum to support a broader range of research applications.

Summary updated

BibTeX
@misc{guo2025m,
  author = {Xiaoyu Guo and Shinobu Saito and Jianjun Zhao},
  title = {{M2QCode: A Model-Driven Framework for Generating Multi-Platform Quantum Programs}},
  year = {2025},
  eprint = {2510.17110},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.17110},
}
Figure