How to delete corrupted trace?

Hi everyone, first of all, I thank you for this great works. I’m new here, but I’ve using pymc for a while and got little to no problem, until recently. So i hope you all could give me some pointers. So, recently I ran my python script and part of it is pymc code containing model and simple regression to my data. Unfortunately during the run, my computer was turn off due to power failure. After that, I tried to run my code again and got some errors, as follows:

---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
Cell In[53], line 3
      1 with simple_model:
      2     # --- Inference! ---
----> 3     idata_simple = pm.sample(1000, nuts_sampler='nutpie')
      4     # idata_simple = pm.sample(1000)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\pymc\sampling\mcmc.py:722, in sample(draws, tune, chains, cores, random_seed, progressbar, progressbar_theme, step, var_names, nuts_sampler, initvals, init, jitter_max_retries, n_init, trace, discard_tuned_samples, compute_convergence_checks, keep_warning_stat, return_inferencedata, idata_kwargs, nuts_sampler_kwargs, callback, mp_ctx, blas_cores, model, **kwargs)
    718         raise ValueError(
    719             "Model can not be sampled with NUTS alone. Your model is probably not continuous."
    720         )
    721     with joined_blas_limiter():
--> 722         return _sample_external_nuts(
    723             sampler=nuts_sampler,
    724             draws=draws,
    725             tune=tune,
    726             chains=chains,
    727             target_accept=kwargs.pop("nuts", {}).get("target_accept", 0.8),
    728             random_seed=random_seed,
    729             initvals=initvals,
    730             model=model,
    731             var_names=var_names,
    732             progressbar=progressbar,
    733             idata_kwargs=idata_kwargs,
    734             nuts_sampler_kwargs=nuts_sampler_kwargs,
    735             **kwargs,
    736         )
    738 if isinstance(step, list):
    739     step = CompoundStep(step)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\pymc\sampling\mcmc.py:306, in _sample_external_nuts(sampler, draws, tune, chains, target_accept, random_seed, initvals, model, var_names, progressbar, idata_kwargs, nuts_sampler_kwargs, **kwargs)
    301 if var_names is not None:
    302     warnings.warn(
    303         "`var_names` are currently ignored by the nutpie sampler",
    304         UserWarning,
    305     )
--> 306 compiled_model = nutpie.compile_pymc_model(model)
    307 t_start = time.time()
    308 idata = nutpie.sample(
    309     compiled_model,
    310     draws=draws,
   (...)
    316     **nuts_sampler_kwargs,
    317 )

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\nutpie\compile_pymc.py:515, in compile_pymc_model(model, backend, gradient_backend, initial_points, jitter_rvs, default_initialization_strategy, var_names, freeze_model, **kwargs)
    513     if gradient_backend == "jax":
    514         raise ValueError("Gradient backend cannot be jax when using numba backend")
--> 515     return _compile_pymc_model_numba(
    516         model=model,
    517         pymc_initial_point_fn=initial_point_fn,
    518         var_names=var_names,
    519         **kwargs,
    520     )
    521 elif backend.lower() == "jax":
    522     return _compile_pymc_model_jax(
    523         model=model,
    524         gradient_backend=gradient_backend,
   (...)
    527         **kwargs,
    528     )

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\nutpie\compile_pymc.py:279, in _compile_pymc_model_numba(model, pymc_initial_point_fn, var_names, **kwargs)
    272 with warnings.catch_warnings():
    273     warnings.filterwarnings(
    274         "ignore",
    275         message="Cannot cache compiled function .* as it uses dynamic globals",
    276         category=numba.NumbaWarning,
    277     )
--> 279     logp_numba = numba.cfunc(c_sig, **kwargs)(logp_numba_raw)
    281 expand_shared_names = [var.name for var in expand_fn_pt.get_shared()]
    282 expand_numba_raw, c_sig_expand = _make_c_expand_func(
    283     n_dim, n_expanded, expand_fn, user_data, expand_shared_names, shared_data
    284 )

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\decorators.py:275, in cfunc.<locals>.wrapper(func)
    273 if cache:
    274     res.enable_caching()
