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 <michaelhan2050@gmail.com>
This commit is contained in:
Daniel Han 2026-06-22 02:28:30 -07:00 committed by GitHub
commit ad2546e592
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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