# Circuit of the month Nov 21: Fun with State Preparations

State preparations are often an important first step in many quantum algorithms. This month, we explore a circuit designed to load probability mass functions into five groups of three qubits each.

The unique angle here is how the Classiq platform generates the circuit when given a different number of qubits to work with.

In the first instance, we ask the synthesis platform to achieve this goal with 20 qubits. After automatically exploring many options, the engine decides that a good solution would be to split the 20 qubits into five groups of four qubits each. In each group, three qubits are initialized and the fourth qubit is used as an ancilla/auxiliary qubit.

Things get more interesting when the Classiq engine is asked to find a solution with 16 qubits. In this case, five groups of four qubits each is not possible. What the engine generates is a solution using the following steps:

- First, four groups of three qubits are initialized (each using an ancilla qubit)
- Then, the four ancialla qubits (one from each group) are cleaned up
- Now, to take care of the last group of three qubits, not yet initialized, three of these four qubits (previously used as ancilla qubits for the previous groups) are initialized using the fourth qubit as ancilla

Here is the Classiq code for the 20-qubit case. This is the textual model, which one could run in the VSCode environment:

and here is the resulting circuit. You can see that all the five groups (three qubits each) are initialized in parallel

To explore the 16-qubit solution, a single line needs to change:

And here is the resulting circuit. You can see that qubits 3, 7, 11 and 15 are used after finishing the state preparation of qubits 0-2, 4-6, 8-10 and 12-14:

The Classiq platform not only allows designers to explore various options, but finds innovative solutions automatically.

State preparations are often an important first step in many quantum algorithms. This month, we explore a circuit designed to load probability mass functions into five groups of three qubits each.

The unique angle here is how the Classiq platform generates the circuit when given a different number of qubits to work with.

In the first instance, we ask the synthesis platform to achieve this goal with 20 qubits. After automatically exploring many options, the engine decides that a good solution would be to split the 20 qubits into five groups of four qubits each. In each group, three qubits are initialized and the fourth qubit is used as an ancilla/auxiliary qubit.

Things get more interesting when the Classiq engine is asked to find a solution with 16 qubits. In this case, five groups of four qubits each is not possible. What the engine generates is a solution using the following steps:

- First, four groups of three qubits are initialized (each using an ancilla qubit)
- Then, the four ancialla qubits (one from each group) are cleaned up
- Now, to take care of the last group of three qubits, not yet initialized, three of these four qubits (previously used as ancilla qubits for the previous groups) are initialized using the fourth qubit as ancilla

Here is the Classiq code for the 20-qubit case. This is the textual model, which one could run in the VSCode environment:

and here is the resulting circuit. You can see that all the five groups (three qubits each) are initialized in parallel

To explore the 16-qubit solution, a single line needs to change:

And here is the resulting circuit. You can see that qubits 3, 7, 11 and 15 are used after finishing the state preparation of qubits 0-2, 4-6, 8-10 and 12-14:

The Classiq platform not only allows designers to explore various options, but finds innovative solutions automatically.