--> 275 res.compile()
    276 return res

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_lock.py:35, in _CompilerLock.__call__.<locals>._acquire_compile_lock(*args, **kwargs)
     32 @functools.wraps(func)
     33 def _acquire_compile_lock(*args, **kwargs):
     34     with self:
---> 35         return func(*args, **kwargs)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\ccallback.py:68, in CFunc.compile(self)
     65 cres = self._cache.load_overload(self._sig,
     66                                  self._targetdescr.target_context)
     67 if cres is None:
---> 68     cres = self._compile_uncached()
     69     self._cache.save_overload(self._sig, cres)
     70 else:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\ccallback.py:82, in CFunc._compile_uncached(self)
     79 sig = self._sig
     81 # Compile native function as well as cfunc wrapper
---> 82 return self._compiler.compile(sig.args, sig.return_type)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:80, in _FunctionCompiler.compile(self, args, return_type)
     79 def compile(self, args, return_type):
---> 80     status, retval = self._compile_cached(args, return_type)
     81     if status:
     82         return retval

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:94, in _FunctionCompiler._compile_cached(self, args, return_type)
     91     pass
     93 try:
---> 94     retval = self._compile_core(args, return_type)
     95 except errors.TypingError as e:
     96     self._failed_cache[key] = e

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:107, in _FunctionCompiler._compile_core(self, args, return_type)
    104 flags = self._customize_flags(flags)
    106 impl = self._get_implementation(args, {})
--> 107 cres = compiler.compile_extra(self.targetdescr.typing_context,
    108                               self.targetdescr.target_context,
    109                               impl,
    110                               args=args, return_type=return_type,
    111                               flags=flags, locals=self.locals,
    112                               pipeline_class=self.pipeline_class)
    113 # Check typing error if object mode is used
    114 if cres.typing_error is not None and not flags.enable_pyobject:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:744, in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
    720 """Compiler entry point
    721 
    722 Parameter
   (...)
    740     compiler pipeline
    741 """
    742 pipeline = pipeline_class(typingctx, targetctx, library,
    743                           args, return_type, flags, locals)
--> 744 return pipeline.compile_extra(func)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:438, in CompilerBase.compile_extra(self, func)
    436 self.state.lifted = ()
    437 self.state.lifted_from = None
--> 438 return self._compile_bytecode()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:506, in CompilerBase._compile_bytecode(self)
    502 """
    503 Populate and run pipeline for bytecode input
    504 """
    505 assert self.state.func_ir is None
--> 506 return self._compile_core()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:481, in CompilerBase._compile_core(self)
    478 except Exception as e:
    479     if (utils.use_new_style_errors() and not
    480             isinstance(e, errors.NumbaError)):
--> 481         raise e
    483     self.state.status.fail_reason = e
    484     if is_final_pipeline:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:472, in CompilerBase._compile_core(self)
    470 res = None
    471 try:
--> 472     pm.run(self.state)
    473     if self.state.cr is not None:
    474         break

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:364, in PassManager.run(self, state)
    361 except Exception as e:
    362     if (utils.use_new_style_errors() and not
    363             isinstance(e, errors.NumbaError)):
--> 364         raise e
    365     msg = "Failed in %s mode pipeline (step: %s)" % \
    366         (self.pipeline_name, pass_desc)
    367     patched_exception = self._patch_error(msg, e)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:356, in PassManager.run(self, state)
    354 pass_inst = _pass_registry.get(pss).pass_inst
    355 if isinstance(pass_inst, CompilerPass):
--> 356     self._runPass(idx, pass_inst, state)
    357 else:
    358     raise BaseException("Legacy pass in use")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_lock.py:35, in _CompilerLock.__call__.<locals>._acquire_compile_lock(*args, **kwargs)
     32 @functools.wraps(func)
     33 def _acquire_compile_lock(*args, **kwargs):
     34     with self:
