-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving integration of quantum_info
module and qibojit
#1136
Comments
quantum_info
module and numba
quantum_info
module and qibojit
@AlejandroSopena @BrunoLiegiBastonLiegi This is list of the functions that have priority in being optimized in Basis:
Random ensembles:
Superoperator transformations:
|
@renatomello should we create a separate module in
and then the functions inside the |
Which routines would be there? |
All the ones we want to improve with |
Then they'd have to be subroutines of the functions we have, because the functions we want to improve are all user-facing and part of specific submodules |
#1459 is trying to address the first two boxes (basis section) |
@renatomello I've done a quick test of @njit("c16[:](i8)", parallel=True, cache=True)
def numba_random_statevec(dims):
state = np.random.standard_normal(dims)
state = state + 1.0j * np.random.standard_normal(dims)
state = state / np.linalg.norm(state)
return state and explicitely using def cupy_random_statevec(dims):
state = cp.random.standard_normal(dims)
state = state + 1.0j * cp.random.standard_normal(dims)
state = state / cp.linalg.norm(state)
return state I was able to test only up to 25 qubits due to my local memory limitations and I got these results with 10 repetitions each:
The only small issue is that we lose direct access to the seed, which should be then reset globally with |
@BrunoLiegiBastonLiegi these custom functions can only accept one input? |
For |
I guess we could drop EDIT: Maybe this helps https://stackoverflow.com/questions/55806542/how-to-compile-a-numba-jited-function-with-variable-input-type ? |
Yeah i mean you could always have a wrapper: @njit("c16[:](i8)", parallel=True, cache=True)
def _random_statevector(dims):
state = np.random.standard_normal(dims)
state = state + 1.0j * np.random.standard_normal(dims)
state = state / np.linalg.norm(state)
return state
def random_statevector(dims, seed):
np.random.seed(seed)
return _random_staevector(dims) I am more worried on how to integrate this and similar changes to the backend, to be honest... |
If you don't know, then I really do not know. |
I mean most likely we will need to make backend.np.function(cp.array) because the cupy implementation is triggered anyway, but not, as for example in this case, when you do sampling or creation: backend.np.random.random_normal() |
In a sense, you may want to do for the However, since the other plan is not advancing at all right now, if you want to make the Alternative proposal explanation/reminderWhat we were already discussing (even in the scope of
However, multiple backends may share the same outcome features. E.g. NumPy, TensorFlow, and Qibolab may all produce an observable made of shots on the CPU memory. And they can be manipulated in the very same way. Same for the full state vector on GPU, which is independent of the library who generated it (it may be recasted as a buffer, if needed). However, this plan requires some considerable refactoring effort, and it's not going to happen immediately. |
Apart from the separation between the execution and manipulation backends, which is probably the best solution but takes some time, I was thinking about providing the backends with a |
@BrunoLiegiBastonLiegi to me, there is no problem. As argued above, I know is very much against isolation, but given the current situation, I'd be willing to accept even to proliferate directly in the scope of the backend itself, adding methods there. Instead, if you instead believe that you can reuse this inner scopes (the Otherwise, it's just the same :) |
Right now, even though the
quantum_info
module is compatible to all backends, it is not making use of any of thejit
properties fromnumba
. Therefore,numpy
andnumba
performances are the same across the board. It would be good to profile the module and see where it is worth to invest time to code custom operations inqibojit
.Tasks
CliffordOperations
throughnumba
andcupy
qibojit#161qibojit
engines #1150qibo.quantum_info.basis.pauli_basis
andvectorization
function #1459The text was updated successfully, but these errors were encountered: