The QPath Blog

Q xCompositor, practical examples of quantum gate circuit development

The article “QuantumPath®’s Q Assets Compositor® family is growing: tools for enterprise quantum software development” presents the launch of Q xCompositor, a complementary tool to QuantumPath® that allows the development of circuits from a familiar interface such as Microsoft Excel [1], taking advantage of the features of this software. Thanks to its addin and full integration with QPath®, it becomes a tool to be considered for creating scalable quantum gate circuits.

This article will show how it works through two use cases. The first one where a QRNG (Quantum Random Number Generator) of a larger scale than the one shown in the article “Practical Quantum Computing with QuantumPath®: 3-qubit random number generator” will be created from scratch, taking advantage of the properties of Q xCompositor. And the second part is where we already have an algorithm implemented with Q Assets Compositor® of QuantumPath® and we choose to edit it in Q xCompositor.

 

Use case 1: creation of a QRNG with Q xCompositor

In the article mentioned above, an example of a 3-qubit QRNG was proposed. This is a very simple example, but it can be used to show the speed of circuit construction that can be achieved with Q xCompositor.

Such a circuit requires as many qubits as bits you want the number expressed in base-2 to have. On the other hand, each of them will have a Hadamard gate to achieve the superposition and a measurement gate to know the final result of our random number.

Extrapolating this to a spreadsheet and having a vision of how to work with Q xCompositor, each row would be a qubit, the first column would be used for the Hadamard gates, and a second one for the measurements. Resulting in a set of n rows x 2 columns.

To begin with the development of the circuit, you must have a solution created in QuantumPath®, from which you can select the option to create the circuit directly from Excel using Q xCompositor. After clicking on the Create Circuit button in Excel, the document on which we will create our circuit is downloaded.

Fig. 1 Create Circuit button in Excel

 

Once inside we will go to the “xCompositor Settings” tab, where we will select the properties of our circuit. In this case, we will make a QRNG of 100 qubits, so we will indicate it in the box provided and click on “Restore Qubits” to apply the changes.

Fig. 2 Initialization of 100 qubits with Q xCompositor

 

As you can see, 100 qubits have been automatically initialized visually with just one click. After this, it remains to add to our circuit an entire first column of Hadamard gates, and a second one of measurement. This would be done by selecting the first column of our panel (column B) and going to the “Quantum Gates” tab to click on the Hadamard gate. Finally, the same process is done with the second column (C) and the measurement gate.

Fig. 3 100-qubit QRNG circuit

 

To visualize the circuit in a more reduced form and contain more information on the screen, from the “xCompositor Settings” tab we will select the “Gate Colors” option to display each gate with a color. Then we zoom out Excel and we can see immediately that the first two columns have been filled with the expected gates.

Fig. 4 General view of the circuit

 

Finally, to export the circuit to QuantumPath®, go to the tab with the same name and select the “Circuit to QuantumPath” option. A window will open requesting the login, and the necessary data for the creation of the circuit.

Fig05

Fig. 5 Circuit data

 

Finally, if we go to the QuantumPath® circuit manager, we can see how our circuit just created with Q xCompositor has been successfully imported, being able to open it with Q Assets Compositor® and treat it as another circuit within the QPath® ecosystem.

Fig. 6 Circuit from the Q Assets Compositor®

 

 

Use case 2: editing an existing circuit with Q xCompositor

Another capability of Q xCompositor is the ability to edit circuits already created in QuantumPath® by taking advantage of the potential of a spreadsheet. To open any circuit in this addin, enter the circuit editing window and click on “Edit Circuit on Excel”. The document where the circuit is already developed will be downloaded as in the previous use case.

We will assume for this example, that we have a circuit like the Quantum Teleportation circuit already generated as active in QuantumPath®.

Fig. 7 Edit existing circuit in Excel

 

Once inside, you can take advantage of Q xCompositor‘s features, such as the color display of the circuit, which allows a quick visual check that the algorithm is correctly developed.

Fig. 8 Teleport Algorithm with colors in Q xCompositor

 

In case you want to extend parts of the circuit, it is as simple as selecting the cells that will be taken as a base and dragging them to be replicated in the rest of the blank boxes where the selection is applied.

Fig. 9 Circuit extension, use Excel to clone/copy cell ranges

 

This Excel document can be saved locally on the computer so that you can work completely disconnected from the platform. This allows you to make modifications to the circuit whenever you want and export it to QuantumPath® when necessary. In this way, to make changes in the circuit it is not necessary to use the web interface, achieving greater versatility in the creation and edition of algorithms.

Another point to take into account is that, since it is a local file and the persistence of the circuit is done at the time of exporting it, it is not necessary to have an internet connection to edit the circuit. It can be modified completely offline using Q xCompositor tools and then, when an internet connection is available, it can be exported to QuantumPath® to achieve its persistence and be executed. Of course, you can also save the file without having completed the circuit 100% to continue its creation later.

In addition, Q xCompositor also provides the ability to import or export the circuit definition in visual language. In such a way that it is very versatile when generating texts or aids or incorporating them from any source other than the platform itself. It can even be exchanged with other people using any telematic means.

Fig. 10 Functions to import and export a circuit in intermediate language

 

If the reader wants to try Grover’s 3-qubit circuit, we leave it as text in visual language so that it is easy to copy and paste into any of the input controls of QuantumPath® or Q xCompositor itself.

circuit={“cols”:[[“H”,”H”,”H”,”H”,”H”,”H”,”H”,”H”],[“1″,”SPACER”],[“1”,{“id”:”BEGIN_R”,”arg”:”12″}],[“1″,”X”,”1″,”X”,”1″,”X”,”X”,”X”],[“CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”Z”],[“1″,”X”,”1″,”X”,”1″,”X”,”X”,”X”],[“1″,”SPACER”],[“H”,”H”,”H”,”H”,”H”,”H”,”H”,”H”],[“X”,”X”,”X”,”X”,”X”,”X”,”X”,”X”],[“CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”CTRL”,”Z”],[“X”,”X”,”X”,”X”,”X”,”X”,”X”,”X”],[“H”,”H”,”H”,”H”,”H”,”H”,”H”,”H”],[“1″,”END_R”],[“Measure”,”Measure”,”Measure”,”Measure”,”Measure”,”Measure”,”Measure”,”Measure”]],”init”:[“0″,”0″,”0″,”0″,”0″,”0″,”0″,”0”]}

Either from the Quantum Circuit Catalog or from Q xCompositor, it will be enough to paste the circuit in VL to start editing it in any of the circuit editing use cases. In any case, the reader will be able to incorporate this definition into the system through the different use cases provided by the product.

Fig. 11 Import Circuit in VL to start its design in Q xCompositor

 

As shown throughout the article, Q xCompositor not only facilitates the creation and edition of gate circuits but also simplifies the management of large quantities of qubits in a controlled way, something that has a positive impact on the productivity of the work in the design and development of circuits with a high number of gates. Moreover, for this reason, it is a very useful tool when in evolutionary and adaptive maintenance we need to increase the number of qubits of circuits already created to exploit their capabilities to the maximum in more powerful quantum computers. For all these reasons, plus other capabilities that we will show in other deliveries, Q xCompositor adds its value to the tools available in the QuantumPath® environment to successfully facilitate and accelerate the adoption of quantum computing as a new technological paradigm.

 

[1] Microsoft Office and Microsoft Excel are the property of Microsoft Corporation, to which Microsoft owns all copyrights.