Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
This tutorial describes how to use the Classiq platform to create MCX gates, including one with 14 controls. Then, it demonstrates a much more complex example with 50 control qubits.
Quantum computers offer tantalizing promises to those who can harness their power.And although today’s computers are not quite able to solve real-world problems, those who are able to optimize for the available hardware can reap rewards sooner than those who wait.The MCX gate is an important quantum gate used in a variety of circuits, such as the Grover operator, logical AND operator, state preparation algorithms, and arithmetic comparators.The ability to adapt implementations of MCX gates to meet the hardware constraints—limited qubit count, fidelities, gate count, and so on—is not trivial.
To create an MCX gate with 14 control qubits using Classiq, we first define a quantum function called my_mcx whose arguments are an array of qubits (of any size) for control and a single qubit argument for the target:
To create an MCX gate with 14 control qubits, we create a quantum main function that executes our my_mcx function with 14 qubits allocated to the control argument:
To constrain a circuit to only 20 qubits and optimize for circuit depth, we pass the maximum width and optimization parameter to a Constraints object and synthesize our model, create a quantum program, and view it:
Classiq automatically optimizes the quantum circuit and each MCX gate to a plethora of possible situations. To characterize each setting we pass our constraints and preferences to the synthesis request using the Constraints and Preferences objects.
The power of the Classiq synthesis engine is far greater than creating optimized, 14-control MCX gates in an instant.For example, the following code creates an MCX gate with 50 control qubits: