-
Notifications
You must be signed in to change notification settings - Fork 60
permutation inference performance using numba #116
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
Conversation
|
At this phase, we've got an 8x speedup over the current implementation. From here, we have three tasks. Conceptually, we want the final implementation to look like this: def crand_plus(*data, local_function=moran_i):
cardinalities, weight_pointers, *etc = setup_crand()
with multiprocessing.Pool() as P:
larger, random_locals = P.map(_do_one_observation, stuff_needed_for_that_iteration)
return larger, random_localsdefining the inner loop & lifting it into a numba method.We need to lift up the body of
parallelizing the computationIf (and only if) there's gains to be made by parallelizing the simulations, we want to explore using defining local functionsIdeally, we'd like to implement the permutation logic once and then use it in all permutation-inference driven things. If we do that, we need to define something like a numba-fied local statistic for anything using the permutation inference engine. For example, a Moran version might be: @njit(fastmath=True)
def local_statistic(i, z, permutations, cardinality, weights_i):
mask = numpy.ones_like(z)
n = z.shape[0]
scaling = (n - 1) / (z * z).sum()
mask[i] = False
z_no_i = z[mask].reshape(z.shape)
flat_random_z = z_no_i[permutations[:, :cardinality]]
z_no_i_lag = flat_random_z.reshape(-1,cardinality) @ weights_i
rlisa = z[i] * z_no_i_lag.sum(axis=1) * scaling
return rlisaThis will enable us to pass arbitrary JIT-ted functions to the random permutation engine. |
…on single process. Start of parallel implementation
[WIP] Updating tests
Add seed argument to be passed to crand and insert in tests
Make seed not optional in vec_permutations
Moran perf
|
The only failures now are the known failures for the chi-squared test in join counts (#123). This should be ready to merge 🥳 |
This is a stub to work on performance in the permutational inference engine using numba.