question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

n_jobs>1 returns an error for sparse input

See original GitHub issue

I have a sparse matrix X, on which I can successfully run UMAP:

<100000x9630 sparse matrix of type '<class 'numpy.float64'>'
	with 266398 stored elements in List of Lists format>

In particular, nn = NNDescent(X, metric='cosine') works fine (it does raise a warning “Failed to correctly find n_neighbors for some samples”, but I’m ignoring it). However,

nn = NNDescent(X, metric='cosine', n_jobs=-1)

or any other non-default value of n_jobs returns an error here:

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'tau_rand_int': cannot determine Numba type of <class 'numba.ir.UndefinedType'>

File "../../../anaconda3/lib/python3.7/site-packages/pynndescent/sparse_threaded.py", line 42:
def sparse_current_graph_map_jit(
    <source elided>
            for j in range(n_neighbors - np.sum(heap[0, i] >= 0.0)):
                idx = np.abs(tau_rand_int(rng_state_local)) % data.shape[0]

Versions:

UMAP 0.3.10
pynndescent 0.4.5
numba 0.46.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lmcinnescommented, May 9, 2020

I believe the error is different since it was a new bug, introduced when I did some data structure refactoring and apparently missed a few spots.

In good news a lot of this should be made a lot more sane in version 0.5 where everything moves to numba parallelism controlled with numba’s new threading control features. This will mean that there will be only a single approach that covers both the serial and threaded cases rather than the current split of approaches that exists now. That should also fix some of the memory use issues with threaded use that you encountered earlier.

0reactions
dkobakcommented, Oct 20, 2020

Hi Leland, I just noticed that this seems to be resolved in 0.5 (at least everything works fine for me), and moreover the default behaviour (n_jobs=None) seems to be using n_jobs=-1 (btw, this was not entirely clear to me from the docstring). So I am closing this issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sparse matrix slicing memory error - Stack Overflow
Problem: When i have csr matrix only, my server's RAM is busy with 40 GB. When i run the csr_2 = csr[1::2,:] ,...
Read more >
Sparse matrices (scipy.sparse) — SciPy v1.9.3 Manual
Return the lower triangular portion of a matrix in sparse format ... of sparse matrices, therefore using it will result on unexpected results...
Read more >
Sparse Matrix Error - MATLAB Answers - MathWorks
I've been trying to create a matrix using the sparse matrix command: M=sparse(IndR,IndC,KP,S,S,4); ... Error using ==> sparse Index exceeds matrix dimensions.
Read more >
Sparse Matrices — GSL 2.7 documentation - GNU.org
In order to faciliate efficient sparse matrix assembly, GSL stores the ... handler with an error code of GSL_ENOMEM in addition to returning...
Read more >
Working with sparse tensors | TensorFlow Core
Input or tf.keras.layers.InputLayer . You can pass sparse tensors between Keras layers, and also have Keras models return them as outputs. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found