pynndescent blows up without interpretable error message
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 871
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Description
Hi, first of all, we've been using UMAP 0.3.x in production for a while and it's been working great! However, we've been trying for a while but can't seem to get 0.4.x working reliably with pynndescent. Here is a simple example of it blowing up (umap=0.4.4, pynndescent=0.4.7):
``` python
import numpy as np
import umap
rng = np.random.default_rng()
vecs = rng.choice([-1, 0, 1], p=[0.1, 0.8, 0.1], size=(5000, 100))
print(vecs)
umap.UMAP(verbose=True).fit_transform(vecs)
```
this fails as soon as the dataset is big enough for pynndescent to kick in, and independent of the metric used etc (tried dice, jaccard e.g.). Uninstalling pynndescent does the trick, but it would be nice to get the speed improvements working ;) The output is:
``` bash
[[ 0 0 0 ... 0 0 0]
[ 0 -1 1 ... 0 0 0]
[ 0 0 0 ... 1 1 -1]
...
[ 0 0 0 ... 0 0 0]
[ 0 0 0 ... 0 0 0]
[ 0 1 0 ... 0 -1 -1]]
UMAP(a=None, angular_rp_forest=False, b=None,
force_approximation_algorithm=False, init='spectral', learning_rate=1.0,
local_connectivity=1.0, low_memory=False, metric='euclidean',
metric_kwds=None, min_dist=0.1, n_components=2, n_epochs=None,
n_neighbors=15, negative_sample_rate=5, output_metric='euclidean',
output_metric_kwds=None, random_state=None, repulsion_strength=1.0,
set_op_mix_ratio=1.0, spread=1.0, target_metric='categorical',
target_metric_kwds=None, target_n_neighbors=-1, target_weight=0.5,
transform_queue_size=4.0, transform_seed=42, unique=False, verbose=True)
Construct fuzzy simplicial set
Thu Jun 18 17:29:41 2020 Finding Nearest Neighbors
Thu Jun 18 17:29:41 2020 Building RP forest with 10 trees
Thu Jun 18 17:29:41 2020 NN descent for 13 iterations
---------------------------------------------------------------------------
TypingError Traceback (most recent call last)
in
6 print(vecs)
7
----> 8 umap.UMAP(verbose=True).fit_transform(vecs)
~/anaconda/envs/grapy/lib/python3.7/site-packages/umap/umap_.py in fit_transform(self, X, y)
2010 Embedding of the training data in low-dimensional space.
2011 """
-> 2012 self.fit(X, y)
2013 return self.embedding_
2014
~/anaconda/envs/grapy/lib/python3.7/site-packages/umap/umap_.py in fit(self, X, y)
1799 self.low_memory,
1800 use_pynndescent=True,
-> 1801 verbose=self.verbose,
1802 )
1803
~/anaconda/envs/grapy/lib/python3.7/site-packages/umap/umap_.py in nearest_neighbors(X, n_neighbors, metric, metric_kwds, angular, random_state, low_memory, use_pynndescent, verbose)
298 max_candidates=60,
299 low_memory=low_memory,
--> 300 verbose=verbose,
301 )
302 knn_indices, knn_dists = nnd.neighbor_graph
~/anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py in __init__(self, data, metric, metric_kwds, n_neighbors, n_trees, leaf_size, pruning_degree_multiplier, diversify_epsilon, n_search_trees, tree_init, random_state, algorithm, low_memory, max_candidates, n_iters, delta, n_jobs, compressed, seed_per_row, verbose)
977 leaf_array=leaf_array,
978 verbose=verbose,
--> 979 seed_per_row=seed_per_row,
980 )
981 else:
~/anaconda/envs/grapy/lib/python3.7/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
399 e.patch_message(msg)
400
--> 401 error_rewrite(e, 'typing')
402 except errors.UnsupportedError as e:
403 # Something unsupported is present in the user code, add help info
~/anaconda/envs/grapy/lib/python3.7/site-packages/numba/dispatcher.py in error_rewrite(e, issue_type)
342 raise e
343 else:
--> 344 reraise(type(e), e, None)
345
346 argtypes = []
~/anaconda/envs/grapy/lib/python3.7/site-packages/numba/six.py in reraise(tp, value, tb)
666 value = tp()
667 if value.__traceback__ is not tb:
--> 668 raise value.with_traceback(tb)
669 raise value
670
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
Internal error at .
Failed in nopython mode pipeline (step: nopython mode backend)
scalar type Tuple() given for non scalar argument #5
File "../../anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py", line 232:
def generate_leaf_updates(leaf_block, dist_thresholds, data, dist, dist_args):
for n in numba.prange(leaf_block.shape[0]):
^
[1] During: lowering "id=16[LoopNest(index_variable = parfor_index.3050, range = (0, $38binary_subscr.5, 1))]{186: , 136: , 138: , 88: , 1134: , 174: , 1136: , 208: , 210: , 112: , 212: , 114: , 214: , 216: , 90: , 219: }Var(parfor_index.3050, pynndescent_.py:232)" at /Users/thomas/anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py (232)
[2] During: resolving callee type: type(CPUDispatcher())
[3] During: typing of call at /Users/thomas/anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py (265)
Enable logging at debug level for details.
File "../../anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py", line 265:
def init_rp_tree(data, dist, dist_args, current_graph, leaf_array):
updates = generate_leaf_updates(
leaf_block, dist_thresholds, data, dist, dist_args
^
[1] During: resolving callee type: type(CPUDispatcher())
[2] During: typing of call at /Users/thomas/anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py (464)
[3] During: resolving callee type: type(CPUDispatcher())
[4] During: typing of call at /Users/thomas/anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py (464)
File "../../anaconda/envs/grapy/lib/python3.7/site-packages/pynndescent/pynndescent_.py", line 464:
def nn_descent(
if rp_tree_init:
init_rp_tree(data, dist, dist_args, current_graph, leaf_array)
```
Would you say that pynndescent is still at an experimental stage and not recommend its use in production?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported call path in umap/umap_.py and the referenced pynndescent_.py locations around generate_leaf_updates, init_rp_tree, and nn_descent. Reproduce the failure with the provided UMAP 0.4.4, pynndescent 0.4.7, and NumPy example, then trace the Numba TypingError. Done should include a handled failure with an interpretable message or a verified fix for the reported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100