Skip to content

BUG: clang linker fails #1347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
knods3k opened this issue Apr 7, 2025 · 2 comments
Closed

BUG: clang linker fails #1347

knods3k opened this issue Apr 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@knods3k
Copy link

knods3k commented Apr 7, 2025

Describe the issue:

I have installed PyMC exactly as recommended:

conda create -c conda-forge -n pymc_env "pymc>=5"
conda activate pymc_env

And running the basic usage example for pytensor, I get a very cryptic C compiler error.

I have uninstalled and reinstalled the complete conda environment various times, and installed individual packages like PyMC, pytensor, theano in differing orders, combinations and versions.
All of them throw similar long and cryptic errors related to the c compiler.

Note, that the compiler is installed by conda into the environment.

Reproducable code example:

import pytensor
from pytensor import tensor as pt

# Declare two symbolic floating-point scalars
a = pt.dscalar("a")
b = pt.dscalar("b")

# Create a simple example expression
c = a + b

# Convert the expression into a callable object that takes `(a, b)`
# values as input and computes the value of `c`.
f_c = pytensor.function([a, b], c)

assert f_c(1.5, 2.5) == 4.0

# Compute the gradient of the example expression with respect to `a`
dc = pytensor.grad(c, a)

f_dc = pytensor.function([a, b], dc)

assert f_dc(1.5, 2.5) == 1.0

# Compiling functions with `pytensor.function` also optimizes
# expression graphs by removing unnecessary operations and
# replacing computations with more efficient ones.

v = pt.vector("v")
M = pt.matrix("M")

d = a/a + (M + a).dot(v)

pytensor.dprint(d)
#  Add [id A]
#  ├─ ExpandDims{axis=0} [id B]
#  │  └─ True_div [id C]
#  │     ├─ a [id D]
#  │     └─ a [id D]
#  └─ dot [id E]
#     ├─ Add [id F]
#     │  ├─ M [id G]
#     │  └─ ExpandDims{axes=[0, 1]} [id H]
#     │     └─ a [id D]
#     └─ v [id I]

f_d = pytensor.function([a, v, M], d)

# `a/a` -> `1` and the dot product is replaced with a BLAS function
# (i.e. CGemv)
pytensor.dprint(f_d)
# Add [id A] 5
#  ├─ [1.] [id B]
#  └─ CGemv{inplace} [id C] 4
#     ├─ AllocEmpty{dtype='float64'} [id D] 3
#     │  └─ Shape_i{0} [id E] 2
#     │     └─ M [id F]
#     ├─ 1.0 [id G]
#     ├─ Add [id H] 1
#     │  ├─ M [id F]
#     │  └─ ExpandDims{axes=[0, 1]} [id I] 0
#     │     └─ a [id J]
#     ├─ v [id K]
#     └─ 0.0 [id L]
# %%

Error message:

---------------------------------------------------------------------------
CompileError                              Traceback (most recent call last)
File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/vm.py:1230, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
   1226 # no-recycling is done at each VM.__call__ So there is
   1227 # no need to cause duplicate c code by passing
   1228 # no_recycling here.
   1229 thunks.append(
-> 1230     node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
   1231 )
   1232 linker_make_thunk_time[node] = time.perf_counter() - thunk_start

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/op.py:119, in COp.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
    118 try:
--> 119     return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
    120 except (NotImplementedError, MethodNotDefined):
    121     # We requested the c code, so don't catch the error.

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/op.py:84, in COp.make_c_thunk(self, node, storage_map, compute_map, no_recycling)
     83         raise NotImplementedError("float16")
---> 84 outputs = cl.make_thunk(
     85     input_storage=node_input_storage, output_storage=node_output_storage
     86 )
     87 thunk, node_input_filters, node_output_filters = outputs

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1185, in CLinker.make_thunk(self, input_storage, output_storage, storage_map, cache, **kwargs)
   1184 init_tasks, tasks = self.get_init_tasks()
-> 1185 cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
   1186     input_storage, output_storage, storage_map, cache
   1187 )
   1189 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1102, in CLinker.__compile__(self, input_storage, output_storage, storage_map, cache)
   1101 output_storage = tuple(output_storage)