---> 35         return func(*args, **kwargs)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:311, in PassManager._runPass(self, index, pss, internal_state)
    309     mutated |= check(pss.run_initialization, internal_state)
    310 with SimpleTimer() as pass_time:
--> 311     mutated |= check(pss.run_pass, internal_state)
    312 with SimpleTimer() as finalize_time:
    313     mutated |= check(pss.run_finalizer, internal_state)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:273, in PassManager._runPass.<locals>.check(func, compiler_state)
    272 def check(func, compiler_state):
--> 273     mangled = func(compiler_state)
    274     if mangled not in (True, False):
    275         msg = ("CompilerPass implementations should return True/False. "
    276                "CompilerPass with name '%s' did not.")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typed_passes.py:112, in BaseTypeInference.run_pass(self, state)
    106 """
    107 Type inference and legalization
    108 """
    109 with fallback_context(state, 'Function "%s" failed type inference'
    110                       % (state.func_id.func_name,)):
    111     # Type inference
--> 112     typemap, return_type, calltypes, errs = type_inference_stage(
    113         state.typingctx,
    114         state.targetctx,
    115         state.func_ir,
    116         state.args,
    117         state.return_type,
    118         state.locals,
    119         raise_errors=self._raise_errors)
    120     state.typemap = typemap
    121     # save errors in case of partial typing

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typed_passes.py:93, in type_inference_stage(typingctx, targetctx, interp, args, return_type, locals, raise_errors)
     91     infer.build_constraint()
     92     # return errors in case of partial typing
---> 93     errs = infer.propagate(raise_errors=raise_errors)
     94     typemap, restype, calltypes = infer.unify(raise_errors=raise_errors)
     96 return _TypingResults(typemap, restype, calltypes, errs)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:1083, in TypeInferer.propagate(self, raise_errors)
   1080 oldtoken = newtoken
   1081 # Errors can appear when the type set is incomplete; only
   1082 # raise them when there is no progress anymore.
-> 1083 errors = self.constraints.propagate(self)
   1084 newtoken = self.get_state_token()
   1085 self.debug.propagate_finished()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:182, in ConstraintNetwork.propagate(self, typeinfer)
    180     errors.append(utils.chain_exception(new_exc, e))
    181 elif utils.use_new_style_errors():
--> 182     raise e
    183 else:
    184     msg = ("Unknown CAPTURED_ERRORS style: "
    185            f"'{config.CAPTURED_ERRORS}'.")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:160, in ConstraintNetwork.propagate(self, typeinfer)
    157 with typeinfer.warnings.catch_warnings(filename=loc.filename,
    158                                        lineno=loc.line):
    159     try:
--> 160         constraint(typeinfer)
    161     except ForceLiteralArg as e:
    162         errors.append(e)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:583, in CallConstraint.__call__(self, typeinfer)
    581     fnty = typevars[self.func].getone()
    582 with new_error_context("resolving callee type: {0}", fnty):
--> 583     self.resolve(typeinfer, typevars, fnty)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:606, in CallConstraint.resolve(self, typeinfer, typevars, fnty)
    604     fnty = fnty.instance_type
    605 try:
--> 606     sig = typeinfer.resolve_call(fnty, pos_args, kw_args)
    607 except ForceLiteralArg as e:
    608     # Adjust for bound methods
    609     folding_args = ((fnty.this,) + tuple(self.args)
    610                     if isinstance(fnty, types.BoundFunction)
    611                     else self.args)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:1577, in TypeInferer.resolve_call(self, fnty, pos_args, kw_args)
   1574     return sig
   1575 else:
   1576     # Normal non-recursive call
-> 1577     return self.context.resolve_function_type(fnty, pos_args, kw_args)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typing\context.py:196, in BaseContext.resolve_function_type(self, func, args, kws)
    194 # Prefer user definition first
    195 try:
--> 196     res = self._resolve_user_function_type(func, args, kws)
    197 except errors.TypingError as e:
    198     # Capture any typing error
    199     last_exception = e

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typing\context.py:248, in BaseContext._resolve_user_function_type(self, func, args, kws, literals)
    244         return self.resolve_function_type(func_type, args, kws)
    246 if isinstance(func, types.Callable):
    247     # XXX fold this into the __call__ attribute logic?
