Speed up template similarity computing using numba#4343
Conversation
for more information, see https://pre-commit.ci
ce491e6 to
99985d4
Compare
|
So everything is supposed to work fine, i think i have some differences mostly due to casting but it's "minimal" in the context of a normalized distance. Just to quickly sum up i moved the computing of the support matrix out of the loop, it will be more 'memory' costly in case of different template matrix but i think since most of the time we have the same ones it's a boost here. Also more leverage of numpy views instead of copies. Im not this familiar with the numba/numpy efficiency stuff but for the union it was faster to do it the "dummy" way (mine lol) that the vectorised one. So if you guys have so rule of thumbs tips for Numba, im in ;) @samuelgarcia
|
for more information, see https://pre-commit.ci
|
Looks great as a user! I get a small ~30% speed up on initial compute, and 10x speed-up on recompute (=> trying out different methods in the gui is super fast, and hard merges are very fast). And on some real data with 800 neurons, the biggest absmax in difference is... Nice!!! |
yger
left a comment
There was a problem hiding this comment.
I would be carefull, because in between, we patched a bug in the similarity due to over optimizations. We can not compute only hald the times, and the upper part of the matrix and use symmetry everywhere, otherwise this is not complete. If we symmetrize in time, we need compute for all indices
|
I would be carefull here, because we recently patched a bug in #4345 and I think this is not propagated here |
|
@yger I think that the symmetry issue is fixed. Can you double check? |
|
Salut Theo. |
…soft_merges_and_refactor
|
This is now OK for me. |
|
salut Samuel, |
|
No because if this is not the same array, we'll explore all shifts, am I right? |
|
to me there two symmetries : a "spatial" one where we can say dist(i, j) = dist(j, i) at lag t and a temporal one where dist(i, j) at lag t = dist(i, j) at lag -t (we do agree that both apply only in case of |
|
You are right. Can we make that together with a small call ? |
for more information, see https://pre-commit.ci
|
@tayheau if you can finish today and propagate changes to compute_(...)_numpy this would be great, since we would like to merge that quickly for release. Otherwise let me know and I can have a go on the branch |
|
As told to @samuelgarcia this is good to me, expect that currently optimizations are only performed at the numba level, not yet in pure numpy (in case numba is not present) |
|
I'm not able to push in your branch, but here is a code to change _compute_similarity_matrix_numpy() |
|
Merci Theo. |
|
pas de soucis ! |


Following #4310, @chrishalcrow showed that given that the diff between two merged templates is considered small, we can approximate the distance of a megred template and a new one a as a linear function. This should allow us to speed up significantly template similarity computations for merged ones.