-> 1102 thunk, module = self.cthunk_factory(
   1103     error_storage,
   1104     input_storage,
   1105     output_storage,
   1106     storage_map,
   1107     cache,
   1108 )
   1109 return (
   1110     thunk,
   1111     module,
   (...)   1124     error_storage,
   1125 )

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1626, in CLinker.cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, cache)
   1625         cache = get_module_cache()
-> 1626     module = cache.module_from_key(key=key, lnk=self)
   1628 vars = self.inputs + self.outputs + self.orphans

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/cmodule.py:1250, in ModuleCache.module_from_key(self, key, lnk)
   1249 location = dlimport_workdir(self.dirname)
-> 1250 module = lnk.compile_cmodule(location)
   1251 name = module.__file__

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1527, in CLinker.compile_cmodule(self, location)
   1526     _logger.debug(f"LOCATION {location}")
-> 1527     module = c_compiler.compile_str(
   1528         module_name=mod.code_hash,
   1529         src_code=src_code,
   1530         location=location,
   1531         include_dirs=self.header_dirs(),
   1532         lib_dirs=self.lib_dirs(),
   1533         libs=libs,
   1534         preargs=preargs,
   1535     )
   1536 except Exception as e:

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/cmodule.py:2676, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2672     # We replace '\n' by '. ' in the error message because when Python
   2673     # prints the exception, having '\n' in the text makes it more
   2674     # difficult to read.
   2675     # compile_stderr = compile_stderr.replace("\n", ". ")
-> 2676     raise CompileError(
   2677         f"Compilation failed (return status={status}):\n{' '.join(cmd)}\n{compile_stderr}"
   2678     )
   2679 elif config.cmodule__compilation_warning and compile_stderr:
   2680     # Print errors just below the command line.

CompileError: Compilation failed (return status=1):
/opt/homebrew/Caskroom/miniconda/base/envs/prob/bin/clang++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -fPIC -undefined dynamic_lookup -ld64 -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/numpy/_core/include -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/include/python3.13 -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/c_code -L/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib -fvisibility=hidden -o /Users/cankayser/.pytensor/compiledir_macOS-15.3.2-arm64-arm-64bit-Mach-O-arm-3.13.2-64/tmp0849k9x0/m7f5abb5c650b9a70348e698e2274cbebb540b453f324f64fe2522bfb278340b8.so /Users/cankayser/.pytensor/compiledir_macOS-15.3.2-arm64-arm-64bit-Mach-O-arm-3.13.2-64/tmp0849k9x0/mod.cpp
ld: -lto_library library filename must be 'libLTO.dylib'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)


During handling of the above exception, another exception occurred:

CompileError                              Traceback (most recent call last)
Cell In[1], line 14
     10 c = a + b
     12 # Convert the expression into a callable object that takes `(a, b)`
     13 # values as input and computes the value of `c`.
---> 14 f_c = pytensor.function([a, b], c)
     16 assert f_c(1.5, 2.5) == 4.0
     18 # Compute the gradient of the example expression with respect to `a`

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/compile/function/__init__.py:332, in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, trust_input)
    321     fn = orig_function(
    322         inputs,
    323         outputs,
   (...)    327         trust_input=trust_input,
    328     )
    329 else:
    330     # note: pfunc will also call orig_function -- orig_function is
    331     #      a choke point that all compilation must pass through
--> 332     fn = pfunc(
    333         params=inputs,
    334         outputs=outputs,
    335         mode=mode,
    336         updates=updates,
    337         givens=givens,
    338         no_default_updates=no_default_updates,
    339         accept_inplace=accept_inplace,
    340         name=name,
    341         rebuild_strict=rebuild_strict,
    342         allow_input_downcast=allow_input_downcast,
    343         on_unused_input=on_unused_input,
    344         profile=profile,
    345         output_keys=output_keys,
    346         trust_input=trust_input,
    347     )
    348 return fn

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/compile/function/pfunc.py:466, in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys, fgraph, trust_input)
    452     profile = ProfileStats(message=profile)
    454 inputs, cloned_outputs = construct_pfunc_ins_and_outs(
    455     params,
    456     outputs,
   (...)    463     fgraph=fgraph,
    464 )