--> 248     return func.get_call_type(self, args, kws)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\types\functions.py:541, in Dispatcher.get_call_type(self, context, args, kws)
    534 def get_call_type(self, context, args, kws):
    535     """
    536     Resolve a call to this dispatcher using the given argument types.
    537     A signature returned and it is ensured that a compiled specialization
    538     is available for it.
    539     """
    540     template, pysig, args, kws = \
--> 541         self.dispatcher.get_call_template(args, kws)
    542     sig = template(context).apply(args, kws)
    543     if sig:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:318, in _DispatcherBase.get_call_template(self, args, kws)
    316 # Ensure an overload is available
    317 if self._can_compile:
--> 318     self.compile(tuple(args))
    320 # Create function type for typing
    321 func_name = self.py_func.__name__

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:905, in Dispatcher.compile(self, sig)
    903 with ev.trigger_event("numba:compile", data=ev_details):
    904     try:
--> 905         cres = self._compiler.compile(args, return_type)
    906     except errors.ForceLiteralArg as e:
    907         def folded(args, kws):

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:80, in _FunctionCompiler.compile(self, args, return_type)
     79 def compile(self, args, return_type):
---> 80     status, retval = self._compile_cached(args, return_type)
     81     if status:
     82         return retval

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:94, in _FunctionCompiler._compile_cached(self, args, return_type)
     91     pass
     93 try:
---> 94     retval = self._compile_core(args, return_type)
     95 except errors.TypingError as e:
     96     self._failed_cache[key] = e

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:107, in _FunctionCompiler._compile_core(self, args, return_type)
    104 flags = self._customize_flags(flags)
    106 impl = self._get_implementation(args, {})
--> 107 cres = compiler.compile_extra(self.targetdescr.typing_context,
    108                               self.targetdescr.target_context,
    109                               impl,
    110                               args=args, return_type=return_type,
    111                               flags=flags, locals=self.locals,
    112                               pipeline_class=self.pipeline_class)
    113 # Check typing error if object mode is used
    114 if cres.typing_error is not None and not flags.enable_pyobject:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:744, in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
    720 """Compiler entry point
    721 
    722 Parameter
   (...)
    740     compiler pipeline
    741 """
    742 pipeline = pipeline_class(typingctx, targetctx, library,
    743                           args, return_type, flags, locals)
--> 744 return pipeline.compile_extra(func)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:438, in CompilerBase.compile_extra(self, func)
    436 self.state.lifted = ()
    437 self.state.lifted_from = None
--> 438 return self._compile_bytecode()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:506, in CompilerBase._compile_bytecode(self)
    502 """
    503 Populate and run pipeline for bytecode input
    504 """
    505 assert self.state.func_ir is None
--> 506 return self._compile_core()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:481, in CompilerBase._compile_core(self)
    478 except Exception as e:
    479     if (utils.use_new_style_errors() and not
    480             isinstance(e, errors.NumbaError)):
--> 481         raise e
    483     self.state.status.fail_reason = e
    484     if is_final_pipeline:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler.py:472, in CompilerBase._compile_core(self)
    470 res = None
    471 try:
--> 472     pm.run(self.state)
    473     if self.state.cr is not None:
    474         break

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:364, in PassManager.run(self, state)
    361 except Exception as e:
    362     if (utils.use_new_style_errors() and not
    363             isinstance(e, errors.NumbaError)):
--> 364         raise e
    365     msg = "Failed in %s mode pipeline (step: %s)" % \
    366         (self.pipeline_name, pass_desc)
    367     patched_exception = self._patch_error(msg, e)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:356, in PassManager.run(self, state)
    354 pass_inst = _pass_registry.get(pss).pass_inst
    355 if isinstance(pass_inst, CompilerPass):
