Blog

# Introducing Qmod: Streamlining Quantum Algorithm Design

13
August
,
2024
Matan Vax

Qmod is a new language for quantum algorithm design. It aims to capture the pure functional intent of algorithms and abstract from all implementation details. Qmod draws on recent work in the field of quantum programming languages, with domain-specific concepts such as general controlled operations, auto-uncompute logic, and no-cloning semantics. In addition, Qmod includes concepts that are inspired by high-level classical programming languages. It supports a full-blown type system for quantum variables, with numeric types, arrays, and struct types, similar to what you find in classical languages such as C. Quantum variables can be composed into arithmetic and logical expressions, and these expressions are used in assignments and quantum control-flow statements.

Applying high-level types and expressions in the description of both basic and sophisticated algorithms makes for a natural and concise code. A large repository of such examples can be found in the Classiq Library. The following simple example illustrates the power of these constructs. In it, the Grover Search algorithm is used to find assignments to a set of variables that satisfy a certain constraint. In Qmod, you can group a set of numeric variables in a quantum struct thus:

These variables represent numbers in different domains. ‘a’ is a two-bit unsigned integer, that is, a number in the domain [0..3]. ‘b’ is a two-bit fixed-point number in the domain [0, 0.25, 0.5, 0.75]. ‘c’ is a signed number in the domain [-1..0.75]. You can specify any expression over the scalar variables of a struct using native quantum arithmetic operators. The quantum function below evaluates the property that their sum is equal to some constant value:

The Classiq Library includes many quantum functions that serve as building blocks in describing algorithms, such as ‘hadamard_transform’ and ‘grover_operator’. Using these, the full listing of the Grover Search algorithm is a few lines of code:

Synthesizing this simple example in the Classiq platform yields a rather complex quantum circuit, but one that is highly optimized per the specified configuration or hardware constraints dictated by the user. Executing the circuit on a quantum simulator returns an assignment to variables ‘a’, ‘b’, and ‘c’ of ‘MyProblem’ that satisfy the constraint with very high probability.

The high-level capture of the user’s intent not only offloads the burden of working out the complex implementation from the user. It also enables much more powerful and flexible optimization techniques as part of the synthesis process, making decisions in a huge space of possible qubit allocations and gate layouts. This would not have been possible for a more concrete or low-level description.

Qmod is a new language for quantum algorithm design. It aims to capture the pure functional intent of algorithms and abstract from all implementation details. Qmod draws on recent work in the field of quantum programming languages, with domain-specific concepts such as general controlled operations, auto-uncompute logic, and no-cloning semantics. In addition, Qmod includes concepts that are inspired by high-level classical programming languages. It supports a full-blown type system for quantum variables, with numeric types, arrays, and struct types, similar to what you find in classical languages such as C. Quantum variables can be composed into arithmetic and logical expressions, and these expressions are used in assignments and quantum control-flow statements.

Applying high-level types and expressions in the description of both basic and sophisticated algorithms makes for a natural and concise code. A large repository of such examples can be found in the Classiq Library. The following simple example illustrates the power of these constructs. In it, the Grover Search algorithm is used to find assignments to a set of variables that satisfy a certain constraint. In Qmod, you can group a set of numeric variables in a quantum struct thus:

These variables represent numbers in different domains. ‘a’ is a two-bit unsigned integer, that is, a number in the domain [0..3]. ‘b’ is a two-bit fixed-point number in the domain [0, 0.25, 0.5, 0.75]. ‘c’ is a signed number in the domain [-1..0.75]. You can specify any expression over the scalar variables of a struct using native quantum arithmetic operators. The quantum function below evaluates the property that their sum is equal to some constant value:

The Classiq Library includes many quantum functions that serve as building blocks in describing algorithms, such as ‘hadamard_transform’ and ‘grover_operator’. Using these, the full listing of the Grover Search algorithm is a few lines of code:

Synthesizing this simple example in the Classiq platform yields a rather complex quantum circuit, but one that is highly optimized per the specified configuration or hardware constraints dictated by the user. Executing the circuit on a quantum simulator returns an assignment to variables ‘a’, ‘b’, and ‘c’ of ‘MyProblem’ that satisfy the constraint with very high probability.

The high-level capture of the user’s intent not only offloads the burden of working out the complex implementation from the user. It also enables much more powerful and flexible optimization techniques as part of the synthesis process, making decisions in a huge space of possible qubit allocations and gate layouts. This would not have been possible for a more concrete or low-level description.

## About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.