============================= test session starts ============================== platform darwin -- Python 3.11.0, pytest-7.2.1, pluggy-1.0.0 -- /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/bin/python3.11 cachedir: .pytest_cache rootdir: /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests collecting ... collected 87 items ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestBaseModel::test_setattr_properly_works PASSED [ 1%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestBaseModel::test_context_passes_vars_to_parent_model PASSED [ 2%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_nest_context_works PASSED [ 3%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_named_context PASSED [ 4%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_docstring_example1 PASSED [ 5%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_docstring_example2 PASSED [ 6%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_duplicates_detection PASSED [ 8%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_model_root PASSED [ 9%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_prefix_add_uses_separator PASSED [ 10%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_nested_named_model_repeated PASSED [ 11%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_nested_named_model PASSED [ 12%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_nested_model_to_netcdf FAILED [ 13%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestNested::test_bad_name PASSED [ 14%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestObserved::test_observed_rv_fail PASSED [ 16%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestObserved::test_observed_type PASSED [ 17%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_duplicate_vars PASSED [ 18%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_empty_observed PASSED [ 19%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_edge_case XFAIL [ 20%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_extra_not_set PASSED [ 21%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_grad PASSED [ 22%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_invalid_type PASSED [ 24%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_missing_data FAILED [ 25%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_no_extra PASSED [ 26%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_pytensor_switch_broadcast_edge_cases_1 FAILED [ 27%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestValueGradFunction::test_pytensor_switch_broadcast_edge_cases_2 FAILED [ 28%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_multiple_observed_rv PASSED [ 29%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_tempered_logp_dlogp FAILED [ 31%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestPickling::test_model_pickle PASSED [ 32%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestPickling::test_model_pickle_deterministic PASSED [ 33%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestPickling::test_model_roundtrip PASSED [ 34%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_value_vars PASSED [ 35%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_var_maps PASSED [ 36%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_make_obs_var PASSED [ 37%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_initial_point FAILED [ 39%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_point_logps FAILED [ 40%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_point_logps_potential PASSED [ 41%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestShapeEvaluation::test_eval_rv_shapes FAILED [ 42%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestCheckStartVals::test_valid_start_point FAILED [ 43%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestCheckStartVals::test_invalid_start_point FAILED [ 44%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestCheckStartVals::test_invalid_variable_name PASSED [ 45%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_initval FAILED [ 47%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_datalogp_multiple_shapes FAILED [ 48%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_nested_model_coords PASSED [ 49%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_shapeerror_from_set_data_dimensionality PASSED [ 50%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_shapeerror_from_resize_immutable_dim_from_RV FAILED [ 51%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_shapeerror_from_resize_immutable_dim_from_coords PASSED [ 52%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_valueerror_from_resize_without_coords_update PASSED [ 54%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_coords_and_constantdata_create_immutable_dims PASSED [ 55%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_add_coord_mutable_kwarg PASSED [ 56%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_dim PASSED [ 57%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_dim_with_coords PASSED [ 58%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_add_named_variable_checks_dim_name FAILED [ 59%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_data_indirect_resize PASSED [ 60%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_data_warns_on_resize_of_dims_defined_by_other_mutabledata FAILED [ 62%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_data_indirect_resize_with_coords PASSED [ 63%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_set_data_constant_shape_error PASSED [ 64%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_deprecation_warning PASSED [ 65%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_logp[True] FAILED [ 66%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_logp[False] FAILED [ 67%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_dlogp[True] FAILED [ 68%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_dlogp[False] FAILED [ 70%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_d2logp[True] FAILED [ 71%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_d2logp[False] FAILED [ 72%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_deterministic PASSED [ 73%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_empty_model_representation PASSED [ 74%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_compile_fn FAILED [ 75%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_pytensor_config PASSED [ 77%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_model_parent_set_programmatically PASSED [ 78%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestModelContext::test_thread_safety PASSED [ 79%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_mixed_contexts PASSED [ 80%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestProfile::test_profile_model FAILED [ 81%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestProfile::test_profile_variable FAILED [ 82%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestProfile::test_profile_count FAILED [ 83%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_basic[masked] FAILED [ 85%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_basic[pandas] FAILED [ 86%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_with_predictors FAILED [ 87%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_dual_observations FAILED [ 88%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_interval_missing_observations FAILED [ 89%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_logp1 FAILED [ 90%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_logp2 FAILED [ 91%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_multivariate FAILED [ 93%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_vector_parameter FAILED [ 94%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_missing_symmetric PASSED [ 95%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_dims PASSED [ 96%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestImputationMissingData::test_error_non_random_variable PASSED [ 97%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::TestShared::test_deterministic PASSED [ 98%] ../../opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pymc/tests/test_model.py::test_tag_future_warning_model PASSED [100%] =================================== FAILURES =================================== ____________________ TestNested.test_nested_model_to_netcdf ____________________ self = VMLinker(use_cloop=True, lazy=None, allow_partial_eval=None, allow_gc=True) profiler = None, input_storage = [[None]], output_storage = [[None], [None]] storage_map = {scope::var: [None], TensorConstant{-0.5}: [array(-0.5)], TensorConstant{0.9189385332046727}: [array(0.91893853)], sigma > 0: [None], ...} def make_all( self, profiler=None, input_storage=None, output_storage=None, storage_map=None, ): fgraph = self.fgraph order = self.schedule(fgraph) input_storage, output_storage, storage_map = map_storage( fgraph, order, input_storage, output_storage, storage_map ) compute_map = {} for k in storage_map: compute_map[k] = [k.owner is None] thunks = [] t0 = time.perf_counter() linker_make_thunk_time = {} impl = None if self.c_thunks is False: impl = "py" for node in order: try: thunk_start = time.perf_counter() # no-recycling is done at each VM.__call__ So there is # no need to cause duplicate c code by passing # no_recycling here. thunks.append( > node.op.make_thunk(node, storage_map, compute_map, [], impl=impl) ) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/vm.py:1246: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = node = Elemwise{neg,no_inplace}(scope::var) storage_map = {scope::var: [None], TensorConstant{-0.5}: [array(-0.5)], TensorConstant{0.9189385332046727}: [array(0.91893853)], sigma > 0: [None], ...} compute_map = {scope::var: [True], TensorConstant{-0.5}: [True], TensorConstant{0.9189385332046727}: [True], sigma > 0: [False], ...} no_recycling = [], impl = None def make_thunk(self, node, storage_map, compute_map, no_recycling, impl=None): """Create a thunk. See :meth:`Op.make_thunk`. Parameters ---------- impl : Currently, ``None``, ``'c'`` or ``'py'``. If ``'c'`` or ``'py'`` we will only try that version of the code. """ if (impl is None and config.cxx) or impl == "c": self.prepare_node( node, storage_map=storage_map, compute_map=compute_map, impl="c" ) try: > return self.make_c_thunk(node, storage_map, compute_map, no_recycling) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/op.py:131: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = node = Elemwise{neg,no_inplace}(scope::var) storage_map = {scope::var: [None], TensorConstant{-0.5}: [array(-0.5)], TensorConstant{0.9189385332046727}: [array(0.91893853)], sigma > 0: [None], ...} compute_map = {scope::var: [True], TensorConstant{-0.5}: [True], TensorConstant{0.9189385332046727}: [True], sigma > 0: [False], ...} no_recycling = [] def make_c_thunk( self, node: Apply, storage_map: StorageMapType, compute_map: ComputeMapType, no_recycling: Collection[Variable], ) -> CThunkWrapperType: """Create a thunk for a C implementation. Like :meth:`Op.make_thunk`, but will only try to make a C thunk. """ # FIXME: Putting the following import on the module level causes an import cycle. # The conclusion should be that the antire "make_c_thunk" method should be defined # in pytensor.link.c and dispatched onto the Op! import pytensor.link.c.basic from pytensor.graph.fg import FunctionGraph node_input_storage = [storage_map[r] for r in node.inputs] node_output_storage = [storage_map[r] for r in node.outputs] e = FunctionGraph(node.inputs, node.outputs) e_no_recycling = [ new_o for (new_o, old_o) in zip(e.outputs, node.outputs) if old_o in no_recycling ] cl = pytensor.link.c.basic.CLinker().accept(e, no_recycling=e_no_recycling) # float16 gets special treatment since running # unprepared C code will get bad results. if not getattr(self, "_f16_ok", False): def is_f16(t): return getattr(t, "dtype", "") == "float16" if any(is_f16(i.type) for i in node.inputs) or any( is_f16(o.type) for o in node.outputs ): # get_dynamic_module is a subset of make_thunk that is reused. # This just try to build the c code # It will raise an error for ops # that don't implement c code. In those cases, we # don't want to print a warning. cl.get_dynamic_module() print(f"Disabling C code for {self} due to unsupported float16") raise NotImplementedError("float16") > outputs = cl.make_thunk( input_storage=node_input_storage, output_storage=node_output_storage ) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/op.py:96: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = input_storage = [[None]], output_storage = [[None]], storage_map = None cache = None, kwargs = {} init_tasks = [(scope::var_grad, 'init', 1), (scope::var, 'init', 3), (Elemwise{neg,no_inplace}(scope::var), 'init', 6)] tasks = [(scope::var_grad, 'get', 2), (scope::var, 'get', 4), (Elemwise{neg,no_inplace}(scope::var), 'code', 5)] def make_thunk( self, input_storage=None, output_storage=None, storage_map=None, cache: Optional["ModuleCache"] = None, **kwargs, ): """Compile this linker's `self.fgraph` and return a function that performs the computations. The return values can be used as follows: .. code-block:: f, istor, ostor = clinker.make_thunk() istor[0].data = first_input istor[1].data = second_input f() first_output = ostor[0].data Parameters ---------- input_storage: list or None List of lists of length 1. In order to use the thunk returned by `CLinker.__compile__`, the inputs must be put in that storage. If None, storage will be allocated. output_storage: list of lists of length 1. The thunk returned by `CLinker.__compile__` will put the variables of the computation in these lists. If None, storage will be allocated. storage_map: dict that map variables to storages. This is used when you need to customize the storage of this thunk cache A cache in which to store the compilation results. Returns ------- thunk, input_storage, output_storage """ init_tasks, tasks = self.get_init_tasks() > cthunk, module, in_storage, out_storage, error_storage = self.__compile__( input_storage, output_storage, storage_map, cache ) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/basic.py:1202: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = input_storage = ([None],), output_storage = ([None],), storage_map = None cache = None def __compile__( self, input_storage=None, output_storage=None, storage_map=None, cache: Optional["ModuleCache"] = None, ): """Compile `self.fgraph`. Parameters ---------- input_storage: list or None List of lists of length 1. In order to use the thunk returned by this method, the inputs must be put in that storage. If None, storage will be allocated. output_storage: list of lists of length 1 The thunk returned by this method will put the variables of the computation in these lists. If None, storage will be allocated. Returns ------- object Thunk, input_storage, output_storage, error_storage. """ error_storage = [None, None, None] if input_storage is None: input_storage = tuple([None] for variable in self.inputs) if output_storage is None: map = {} output_storage = [] # Initialize the map with the inputs, as some outputs may # be inputs as well. for i, variable in enumerate(self.inputs): map[variable] = input_storage[i] for variable in self.outputs: if variable not in map: map[variable] = [None] output_storage.append(map[variable]) input_storage = tuple(input_storage) output_storage = tuple(output_storage) > thunk, module = self.cthunk_factory( error_storage, input_storage, output_storage, storage_map, cache, ) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/basic.py:1122: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = error_storage = [None, None, None], in_storage = ([None],) out_storage = ([None],), storage_map = None cache = def cthunk_factory( self, error_storage, in_storage, out_storage, storage_map=None, cache: Optional["ModuleCache"] = None, ): """ Returns a thunk that points to an instance of a C struct that can carry on the computation of this linker's fgraph Parameters: ---------- error_storage -> list of length 3 in_storage -> list of lists of length 1, one per input out_storage -> list of lists of length 1, one per output Returns a thunk that points to an instance of a C struct that can carry on the computation of this linker's fgraph. That thunk, when executed, will fetch its inputs from in_storage, put its outputs in out_storage and if an error occurs will put the type, value and traceback of the exception in error_storage. """ try: key = self.cmodule_key() except KeyError: key = None if key is None: # If we can't get a key, then forget the cache mechanism. module = self.compile_cmodule() else: # Set compute_map as None as clinker do not support lazy evaluation for node in self.node_order: node.op.prepare_node(node, storage_map, None, "c") if cache is None: cache = get_module_cache() > module = cache.module_from_key(key=key, lnk=self) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/basic.py:1647: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = key = (((14, (4,), (13, '1.24.2'), (13, '1.24.2'), ('openmp', False)), ('scalar_op', 'inplace_pattern'), (11, 13, '1.24.2'),...NPY_ABI_VERSION=0x1000009', 'c_compiler_str=/opt/homebrew/Caskroom/miniforge/base/envs/pymc5/bin/clang++ 14.0.6', ...)) lnk = def module_from_key(self, key, lnk: "CLinker"): """ Return a module from the cache, compiling it if necessary. Parameters ---------- key The key object associated with the module. If this hits a match, we avoid compilation. lnk Usually a CLinker instance, but it can be any object that defines the `get_src_code()` and `compile_cmodule(location)` functions. The first one returns the source code of the module to load/compile and the second performs the actual compilation. """ # Is the module in the cache? module = self._get_from_key(key) if module is not None: return module src_code = lnk.get_src_code() # Is the source code already in the cache? module_hash = get_module_hash(src_code, key) module = self._get_from_hash(module_hash, key) if module is not None: return module with lock_ctx(): # 1) Maybe somebody else compiled it for us while we # where waiting for the lock. Try to load it again. # 2) If other repo that import PyTensor have PyTensor ops defined, # we need to refresh the cache here. Otherwise, there are import # order problems. # (Outdated) When device=gpu, we compile during PyTensor # import. This triggers the loading of the cache. But # unpickling the cache asks that the external Ops are # completely loaded, which isn't always the case! # If a module isn't completely loaded and its unpickling # fails, it means it is safe for this function # compilation to skip them, but not for future # compilations. So reloading the cache here # compilation fixes this problem. (we could do that only once) self.refresh(cleanup=False) module = self._get_from_key(key) if module is not None: return module module = self._get_from_hash(module_hash, key) if module is not None: return module hash_key = hash(key) nocleanup = False try: location = dlimport_workdir(self.dirname) > module = lnk.compile_cmodule(location) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/cmodule.py:1231: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = location = '/Users/rodrigo/.pytensor/compiledir_macOS-12.6.3-arm64-arm-64bit-arm-3.11.0-64/tmpjuy18wd3' def compile_cmodule(self, location=None): """ This compiles the source code for this linker and returns a loaded module. """ if location is None: location = dlimport_workdir(config.compiledir) mod = self.get_dynamic_module() c_compiler = self.c_compiler() libs = self.libraries() preargs = self.compile_args() # We want to compute the code without the lock src_code = mod.code() with lock_ctx(): try: _logger.debug(f"LOCATION {location}") > module = c_compiler.compile_str( module_name=mod.code_hash, src_code=src_code, location=location, include_dirs=self.header_dirs(), lib_dirs=self.lib_dirs(), libs=libs, preargs=preargs, ) /opt/homebrew/Caskroom/miniforge/base/envs/pymc5/lib/python3.11/site-packages/pytensor/link/c/basic.py:1546: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ module_name = 'm4f4f2d49e31668807bf245a3d46abd3c28a3cc9d60f45d028b682d3dd0edfa47' src_code = '#include \n#include \n#include "pytensor_mod_helper.h"\n#include \n#include