lmcinnes / lmcinnes/umap

Trouble loading UMAP model done with version 0.4.2 - Error coming from pynndescent

Open
#423 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.3k
Forks
871
Avg merge
1d 13h
Merged PRs (30d)
5

Description

Some tips given already in #178, although it does not solve the problem here.

I'm having troubles when loading a previously saved UMAP model.
I used umap version 0.4.2
The model I construct calls umap as:
mapper = umap.UMAP(n_neighbors=150, n_components=2, metric='cosine', random_state=69, transform_queue_size=8.0, min_dist=0.0, target_weight=1, target_n_neighbors=20, verbose=True).fit(nzDense_norm,y=labels_train)

nzDense_norm is 290000x4096 numpy float32 matrix
labels_train is 290000 numpy int8 vector

The model is computed correctly and I save it using joblib:
outputFile = open(filename, 'wb')
joblib.dump(mapper, outputFile, compress=True)
outputFile.close()

Then, when I tried to load it using:
mapper = joblib.load(filename)

I get the error below, (which has been reported in #179 but once the model has been loaded)
Any clues or help?
In fact I performed this operation a lot of times with umap-learn 0.3.10 without any trouble. Afterwards, to get 0.4.2 running I needed to install pynndescent (which I did no thave when using 0.3.10) because I was experiencing RAM problems. But now the models are correctly done, but there is this problem of loading it once saved into disk.

Traceback (most recent call last):
File "", line 1, in
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/joblib/numpy_pickle.py", line 605, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/joblib/numpy_pickle.py", line 529, in unpickle
obj = unpickler.load()
File "/usr/lib/python3.6/pickle.py", line 1050, in load
dispatchkey[0]
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/joblib/numpy_pickle.py", line 342, in load_build
Unpickler.load_build(self)
File "/usr/lib/python3.6/pickle.py", line 1507, in load_build
setstate(state)
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/pynndescent/pynndescent.py", line 1026, in setstate
self._rp_forest = tuple([renumbaify_tree(tree) for tree in d["rp_forest"]])
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/pynndescent/pynndescent.py", line 1026, in
self._rp_forest = tuple([renumbaify_tree(tree) for tree in d["_rp_forest"]])
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/pynndescent/rp_trees.py", line 1178, in renumbaify_tree
hyperplanes.extend(tree.hyperplanes)
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/typed/typedlist.py", line 302, in extend
return _extend(self, iterable)
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/dispatcher.py", line 401, in _compile_for_args
error_rewrite(e, 'typing')
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/dispatcher.py", line 344, in error_rewrite
reraise(type(e), e, None)
File "/home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/six.py", line 668, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (ListType[array(float64, 2d, C)], reflected list(array(float32, 1d, C)))

parameterized
In definition 0:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (ListType[array(float64, 2d, C)], array(float32, 1d, C))
parameterized
In definition 0:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 487:
def impl(l, item):
casteditem = _cast(item, itemty)
^

[1] During: lowering "$0.4 = call $0.1(item, $0.3, func=$0.1, args=[Var(item, listobject.py:487), Var($0.3, listobject.py:487)], kws=(), vararg=None)" at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (487)
raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/six.py:669
In definition 1:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 487:
def impl(l, item):
casteditem = _cast(item, itemty)
^

[1] During: lowering "$0.4 = call $0.1(item, $0.3, func=$0.1, args=[Var(item, listobject.py:487), Var($0.3, listobject.py:487)], kws=(), vararg=None)" at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (487)
raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/six.py:669
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: BoundFunction((, 'append') for ListType[array(float64, 2d, C)])
[2] During: typing of call at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (895)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 895:
def impl(l, iterable):

for i in iterable:
l.append(i)
^

raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/typeinfer.py:985

In definition 1:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (ListType[array(float64, 2d, C)], array(float32, 1d, C))

parameterized
In definition 0:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 487:
def impl(l, item):
casteditem = _cast(item, itemty)
^

[1] During: lowering "$0.4 = call $0.1(item, $0.3, func=$0.1, args=[Var(item, listobject.py:487), Var($0.3, listobject.py:487)], kws=(), vararg=None)" at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (487)
raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/six.py:669
In definition 1:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 487:
def impl(l, item):
casteditem = _cast(item, itemty)
^

[1] During: lowering "$0.4 = call $0.1(item, $0.3, func=$0.1, args=[Var(item, listobject.py:487), Var($0.3, listobject.py:487)], kws=(), vararg=None)" at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (487)
raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/six.py:669
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: BoundFunction((, 'append') for ListType[array(float64, 2d, C)])
[2] During: typing of call at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/listobject.py (895)

File "../../Trainer/lib/python3.6/site-packages/numba/listobject.py", line 895:
def impl(l, iterable):

for i in iterable:
l.append(i)
^

raised from /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/typeinfer.py:985

This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: BoundFunction((, 'extend') for ListType[array(float64, 2d, C)])
[2] During: typing of call at /home/peppone/Feina/INLOC/Projectes/WorkDir/Trainer/lib/python3.6/site-packages/numba/typed/typedlist.py (82)

File "../../Trainer/lib/python3.6/site-packages/numba/typed/typedlist.py", line 82:
def _extend(l, iterable):
return l.extend(iterable)
^

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the joblib.load failure with the saved UMAP model, then read pynndescent/pynndescent.py around setstate and pynndescent/rp_trees.py around renumbaify_tree. Check how the saved float32 and float64 values are handled; done means the model loads successfully without the reported Numba typing error.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.