torch._logging.set_logs — PyTorch 2.7 documentation (original) (raw)

torch._logging.set_logs(*, all=None, dynamo=None, aot=None, autograd=None, dynamic=None, inductor=None, distributed=None, c10d=None, ddp=None, fsdp=None, dtensor=None, onnx=None, bytecode=False, aot_graphs=False, aot_joint_graph=False, ddp_graphs=False, graph=False, graph_code=False, graph_breaks=False, graph_sizes=False, guards=False, recompiles=False, recompiles_verbose=False, trace_source=False, trace_call=False, trace_bytecode=False, output_code=False, kernel_code=False, schedule=False, perf_hints=False, pre_grad_graphs=False, post_grad_graphs=False, ir_pre_fusion=False, ir_post_fusion=False, onnx_diagnostics=False, fusion=False, overlap=False, export=None, modules=None, cudagraphs=False, sym_node=False, compiled_autograd=False, compiled_autograd_verbose=False, cudagraph_static_inputs=False, benchmarking=False, autotuning=False, graph_region_expansion=False)[source][source]

Sets the log level for individual components and toggles individual log artifact types.

Warning

This feature is a prototype and may have compatibility breaking changes in the future.

Note

The TORCH_LOGS environment variable has complete precedence over this function, so if it was set, this function does nothing.

A component is a set of related features in PyTorch. All of the log messages emitted from a given component have their own log levels. If the log level of a particular message has priority greater than or equal to its component’s log level setting, it is emitted. Otherwise, it is suppressed. This allows you to, for instance, silence large groups of log messages that are not relevant to you and increase verbosity of logs for components that are relevant. The expected log level values, ordered from highest to lowest priority, are:

See documentation for the Python logging module for more information on log levels: https://docs.python.org/3/library/logging.html#logging-levels

An artifact is a particular type of log message. Each artifact is assigned to a parent component. A component can emit many different kinds of artifacts. In general, an artifact is emitted if either its corresponding setting in the argument list below is turned on or if its parent component is set to a log level less than or equal to the log level of the artifact.

Keyword Arguments

Example:

import logging

The following changes the "dynamo" component to emit DEBUG-level

logs, and to emit "graph_code" artifacts.

torch._logging.set_logs(dynamo=logging.DEBUG, graph_code=True)

The following enables the logs for a different module

torch._logging.set_logs(modules={"unregistered.module.name": logging.DEBUG})