Silence torchao _C*.so load-failure WARNING on torch >= 2.11 (#6712)

On torch >= 2.11 torchao tries to dlopen each prebuilt _C*.so and logs a
per-file "Failed to load .../_C*.so" WARNING via the torchao logger when one
cannot load. This happens on an ABI tag mismatch in the prebuilt wheel (for
example a cp310 .so under a cp312 runtime, as on Colab) or when the kernel
targets an arch the GPU does not have (mxfp8 needs FP8 hardware, _C_cutlass_90a
is Hopper/SM90 only). torchao falls back to its non-cpp paths and Unsloth's
bnb-4bit / Triton kernels do not use these, so the warning is cosmetic.

Add a HideLoggingMessage filter on the same torchao logger that already filters
the torch < 2.11 "Skipping import of cpp extensions" message, so only these
records are dropped rather than raising the whole logger to ERROR.
This commit is contained in:
Daniel Han 2026-06-26 19:45:32 -07:00 committed by GitHub
parent b11966b2db
commit 101de1927a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -158,6 +158,11 @@ if not UNSLOTH_ENABLE_LOGGING:
logging.getLogger("torchao").addFilter(
HideLoggingMessage("Skipping import of cpp extensions due to incompatible torch version")
)
# torch >= 2.11 path: torchao dlopens each prebuilt _C*.so and logs "Failed to load
# .../_C*.so" when one can't (ABI tag mismatch in the wheel, e.g. a cp310 .so under a
# cp312 runtime on Colab, or an arch-specific kernel the GPU lacks). It falls back to
# non-cpp paths and Unsloth doesn't use these kernels, so drop the cosmetic record.
logging.getLogger("torchao").addFilter(HideLoggingMessage("Failed to load "))
# SyntaxWarning: invalid escape sequence '\.'
warnings.filterwarnings("ignore", message = "invalid escape sequence", category = SyntaxWarning)
# PYTORCH_CUDA_ALLOC_CONF is deprecated warning from torch