--> 466 return orig_function(
    467     inputs,
    468     cloned_outputs,
    469     mode,
    470     accept_inplace=accept_inplace,
    471     name=name,
    472     profile=profile,
    473     on_unused_input=on_unused_input,
    474     output_keys=output_keys,
    475     fgraph=fgraph,
    476     trust_input=trust_input,
    477 )

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/compile/function/types.py:1833, in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys, fgraph, trust_input)
   1820     m = Maker(
   1821         inputs,
   1822         outputs,
   (...)   1830         trust_input=trust_input,
   1831     )
   1832     with config.change_flags(compute_test_value="off"):
-> 1833         fn = m.create(defaults)
   1834 finally:
   1835     if profile and fn:

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/compile/function/types.py:1717, in FunctionMaker.create(self, input_storage, storage_map)
   1714 start_import_time = pytensor.link.c.cmodule.import_time
   1716 with config.change_flags(traceback__limit=config.traceback__compile_limit):
-> 1717     _fn, _i, _o = self.linker.make_thunk(
   1718         input_storage=input_storage_lists, storage_map=storage_map
   1719     )
   1721 end_linker = time.perf_counter()
   1723 linker_time = end_linker - start_linker

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/basic.py:245, in LocalLinker.make_thunk(self, input_storage, output_storage, storage_map, **kwargs)
    238 def make_thunk(
    239     self,
    240     input_storage: Optional["InputStorageType"] = None,
   (...)    243     **kwargs,
    244 ) -> tuple["BasicThunkType", "InputStorageType", "OutputStorageType"]:
--> 245     return self.make_all(
    246         input_storage=input_storage,
    247         output_storage=output_storage,
    248         storage_map=storage_map,
    249     )[:3]

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/vm.py:1239, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
   1237             thunks[-1].lazy = False
   1238     except Exception:
-> 1239         raise_with_op(fgraph, node)
   1241 t1 = time.perf_counter()
   1243 if self.profile:

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/utils.py:526, in raise_with_op(fgraph, node, thunk, exc_info, storage_map)
    521     warnings.warn(
    522         f"{exc_type} error does not allow us to add an extra error message"
    523     )
    524     # Some exception need extra parameter in inputs. So forget the
    525     # extra long error message in that case.
--> 526 raise exc_value.with_traceback(exc_trace)

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/vm.py:1230, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
   1225 thunk_start = time.perf_counter()
   1226 # no-recycling is done at each VM.__call__ So there is
   1227 # no need to cause duplicate c code by passing
   1228 # no_recycling here.
   1229 thunks.append(
-> 1230     node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
   1231 )
   1232 linker_make_thunk_time[node] = time.perf_counter() - thunk_start
   1233 if not hasattr(thunks[-1], "lazy"):
   1234     # We don't want all ops maker to think about lazy Ops.
   1235     # So if they didn't specify that its lazy or not, it isn't.
   1236     # If this member isn't present, it will crash later.

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/op.py:119, in COp.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
    115 self.prepare_node(
    116     node, storage_map=storage_map, compute_map=compute_map, impl="c"
    117 )
    118 try:
--> 119     return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
    120 except (NotImplementedError, MethodNotDefined):
    121     # We requested the c code, so don't catch the error.
    122     if impl == "c":

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/op.py:84, in COp.make_c_thunk(self, node, storage_map, compute_map, no_recycling)
     82         warnings.warn(f"Disabling C code for {self} due to unsupported float16")
     83         raise NotImplementedError("float16")
---> 84 outputs = cl.make_thunk(
     85     input_storage=node_input_storage, output_storage=node_output_storage
     86 )
     87 thunk, node_input_filters, node_output_filters = outputs
     89 @is_cthunk_wrapper_type
     90 def rval():

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1185, in CLinker.make_thunk(self, input_storage, output_storage, storage_map, cache, **kwargs)
   1150 """Compile this linker's `self.fgraph` and return a function that performs the computations.
   1151 
   1152 The return values can be used as follows:
   (...)   1182 
   1183 """
   1184 init_tasks, tasks = self.get_init_tasks()
