CirQuS-UTS / QuanGuru

QuanGuru (pronounced Kangaroo) is a Python library for numerical modelling of quantum systems. It is still under-development, and it consists of tools for numerical simulations of Quantum systems.
BSD 3-Clause "New" or "Revised" License
5 stars 7 forks source link

Transformed Protocols #221

Open adriendilonardo opened 1 year ago

adriendilonardo commented 1 year ago

Please describe the expected enhancement

Another integral step in achieving issue #213 is to be able to have protocols objects whose unitary isn't generated by a function such as matrix exponentiation or via a time-dependent hamiltonian, but rather by transforming the unitary generated by another protocol object.

In the following example code, the fallingEdge object is a transformed protocol. Internally, it's unitary will be generated by taking the transpose of the unitary cached in risingEdge (which is likely stored in the risingEdge._paramBoundBase__matrix attribute after it is generated in the risingEdge object).

risingEdge = qg.pulse(system=total_sys, simulation=simulation)
flatTop = qg.protocol(system=total_sys, createUnitary=qg.UJC)
fallingEdge = risingEdge.transformed(func)

pulseTrain = qg.protocol(steps=[risingEdge, flatTop, fallingEdge]) 

Some notes on this:

Transformation function For users to be able to define this transformation function in their own code, the required arguments, output, and how it is properly used to generate a transformed protocol object should be clear. The arguments should be consistent with the types of arguments expected in other user defined functions which are passed to other parts of the library.

Arguments

Returns

These arguments reflect similar arguments used by the compute functions (superSys, state) compared to (qPro, unitary) here.

Proposed instantiation method: It is unclear whether the transformed protocol object can

risingEdge = qg.pulse(system=total_sys, simulation=simulation)
fallingEdge = risingEdge.transform(transpose)

where transform is a built in method of all protocols and it's first argument is the unitary transformation object

Other notes

Parameter Updating For the sake of computational efficiency, we should minimise the number of times that the transformation function (which may be computationally expensive) needs to be computed. E.g. if we call for the unitary matrix of the transformed protocol object and neither it nor the object it has been copied from have been updated since the previous unitary call, then we should not have to apply the transformation function again but rather fetch the unitary from some previous cache.

Here we only consider what happens when the original protocol and its associated simulation/protocols are modified

Backwards Compatibility Should copyStep be changed to suit our needs, or should we create a new class in its image?

Questions

github-actions[bot] commented 1 year ago

Branch 221-Transformed_Protocols created!