New release qSOA® PySDK v1.6
What's new?
This new version of the qSOA Python SDK brings new features in the creation of quantum gate circuits. Previously, there was a structure of tuples that described the behavior of quantum gates. This has been replaced by an extensive Python object system. This new system allows for much more intuitive use when creating quantum gate circuits, which is why certain functions have been redesigned.
Don't worry, all the code you've already developed with previous versions continues to work without touching anything! However, methods and behaviors marked as deprecated will be removed in the next version of the SDK, 2.0. Therefore, we recommend that code migration be performed.
The changes in the methods are:
- The addCreatedGate method is deprecated.
- The mcg method is deprecated.
-
The new control method evolves.
Previously, the behavior of the control method added a control to the gates that were indicated one at a time. To do this, you had to include them from the CircuitGates object and indicate the add argument to false so that they were not added to the circuit. After this, add it to the circuit with the addCreatedGate method.
Now all that is not necessary. Thanks to the new object model, the new way to create multi-controlled gates and add them to the circuit goes only through the control method. Using it from the CircuitGates object and only indicating the position or list of positions to control, and the circuit object as target, a new multi-controlled gate object will be created and added to the circuit. Thus also assuming the mcg method.
-
The add argument is deprecated.
Due to the new described way of constructing multi-controlled gates, the add argument that was used in quantum gates is no longer used and is replaced by the object model.
Below you can see an example of these changes, where in all cases a not gate with three controls will be created and added.
In previous versions it could be done with the mcg method:
circuit = qsoa.CircuitGates() # create circuit
circuit.mcg([0, 1], circuit.x(2, False)) # add multi controlled gate
Or also with the control and addCreatedGate method:
circuit = qsoa.CircuitGates() # create circuit
cccx = circuit.control( # create a CCCX gate
0, circuit.control(
1, circuit.control(
2, circuit.x(3, False)
)
)
)
circuit.addCreatedGate(cccx) # add created CCCX gate
Now all this is assumed and simplified thanks to the new control method:
from QuantumPathQSOAPySDK.circuit.gates.basicGates import XGate # import XGate object
circuit = qsoa.CircuitGates() # create circuit
circuit.control([0, 1, 2], XGate(3)) # add a custom controlled CCCX gate