Qmod has many powerful high-level programming constructs - quantum arithmetic expressions, quantum conditional statements, and local variables, to name just a few. The Qmod compiler synthesizes these down to efficient low-level implementations, adapting and optimizing them for each target. The output of the Qmod compiler, representing the gate-level quantum program, used to be based on formats such as QASM2 or a restrictive subset of OpenQASM 3.0 supported by common toolchains.
In a recent release, we rolled out the new Qmod compiler architecture that has been in the oven for a long while. The main purpose of this deep redesign is to improve compiler performance and scalability. This was enabled by a new modular compiler architecture, in which successive lowering passes transform the program into increasingly restricted forms of Qmod.
There was a catch, though: external output formats had become a limiting factor. For example, there was no robust support for classical function parameters, rolled-up loops, or symbolic array subscripts - all of which are native in Qmod. This forced the compiler to unroll and “flatten” the description. But Qmod itself is not just a high-level language - it can also express low-level implementation details. So we pivoted to a Qmod-based description as our compiler output: quantum operations are still lowered to gates, but the expressive power of Qmod lets us preserve quantum variables, function hierarchy, and classical control flow.
The impact was substantial: more than 10× faster compilation across an extensive benchmark suite, much of which was based on our library of examples and applications. More importantly, compilation time and output size for iterative algorithms - which, in practice, most are - do not grow with the iteration count. The Qmod-based compiler output also opened the door to more faithful translations to languages with different capabilities. One striking example is CUDA-Q: instead of flattening the program into a massive circuit before translation, we can now generate a compact, parameterized CUDA-Q kernel that preserves loops and program structure, making it much better suited for high-performance hybrid execution.
Qmod has many powerful high-level programming constructs - quantum arithmetic expressions, quantum conditional statements, and local variables, to name just a few. The Qmod compiler synthesizes these down to efficient low-level implementations, adapting and optimizing them for each target. The output of the Qmod compiler, representing the gate-level quantum program, used to be based on formats such as QASM2 or a restrictive subset of OpenQASM 3.0 supported by common toolchains.
In a recent release, we rolled out the new Qmod compiler architecture that has been in the oven for a long while. The main purpose of this deep redesign is to improve compiler performance and scalability. This was enabled by a new modular compiler architecture, in which successive lowering passes transform the program into increasingly restricted forms of Qmod.
There was a catch, though: external output formats had become a limiting factor. For example, there was no robust support for classical function parameters, rolled-up loops, or symbolic array subscripts - all of which are native in Qmod. This forced the compiler to unroll and “flatten” the description. But Qmod itself is not just a high-level language - it can also express low-level implementation details. So we pivoted to a Qmod-based description as our compiler output: quantum operations are still lowered to gates, but the expressive power of Qmod lets us preserve quantum variables, function hierarchy, and classical control flow.
The impact was substantial: more than 10× faster compilation across an extensive benchmark suite, much of which was based on our library of examples and applications. More importantly, compilation time and output size for iterative algorithms - which, in practice, most are - do not grow with the iteration count. The Qmod-based compiler output also opened the door to more faithful translations to languages with different capabilities. One striking example is CUDA-Q: instead of flattening the program into a massive circuit before translation, we can now generate a compact, parameterized CUDA-Q kernel that preserves loops and program structure, making it much better suited for high-performance hybrid execution.
