torchref.utils.debug_utils module

Debug utilities for multicopy_refinement modules.

Provides debugging and introspection functionality for all module classes.

class torchref.utils.debug_utils.DebugMixin[source]

Bases: object

Mixin class that adds debugging capabilities to modules.

When an error occurs, call print_debug_summary() to get a comprehensive overview of the module’s state including:

  • All attributes and their types

  • Tensor shapes, dtypes, and devices

  • DataFrame/array shapes

  • Other object information

print_debug_summary(title=None, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Print a comprehensive debug summary of this module’s state.

Parameters:
  • title (str, optional) – Title for the summary.

  • file (file-like, default sys.stderr) – File to write output to.

debug_on_error(error, context='', recursive=True)[source]

Print debug summary when an error occurs, recursively printing submodules.

Parameters:
  • error (Exception) – The exception that was caught.

  • context (str, default "") – Additional context string to print.

  • recursive (bool, default True) – If True, recursively print debug info for all submodules.

torchref.utils.debug_utils.print_module_summary(module, title=None, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Print debug summary for any module.

Standalone function to print debug information for modules that may or may not have the DebugMixin.

Parameters:
  • module (object) – The module to inspect.

  • title (str, optional) – Title for the summary.

  • file (file-like, default sys.stderr) – File to write output to.