-> 1185 cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
   1186     input_storage, output_storage, storage_map, cache
   1187 )
   1189 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)
   1190 res.nodes = self.node_order

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1102, in CLinker.__compile__(self, input_storage, output_storage, storage_map, cache)
   1100 input_storage = tuple(input_storage)
   1101 output_storage = tuple(output_storage)
-> 1102 thunk, module = self.cthunk_factory(
   1103     error_storage,
   1104     input_storage,
   1105     output_storage,
   1106     storage_map,
   1107     cache,
   1108 )
   1109 return (
   1110     thunk,
   1111     module,
   (...)   1124     error_storage,
   1125 )

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1626, in CLinker.cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, cache)
   1624     if cache is None:
   1625         cache = get_module_cache()
-> 1626     module = cache.module_from_key(key=key, lnk=self)
   1628 vars = self.inputs + self.outputs + self.orphans
   1629 # List of indices that should be ignored when passing the arguments
   1630 # (basically, everything that the previous call to uniq eliminated)

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/cmodule.py:1250, in ModuleCache.module_from_key(self, key, lnk)
   1248 try:
   1249     location = dlimport_workdir(self.dirname)
-> 1250     module = lnk.compile_cmodule(location)
   1251     name = module.__file__
   1252     assert name.startswith(location)

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/basic.py:1527, in CLinker.compile_cmodule(self, location)
   1525 try:
   1526     _logger.debug(f"LOCATION {location}")
-> 1527     module = c_compiler.compile_str(
   1528         module_name=mod.code_hash,
   1529         src_code=src_code,
   1530         location=location,
   1531         include_dirs=self.header_dirs(),
   1532         lib_dirs=self.lib_dirs(),
   1533         libs=libs,
   1534         preargs=preargs,
   1535     )
   1536 except Exception as e:
   1537     e.args += (str(self.fgraph),)

File /opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/cmodule.py:2676, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2668                 print(
   2669                     "Check if package python-dev or python-devel is installed."
   2670                 )
   2672     # We replace '\n' by '. ' in the error message because when Python
   2673     # prints the exception, having '\n' in the text makes it more
   2674     # difficult to read.
   2675     # compile_stderr = compile_stderr.replace("\n", ". ")
-> 2676     raise CompileError(
   2677         f"Compilation failed (return status={status}):\n{' '.join(cmd)}\n{compile_stderr}"
   2678     )
   2679 elif config.cmodule__compilation_warning and compile_stderr:
   2680     # Print errors just below the command line.
   2681     print(compile_stderr)

CompileError: Compilation failed (return status=1):
/opt/homebrew/Caskroom/miniconda/base/envs/prob/bin/clang++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -fPIC -undefined dynamic_lookup -ld64 -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/numpy/_core/include -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/include/python3.13 -I/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/pytensor/link/c/c_code -L/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib -fvisibility=hidden -o /Users/cankayser/.pytensor/compiledir_macOS-15.3.2-arm64-arm-64bit-Mach-O-arm-3.13.2-64/tmp0849k9x0/m7f5abb5c650b9a70348e698e2274cbebb540b453f324f64fe2522bfb278340b8.so /Users/cankayser/.pytensor/compiledir_macOS-15.3.2-arm64-arm-64bit-Mach-O-arm-3.13.2-64/tmp0849k9x0/mod.cpp
ld: -lto_library library filename must be 'libLTO.dylib'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Apply node that caused the error: Add(a, b)
Toposort index: 0
Inputs types: [TensorType(float64, shape=()), TensorType(float64, shape=())]