--> 356     self._runPass(idx, pass_inst, state)
    357 else:
    358     raise BaseException("Legacy pass in use")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_lock.py:35, in _CompilerLock.__call__.<locals>._acquire_compile_lock(*args, **kwargs)
     32 @functools.wraps(func)
     33 def _acquire_compile_lock(*args, **kwargs):
     34     with self:
---> 35         return func(*args, **kwargs)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:311, in PassManager._runPass(self, index, pss, internal_state)
    309     mutated |= check(pss.run_initialization, internal_state)
    310 with SimpleTimer() as pass_time:
--> 311     mutated |= check(pss.run_pass, internal_state)
    312 with SimpleTimer() as finalize_time:
    313     mutated |= check(pss.run_finalizer, internal_state)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\compiler_machinery.py:273, in PassManager._runPass.<locals>.check(func, compiler_state)
    272 def check(func, compiler_state):
--> 273     mangled = func(compiler_state)
    274     if mangled not in (True, False):
    275         msg = ("CompilerPass implementations should return True/False. "
    276                "CompilerPass with name '%s' did not.")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typed_passes.py:112, in BaseTypeInference.run_pass(self, state)
    106 """
    107 Type inference and legalization
    108 """
    109 with fallback_context(state, 'Function "%s" failed type inference'
    110                       % (state.func_id.func_name,)):
    111     # Type inference
--> 112     typemap, return_type, calltypes, errs = type_inference_stage(
    113         state.typingctx,
    114         state.targetctx,
    115         state.func_ir,
    116         state.args,
    117         state.return_type,
    118         state.locals,
    119         raise_errors=self._raise_errors)
    120     state.typemap = typemap
    121     # save errors in case of partial typing

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typed_passes.py:93, in type_inference_stage(typingctx, targetctx, interp, args, return_type, locals, raise_errors)
     91     infer.build_constraint()
     92     # return errors in case of partial typing
---> 93     errs = infer.propagate(raise_errors=raise_errors)
     94     typemap, restype, calltypes = infer.unify(raise_errors=raise_errors)
     96 return _TypingResults(typemap, restype, calltypes, errs)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:1083, in TypeInferer.propagate(self, raise_errors)
   1080 oldtoken = newtoken
   1081 # Errors can appear when the type set is incomplete; only
   1082 # raise them when there is no progress anymore.
-> 1083 errors = self.constraints.propagate(self)
   1084 newtoken = self.get_state_token()
   1085 self.debug.propagate_finished()

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:182, in ConstraintNetwork.propagate(self, typeinfer)
    180     errors.append(utils.chain_exception(new_exc, e))
    181 elif utils.use_new_style_errors():
--> 182     raise e
    183 else:
    184     msg = ("Unknown CAPTURED_ERRORS style: "
    185            f"'{config.CAPTURED_ERRORS}'.")

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:160, in ConstraintNetwork.propagate(self, typeinfer)
    157 with typeinfer.warnings.catch_warnings(filename=loc.filename,
    158                                        lineno=loc.line):
    159     try:
--> 160         constraint(typeinfer)
    161     except ForceLiteralArg as e:
    162         errors.append(e)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:583, in CallConstraint.__call__(self, typeinfer)
    581     fnty = typevars[self.func].getone()
    582 with new_error_context("resolving callee type: {0}", fnty):
--> 583     self.resolve(typeinfer, typevars, fnty)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:606, in CallConstraint.resolve(self, typeinfer, typevars, fnty)
    604     fnty = fnty.instance_type
    605 try:
--> 606     sig = typeinfer.resolve_call(fnty, pos_args, kw_args)
    607 except ForceLiteralArg as e:
    608     # Adjust for bound methods
    609     folding_args = ((fnty.this,) + tuple(self.args)
    610                     if isinstance(fnty, types.BoundFunction)
    611                     else self.args)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typeinfer.py:1577, in TypeInferer.resolve_call(self, fnty, pos_args, kw_args)
   1574     return sig
   1575 else:
   1576     # Normal non-recursive call
