I'm running into an issue with the numba compiler and sc.pp.neighbors- LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)

Hi, whenever I try to run sc.pp.neighbors I’m getting the following error. I’ve been run this without problem for quite some time now and am not sure what caused this to happen.


AssertionError Traceback (most recent call last)
/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)
743 try:
→ 744 yield
745 except NumbaError as e:

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
229 loc=self.loc, errcls_=defaulterrcls):
→ 230 self.lower_inst(inst)
231 self.post_block(block)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower_inst(self, inst)
327 val = self.lower_assign(ty, inst)
→ 328 self.storevar(val, inst.target.name)
329

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in storevar(self, value, name)
1277 name=name)
→ 1278 raise AssertionError(msg)
1279

AssertionError: Storing i64 to ptr of i32 (‘dim’). FE type int32

During handling of the above exception, another exception occurred:

LoweringError Traceback (most recent call last)
in
5
6 mp.pipeline.process(expt_path, data = adata, save = False)
----> 7 mp.pipeline.cluster(expt_path, data = adata)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/magpy/pipeline.py in cluster(expt_path, data, save, fig_pfx, read_file, write_file, show, neighbors_key)
392 #Compute nearest-neighbors graph
393 if neighbors_key is None: neighbors_key = ‘X_pca’
→ 394 sc.pp.neighbors(adata, n_neighbors=settings.num_neighbors, n_pcs=settings.num_pcs, use_rep = neighbors_key)
395
396 #Calculate cell clusters via leiden algorithm

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/scanpy/neighbors/init.py in neighbors(adata, n_neighbors, n_pcs, use_rep, knn, random_state, method, metric, metric_kwds, key_added, copy)
118 adata._init_as_actual(adata.copy())
119 neighbors = Neighbors(adata)
→ 120 neighbors.compute_neighbors(
121 n_neighbors=n_neighbors, knn=knn, n_pcs=n_pcs, use_rep=use_rep,
122 method=method, metric=metric, metric_kwds=metric_kwds,

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/scanpy/neighbors/init.py in compute_neighbors(self, n_neighbors, knn, n_pcs, use_rep, method, random_state, write_knn_indices, metric, metric_kwds)
748 # we need self._distances also for method == ‘gauss’ if we didn’t
749 # use dense distances
→ 750 self._distances, self._connectivities = _compute_connectivities_umap(
751 knn_indices,
752 knn_distances,

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/scanpy/neighbors/init.py in compute_connectivities_umap(knn_indices, knn_dists, n_obs, n_neighbors, set_op_mix_ratio, local_connectivity)
353 # umap 0.5.0
354 warnings.filterwarnings(“ignore”, message=r"Tensorflow not installed")
→ 355 from umap.umap
import fuzzy_simplicial_set
356
357 X = coo_matrix(([], ([], [])), shape=(n_obs, 1))

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/umap/init.py in
----> 1 from .umap_ import UMAP
2
3 # Workaround: numba 0.40.0 installed via pip from PyPI: _dl_check_map_versions: Assertion `needed != NULL' failed! · Issue #3341 · numba/numba · GitHub
4 import numba
5

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/umap/umap_.py in
52 from umap.spectral import spectral_layout
53 from umap.utils import deheap_sort, submatrix
—> 54 from umap.layouts import (
55 optimize_layout_euclidean,
56 optimize_layout_generic,

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/umap/layouts.py in
37 },
38 )
—> 39 def rdist(x, y):
40 “”"Reduced Euclidean distance.
41

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/decorators.py in wrapper(func)
219 with typeinfer.register_dispatcher(disp):
220 for sig in sigs:
→ 221 disp.compile(sig)
222 disp.disable_compile()
223 return disp

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, sig)
907 with ev.trigger_event(“numba:compile”, data=ev_details):
908 try:
→ 909 cres = self._compiler.compile(args, return_type)
910 except errors.ForceLiteralArg as e:
911 def folded(args, kws):

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, args, return_type)
77
78 def compile(self, args, return_type):
—> 79 status, retval = self._compile_cached(args, return_type)
80 if status:
81 return retval

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_cached(self, args, return_type)
91
92 try:
—> 93 retval = self._compile_core(args, return_type)
94 except errors.TypingError as e:
95 self._failed_cache[key] = e

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_core(self, args, return_type)
104
105 impl = self._get_implementation(args, {})
→ 106 cres = compiler.compile_extra(self.targetdescr.typing_context,
107 self.targetdescr.target_context,
108 impl,

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
604 pipeline = pipeline_class(typingctx, targetctx, library,
605 args, return_type, flags, locals)
→ 606 return pipeline.compile_extra(func)
607
608

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(self, func)
351 self.state.lifted = ()
352 self.state.lifted_from = None
→ 353 return self._compile_bytecode()
354
355 def compile_ir(self, func_ir, lifted=(), lifted_from=None):

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler.py in _compile_bytecode(self)
413 “”"
414 assert self.state.func_ir is None
→ 415 return self._compile_core()
416
417 def _compile_ir(self):

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
393 self.state.status.fail_reason = e
394 if is_final_pipeline:
→ 395 raise e
396 else:
397 raise CompilerError(“All available pipelines exhausted”)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
384 res = None
385 try:
→ 386 pm.run(self.state)
387 if self.state.cr is not None:
388 break

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
337 (self.pipeline_name, pass_desc)
338 patched_exception = self._patch_error(msg, e)
→ 339 raise patched_exception
340
341 def dependency_analysis(self):

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
328 pass_inst = _pass_registry.get(pss).pass_inst
329 if isinstance(pass_inst, CompilerPass):
→ 330 self._runPass(idx, pass_inst, state)
331 else:
332 raise BaseException(“Legacy pass in use”)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
33 def _acquire_compile_lock(*args, **kwargs):
34 with self:
—> 35 return func(*args, **kwargs)
36 return _acquire_compile_lock
37

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler_machinery.py in _runPass(self, index, pss, internal_state)
287 mutated |= check(pss.run_initialization, internal_state)
288 with SimpleTimer() as pass_time:
→ 289 mutated |= check(pss.run_pass, internal_state)
290 with SimpleTimer() as finalize_time:
291 mutated |= check(pss.run_finalizer, internal_state)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/compiler_machinery.py in check(func, compiler_state)
260
261 def check(func, compiler_state):
→ 262 mangled = func(compiler_state)
263 if mangled not in (True, False):
264 msg = ("CompilerPass implementations should return True/False. "

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/typed_passes.py in run_pass(self, state)
461
462 # TODO: Pull this out into the pipeline
→ 463 NativeLowering().run_pass(state)
464 lowered = state[‘cr’]
465 signature = typing.signature(state.return_type, *state.args)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/typed_passes.py in run_pass(self, state)
382 lower = lowering.Lower(targetctx, library, fndesc, interp,
383 metadata=metadata)
→ 384 lower.lower()
385 if not flags.no_cpython_wrapper:
386 lower.create_cpython_wrapper(flags.release_gil)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower(self)
134 if self.generator_info is None:
135 self.genlower = None
→ 136 self.lower_normal_function(self.fndesc)
137 else:
138 self.genlower = self.GeneratorLower(self)

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower_normal_function(self, fndesc)
188 # Init argument values
189 self.extract_function_arguments()
→ 190 entry_block_tail = self.lower_function_body()
191
192 # Close tail of entry block

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower_function_body(self)
214 bb = self.blkmap[offset]
215 self.builder.position_at_end(bb)
→ 216 self.lower_block(block)
217 self.post_lower()
218 return entry_block_tail

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
228 with new_error_context(‘lowering “{inst}” at {loc}’, inst=inst,
229 loc=self.loc, errcls_=defaulterrcls):
→ 230 self.lower_inst(inst)
231 self.post_block(block)
232

/proj/anaconda/envs/rnaseq/lib/python3.8/contextlib.py in exit(self, type, value, traceback)
129 value = type()
130 try:
→ 131 self.gen.throw(type, value, traceback)
132 except StopIteration as exc:
133 # Suppress StopIteration unless it’s the same exception that

/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)
749 newerr = errcls(e).add_context(format_msg(fmt, args, kwargs))
750 tb = sys.exc_info()[2] if numba.core.config.FULL_TRACEBACKS else None
→ 751 raise newerr.with_traceback(tb)
752
753

LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
Storing i64 to ptr of i32 (‘dim’). FE type int32

File “…/…/…/…/proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/umap/layouts.py”, line 52:
def rdist(x, y):

result = 0.0
dim = x.shape[0]
^

During: lowering “dim = static_getitem(value=$8load_attr.2, index=0, index_var=$const10.3, fn=)” at /proj/anaconda/envs/rnaseq/lib/python3.8/site-packages/umap/layouts.py (52)

Any help here?

I fixed this by reverting to numba 0.52.0 and that fixed this issue. this can be closed.