Backtrace when the node is created (use PyTensor flag traceback__limit=N to make it longer):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/ipykernel/zmqshell.py", line 549, in run_cell
    return super().run_cell(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/interactiveshell.py", line 3047, in run_cell
    result = self._run_cell(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/interactiveshell.py", line 3102, in _run_cell
    result = runner(coro)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/async_helpers.py", line 128, in _pseudo_sync_runner
    coro.send(None)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/interactiveshell.py", line 3306, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/interactiveshell.py", line 3489, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/prob/lib/python3.13/site-packages/IPython/core/interactiveshell.py", line 3549, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-72142c8dd972>", line 10, in <module>
    c = a + b

HINT: Use a linker other than the C linker to print the inputs' shapes and strides.
HINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.

PyTensor version information:

I'm running mac OS 15.3.2 on a 2022 Macbook Air with Apple Silicon M2.
I installed conda via homebrew and running the code in an ipython notebook from within VS Code.

below is the output of print(pytensor.config):

floatX ({'float16', 'float32', 'float64'})
Doc: Default floating-point precision for python casts.

Note: float16 support is experimental, use at your own risk.
Value: float64

warn_float64 ({'ignore', 'pdb', 'raise', 'warn'})
Doc: Do an action when a tensor variable with float64 dtype is created.
Value: ignore

pickle_test_value (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113f063c0>>)
Doc: Dump test values while pickling model. If True, test values will be dumped with model.
Value: True

cast_policy ({'custom', 'numpy+floatX'})
Doc: Rules for implicit type casting
Value: custom

device (cpu)
Doc: Default device for computations. only cpu is supported for now
Value: cpu

conv__assert_shape (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120668550>>)
Doc: If True, AbstractConv* ops will verify that user-provided shapes match the runtime shapes (debugging option, may slow down compilation)
Value: False

print_global_stats (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120668690>>)
Doc: Print some global statistics (time spent) at the end
Value: False

unpickle_function (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113f01480>>)
Doc: Replace unpickled PyTensor functions with None. This is useful to unpickle old graphs that pickled them when it shouldn't
Value: True

<pytensor.configparser.ConfigParam object at 0x113f06660>
Doc: Default compilation mode
Value: Mode

cxx (<class 'str'>)
Doc: The C++ compiler to use. Currently only g++ is supported, but supporting additional compilers should not be too difficult. If it is empty, no C++ code is compiled.
Value: /opt/homebrew/Caskroom/miniconda/base/envs/prob/bin/clang++

linker ({'c', 'vm', 'cvm', 'c|py', 'vm_nogc', 'c|py_nogc', 'py', 'cvm_nogc'})
Doc: Default linker used if the pytensor flags mode is Mode
Value: cvm

allow_gc (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113f01a70>>)
Doc: Do we default to delete intermediate results during PyTensor function calls? Doing so lowers the memory requirement, but asks that we reallocate memory at the next function call. This is implemented for the default linker, but may not work for all linkers.
Value: True

optimizer ({'o2', 'fast_run', 'o3', 'fast_compile', 'o4', 'merge', 'unsafe', 'None', 'o1'})
Doc: Default optimizer. If not None, will use this optimizer with the Mode
Value: o4

optimizer_verbose (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120630170>>)
Doc: Print information about rewrites that are applied during a graph transformation.
Value: False

optimizer_verbose_ignore (<class 'str'>)
Doc: Do not print information for rewrites with these names when optimizer_verbose is True. Separate names with ','
Value:

on_opt_error ({'ignore', 'pdb', 'raise', 'warn'})
Doc: What to do when an optimization crashes: warn and skip it, raise the exception, or fall into the pdb debugger.
Value: warn

nocleanup (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120601480>>)
Doc: Suppress the deletion of code files that did not compile cleanly
Value: False

on_unused_input ({'ignore', 'raise', 'warn'})
Doc: What to do if a variable in the 'inputs' list of pytensor.function() is not used in the graph.
Value: raise

gcc__cxxflags (<class 'str'>)
Doc: Extra compiler flags for gcc
Value:

cmodule__warn_no_version (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120602580>>)
Doc: If True, will print a warning when compiling one or more Op with C code that can't be cached because there is no c_code_cache_version() function associated to at least one of those Ops.
Value: False

cmodule__remove_gxx_opt (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x111e72950>>)
Doc: If True, will remove the -O* parameter passed to g++.This is useful to debug in gdb modules compiled by PyTensor.The parameter -g is passed by default to g++
Value: False

cmodule__compilation_warning (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113ea6f50>>)
Doc: If True, will print compilation warnings.
Value: False

cmodule__preload_cache (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113e53d40>>)
Doc: If set to True, will preload the C module cache at import time
Value: False

cmodule__age_thresh_use (<class 'int'>)
Doc: In seconds. The time after which PyTensor won't reuse a compile c module.
Value: 2073600

cmodule__debug (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120638500>>)
Doc: If True, define a DEBUG macro (if not exists) for any compiled C code.
Value: False

compile__wait (<class 'int'>)
Doc: Time to wait before retrying to acquire the compile lock.
Value: 5

compile__timeout (<class 'int'>)
Doc: In seconds, time that a process will wait before deciding to
override an existing lock. An override only happens when the existing
lock is held by the same owner and has not been 'refreshed' by this
owner for more than this period. Refreshes are done every half timeout
period for running processes.
Value: 120

tensor__cmp_sloppy (<class 'int'>)
Doc: Relax pytensor.tensor.math._allclose (0) not at all, (1) a bit, (2) more
Value: 0

lib__amdlibm (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113ef6970>>)
Doc: Use amd's amdlibm numerical library
Value: False

tensor__insert_inplace_optimizer_validate_nb (<class 'int'>)
Doc: -1: auto, if graph have less then 500 nodes 1, else 10
Value: -1

traceback__limit (<class 'int'>)
Doc: The number of stack to trace. -1 mean all.
Value: 8

traceback__compile_limit (<class 'int'>)
Doc: The number of stack to trace to keep during compilation. -1 mean all. If greater then 0, will also make us save PyTensor internal stack trace.
Value: 0

warn__ignore_bug_before ({'0.8', '1.0.1', '0.4.1', '0.9', '0.4', '1.0.3', '0.5', '1.0.4', 'None', '0.10', '0.3', '0.8.1', '0.7', '1.0', '0.8.2', '1.0.2', '1.0.5', 'all', '0.6'})
Doc: If 'None', we warn about all PyTensor bugs found by default. If 'all', we don't warn about PyTensor bugs found by default. If a version, we print only the warnings relative to PyTensor bugs found after that version. Warning for specific bugs can be configured with specific [warn] flags.
Value: 0.9

exception_verbosity ({'low', 'high'})
Doc: If 'low', the text of exceptions will generally refer to apply nodes with short names such as Elemwise{add_no_inplace}. If 'high', some exceptions will also refer to apply nodes with long descriptions like:
A. Elemwise{add_no_inplace}
B. log_likelihood_v_given_h
C. log_likelihood_h
Value: low

print_test_value (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113ef6c10>>)
Doc: If 'True', the eval of an PyTensor variable will return its test_value when this is available. This has the practical consequence that, e.g., in debugging my_var will print the same as my_var.tag.test_value when a test value is defined.
Value: False

compute_test_value ({'ignore', 'pdb', 'off', 'warn', 'raise'})
Doc: If 'True', PyTensor will run each op at graph build time, using Constants, SharedVariables and the tag 'test_value' as inputs to the function. This helps the user track down problems in the graph before it gets optimized.
Value: off

compute_test_value_opt ({'ignore', 'pdb', 'off', 'warn', 'raise'})
Doc: For debugging PyTensor optimization only. Same as compute_test_value, but is used during PyTensor optimization
Value: off

check_input (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120659090>>)
Doc: Specify if types should check their input in their C code. It can be used to speed up compilation, reduce overhead (particularly for scalars) and reduce the number of generated C files.
Value: True

NanGuardMode__nan_is_error (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x111ed7d10>>)
Doc: Default value for nan_is_error
Value: True

NanGuardMode__inf_is_error (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x111ed7950>>)
Doc: Default value for inf_is_error
Value: True

NanGuardMode__big_is_error (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113f25700>>)
Doc: Default value for big_is_error
Value: True

NanGuardMode__action ({'pdb', 'raise', 'warn'})
Doc: What NanGuardMode does when it finds a problem
Value: raise

DebugMode__patience (<class 'int'>)
Doc: Optimize graph this many times to detect inconsistency
Value: 10

DebugMode__check_c (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x113f257b0>>)
Doc: Run C implementations where possible
Value: True

DebugMode__check_py (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667430>>)
Doc: Run Python implementations where possible
Value: True

DebugMode__check_finite (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x1206674d0>>)
Doc: True -> complain about NaN/Inf results
Value: True

DebugMode__check_strides (<class 'int'>)
Doc: Check that Python- and C-produced ndarrays have same strides. On difference: (0) - ignore, (1) warn, or (2) raise error
Value: 0

DebugMode__warn_input_not_reused (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667570>>)
Doc: Generate a warning when destroy_map or view_map says that an op works inplace, but the op did not reuse the input for its output.
Value: True

DebugMode__check_preallocated_output (<class 'str'>)
Doc: Test thunks with pre-allocated memory as output storage. This is a list of strings separated by ":". Valid values are: "initial" (initial storage in storage map, happens with Scan),"previous" (previously-returned memory), "c_contiguous", "f_contiguous", "strided" (positive and negative strides), "wrong_size" (larger and smaller dimensions), and "ALL" (all of the above).
Value:

DebugMode__check_preallocated_output_ndim (<class 'int'>)
Doc: When testing with "strided" preallocated output memory, test all combinations of strides over that number of (inner-most) dimensions. You may want to reduce that number to reduce memory or time usage, but it is advised to keep a minimum of 2.
Value: 4

profiling__time_thunks (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667610>>)
Doc: Time individual thunks when profiling
Value: True

profiling__n_apply (<class 'int'>)
Doc: Number of Apply instances to print by default
Value: 20

profiling__n_ops (<class 'int'>)
Doc: Number of Ops to print by default
Value: 20

profiling__output_line_width (<class 'int'>)
Doc: Max line width for the profiling output
Value: 512

profiling__min_memory_size (<class 'int'>)
Doc: For the memory profile, do not print Apply nodes if the size
of their outputs (in bytes) is lower than this threshold
Value: 1024

profiling__min_peak_memory (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x1206676b0>>)
Doc: The min peak memory usage of the order
Value: False

profiling__destination (<class 'str'>)
Doc: File destination of the profiling output
Value: stderr

profiling__debugprint (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667750>>)
Doc: Do a debugprint of the profiled functions
Value: False

profiling__ignore_first_call (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x1206677f0>>)
Doc: Do we ignore the first call of an PyTensor function.
Value: False

on_shape_error ({'raise', 'warn'})
Doc: warn: print a warning and use the default value. raise: raise an error
Value: warn

openmp (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667890>>)
Doc: Allow (or not) parallel computation on the CPU with OpenMP. This is the default value used when creating an Op that supports OpenMP parallelization. It is preferable to define it via the PyTensor configuration file ~/.pytensorrc or with the environment variable PYTENSOR_FLAGS. Parallelization is only done for some operations that implement it, and even for operations that implement parallelism, each operation is free to respect this flag or not. You can control the number of threads used with the environment variable OMP_NUM_THREADS. If it is set to 1, we disable openmp in PyTensor by default.
Value: False

openmp_elemwise_minsize (<class 'int'>)
Doc: If OpenMP is enabled, this is the minimum size of vectors for which the openmp parallelization is enabled in element wise ops.
Value: 200000

optimizer_excluding (<class 'str'>)
Doc: When using the default mode, we will remove optimizer with these tags. Separate tags with ':'.
Value:

optimizer_including (<class 'str'>)
Doc: When using the default mode, we will add optimizer with these tags. Separate tags with ':'.
Value:

optimizer_requiring (<class 'str'>)
Doc: When using the default mode, we will require optimizer with these tags. Separate tags with ':'.
Value:

optdb__position_cutoff (<class 'float'>)
Doc: Where to stop earlier during optimization. It represent the position of the optimizer where to stop.
Value: inf

optdb__max_use_ratio (<class 'float'>)
Doc: A ratio that prevent infinite loop in EquilibriumGraphRewriter.
Value: 8.0

cycle_detection ({'regular', 'fast'})
Doc: If cycle_detection is set to regular, most inplaces are allowed,but it is slower. If cycle_detection is set to faster, less inplacesare allowed, but it makes the compilation faster.The interaction of which one give the lower peak memory usage iscomplicated and not predictable, so if you are close to the peakmemory usage, triyng both could give you a small gain.
Value: regular

check_stack_trace ({'off', 'log', 'raise', 'warn'})
Doc: A flag for checking the stack trace during the optimization process. default (off): does not check the stack trace of any optimization log: inserts a dummy stack trace that identifies the optimizationthat inserted the variable that had an empty stack trace.warn: prints a warning if a stack trace is missing and also a dummystack trace is inserted that indicates which optimization insertedthe variable that had an empty stack trace.raise: raises an exception if a stack trace is missing
Value: off

metaopt__verbose (<class 'int'>)
Doc: 0 for silent, 1 for only warnings, 2 for full output withtimings and selected implementation
Value: 0

unittests__rseed (<class 'str'>)
Doc: Seed to use for randomized unit tests. Special value 'random' means using a seed of None.
Value: 666

warn__round (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667930>>)
Doc: Warn when using tensor.round with the default mode. Round changed its default from half_away_from_zero to half_to_even to have the same default as NumPy.
Value: False

profile (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x1206679d0>>)
Doc: If VM should collect profile information
Value: False

profile_optimizer (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667a70>>)
Doc: If VM should collect optimizer profile information
Value: False

profile_memory (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667b10>>)
Doc: If VM should collect memory profile information and print it
Value: False

<pytensor.configparser.ConfigParam object at 0x120668e10>
Doc: Useful only for the VM Linkers. When lazy is None, auto detect if lazy evaluation is needed and use the appropriate version. If the C loop isn't being used and lazy is True, use the Stack VM; otherwise, use the Loop VM.
Value: None

numba__vectorize_target ({'cpu', 'parallel', 'cuda'})
Doc: Default target for numba.vectorize.
Value: cpu

numba__fastmath (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667bb0>>)
Doc: If True, use Numba's fastmath mode.
Value: True

numba__cache (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120667c50>>)
Doc: If True, use Numba's file based caching.
Value: True

compiledir_format (<class 'str'>)
Doc: Format string for platform-dependent compiled module subdirectory
(relative to base_compiledir). Available keys: device, gxx_version,
hostname, numpy_version, platform, processor, pytensor_version,
python_bitwidth, python_int_bitwidth, python_version, short_platform.
Defaults to compiledir_%(short_platform)s-%(processor)s-
%(python_version)s-%(python_bitwidth)s.
Value: compiledir_%(short_platform)s-%(processor)s-%(python_version)s-%(python_bitwidth)s

<pytensor.configparser.ConfigParam object at 0x120669090>
Doc: platform-independent root directory for compiled modules
Value: /Users/cankayser/.pytensor

<pytensor.configparser.ConfigParam object at 0x113f02190>
Doc: platform-dependent cache directory for compiled modules
Value: /Users/cankayser/.pytensor/compiledir_macOS-15.3.2-arm64-arm-64bit-Mach-O-arm-3.13.2-64

blas__ldflags (<class 'str'>)
Doc: lib[s] to include for [Fortran] level-3 blas implementation
Value:

blas__check_openmp (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x120861770>>)
Doc: Check for openmp library conflict.
WARNING: Setting this to False leaves you open to wrong results in blas-related operations.
Value: True

scan__allow_gc (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x124b7ca50>>)
Doc: Allow/disallow gc inside of Scan (default: False)
Value: False

scan__allow_output_prealloc (<bound method BoolParam._apply of <pytensor.configparser.BoolParam object at 0x124b7caf0>>)
Doc: Allow/disallow memory preallocation for outputs inside of scan (default: True)
Value: True

Context for the issue:

No response

@knods3k knods3k added the bug Something isn't working label Apr 7, 2025
@maresb
Copy link
Contributor

maresb commented Apr 7, 2025

Thanks for the report! I believe this is identical to #1342.

Could you post a message there mentioning if you're using JupyterLab, VS Code, or something else?

@knods3k
Copy link
Author

knods3k commented Apr 7, 2025

And I thank you for your effort. Yes, it seems to be the exact same issue, so I'll detail my setup there.

For cross-reference, the issue can be temporarilty fixed by deleting the conda installed c compiler using conda remove --force clang clangxx -n pymc_env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants