From ad2546e5929e4e527eb17bb06264cc2c84f296bb Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 22 Jun 2026 02:28:30 -0700 Subject: [PATCH] Suppress only torchao's cosmetic cpp-extensions warning (#6506) * Suppress only torchao's cosmetic cpp-extensions warning torchao logs a cosmetic WARNING on torch < 2.11 from torchao/__init__.py (logger.warning("Skipping import of cpp extensions due to incompatible torch version...")). The bnb-4bit and Unsloth paths do not use torchao's cpp kernels, so the message is noise. The quiet block raised the whole torchao logger to ERROR, which also hid any genuine torchao warning, plus a redundant stderr substring filter. Replace both with a HideLoggingMessage logging filter scoped to the torchao logger that drops only this one record, leaving every other torchao log intact. * torchao cpp-extensions filter: tighten comment (no code change) --------- Co-authored-by: danielhanchen --- unsloth/import_fixes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py index ffbc24362f..5afd6f4b37 100644 --- a/unsloth/import_fixes.py +++ b/unsloth/import_fixes.py @@ -152,10 +152,12 @@ if not UNSLOTH_ENABLE_LOGGING: sys.stderr.add_filter("CUTE_INVALID_CONTROL_PATH") # CUTLASS TMA-related errors when not targeting correct architecture sys.stderr.add_filter("Trying to use tma without CUTE_ARCH_TMA") - # Skipping import of cpp extensions due to incompatible torch version 2.9.0+cu128 for torchao version 0.15.0 - logging.getLogger("torchao").setLevel(logging.ERROR) - # Also filter torchao print to stderr about cpp extensions - sys.stderr.add_filter("Skipping import of cpp extensions") + # torchao logs a cosmetic "Skipping import of cpp extensions" WARNING on torch < 2.11. The + # bnb-4bit / Unsloth paths don't use torchao's cpp kernels, so drop only that record rather + # than raising the whole torchao logger to ERROR. + logging.getLogger("torchao").addFilter( + HideLoggingMessage("Skipping import of cpp extensions due to incompatible torch version") + ) # SyntaxWarning: invalid escape sequence '\.' warnings.filterwarnings("ignore", message = "invalid escape sequence", category = SyntaxWarning) # PYTORCH_CUDA_ALLOC_CONF is deprecated warning from torch