Skip to content

Commit 75e8f99

Browse files
Add compiler_verbose config flag (#1520)
* Add compiler_verbose config flag * Add entry in `config.rst` for `compiler_verbose` --------- Co-authored-by: Jesse Grabowski <[email protected]>
1 parent 801845c commit 75e8f99

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

doc/library/config.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,15 @@ import ``pytensor`` and print the config variable, as in:
556556

557557
When ``True``, print the rewrites applied to stdout.
558558

559+
.. attribute:: compiler_verbose
560+
561+
Bool value: either ``True`` or ``False``
562+
563+
Default: ``False``
564+
565+
When ``True``, print detailed information about the compilation of a graph. The type of information printed will
566+
vary depending on the computational backend, and some backends may not provide additional information.
567+
559568
.. attribute:: nocleanup
560569

561570
Bool value: either ``True`` or ``False``

pytensor/configdefaults.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ def add_compile_configvars():
430430
in_c_key=False,
431431
)
432432

433+
config.add(
434+
"compiler_verbose",
435+
"Print information about compilation steps.",
436+
BoolParam(False),
437+
in_c_key=False,
438+
)
439+
433440
config.add(
434441
"on_opt_error",
435442
(

pytensor/configparser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class PyTensorConfigParser:
8282
optimizer: str
8383
optimizer_verbose: bool
8484
optimizer_verbose_ignore: str
85+
compiler_verbose: bool
8586
on_opt_error: str
8687
nocleanup: bool
8788
on_unused_input: str

pytensor/link/numba/dispatch/basic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,14 @@ def generate_fallback_impl(op, node=None, storage_map=None, **kwargs):
285285
"""Create a Numba compatible function from a Pytensor `Op`."""
286286

287287
warnings.warn(
288-
f"Numba will use object mode to run {op}'s perform method",
288+
f"Numba will use object mode to run {op}'s perform method. "
289+
f"Set `pytensor.config.compiler_verbose = True` to see more details.",
289290
UserWarning,
290291
)
291292

293+
if config.compiler_verbose:
294+
node.dprint(depth=5, print_type=True)
295+
292296
n_outputs = len(node.outputs)
293297

294298
if n_outputs > 1:

0 commit comments

Comments
 (0)