-> 1577     return self.context.resolve_function_type(fnty, pos_args, kw_args)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typing\context.py:196, in BaseContext.resolve_function_type(self, func, args, kws)
    194 # Prefer user definition first
    195 try:
--> 196     res = self._resolve_user_function_type(func, args, kws)
    197 except errors.TypingError as e:
    198     # Capture any typing error
    199     last_exception = e

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\typing\context.py:248, in BaseContext._resolve_user_function_type(self, func, args, kws, literals)
    244         return self.resolve_function_type(func_type, args, kws)
    246 if isinstance(func, types.Callable):
    247     # XXX fold this into the __call__ attribute logic?
--> 248     return func.get_call_type(self, args, kws)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\types\functions.py:541, in Dispatcher.get_call_type(self, context, args, kws)
    534 def get_call_type(self, context, args, kws):
    535     """
    536     Resolve a call to this dispatcher using the given argument types.
    537     A signature returned and it is ensured that a compiled specialization
    538     is available for it.
    539     """
    540     template, pysig, args, kws = \
--> 541         self.dispatcher.get_call_template(args, kws)
    542     sig = template(context).apply(args, kws)
    543     if sig:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:318, in _DispatcherBase.get_call_template(self, args, kws)
    316 # Ensure an overload is available
    317 if self._can_compile:
--> 318     self.compile(tuple(args))
    320 # Create function type for typing
    321 func_name = self.py_func.__name__

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\dispatcher.py:886, in Dispatcher.compile(self, sig)
    884     return existing.entry_point
    885 # Try to load from disk cache
--> 886 cres = self._cache.load_overload(sig, self.targetctx)
    887 if cres is not None:
    888     self._cache_hits[sig] += 1

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\caching.py:635, in Cache.load_overload(self, sig, target_context)
    633 target_context.refresh()
    634 with self._guard_against_spurious_io_errors():
--> 635     return self._load_overload(sig, target_context)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\caching.py:642, in Cache._load_overload(self, sig, target_context)
    640     return
    641 key = self._index_key(sig, target_context.codegen())
--> 642 data = self._cache_file.load(key)
    643 if data is not None:
    644     data = self._impl.rebuild(target_context, data)

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\caching.py:485, in IndexDataCacheFile.load(self, key)
    481 def load(self, key):
    482     """
    483     Load a cache entry with *key*.
    484     """
--> 485     overloads = self._load_index()
    486     data_name = overloads.get(key)
    487     if data_name is None:

File c:\Users\PJ\miniconda3\envs\pymc\Lib\site-packages\numba\core\caching.py:511, in IndexDataCacheFile._load_index(self)
    507 if version != self._version:
    508     # This is another version.  Avoid trying to unpickling the
    509     # rest of the stream, as that may fail.
    510     return {}
--> 511 stamp, overloads = pickle.loads(data)
    512 _cache_log("[cache] index loaded from %r", self._index_path)
    513 if stamp != self._source_stamp:
    514     # Cache is not fresh.  Stale data files will be eventually
    515     # overwritten, since they are numbered in incrementing order.

UnpicklingError: invalid load key, '\x00'.

When searching for solutions, I’ve got some info that this is due to corrupted trace file (?) or something like that, but I can’t found where these files were located eventhoughp I want to delete them and restarting my pymc run. Any suggestions? or did I got it wrong? Thank you for your patients.

warm regards,
PJ

The error is related to numba caching. You could try clearing the numba cache, which I think amounts to deleting the __pycache__ directory wherever your project lives. You can also run pytensor-cache clear to clear the pytensor cache, which might or might not be implicated.

Hi Jesse, thanks for your suggestions. I tried both of them, but still to no avail. Here I attached the pycache directory that I removed. This directory is inside my working directory. I also try to run my script in other directory (under the same conda environment) but the problem still persists. When I change environment (or create a new one containing pymc) the problem was solved when I run my script using that (new) environment. Any ideas?

I’d just delete the environment and rebuild it in that case. They’re meant to be disposable. Other option is to look on SO for advice about clearing numba cache.

Hi Jesse, OK thanks!