Repository navigation
Silence torchao _C*.so load-failure WARNING on torch >= 2.11 - #6712
Conversation
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.
There was a problem hiding this comment.
Code Review
This pull request adds a log filter to suppress cosmetic "Failed to load" warnings from the torchao logger when prebuilt shared libraries fail to load. The reviewer pointed out that the current filter is too broad and could suppress critical error messages, suggesting a more specific filter that checks for both "Failed to load" and ".so" in the log message.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # .../_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 ")) |
There was a problem hiding this comment.
Filtering out any log message containing "Failed to load " is overly broad and could accidentally suppress critical error messages from torchao (such as failing to load a model, config, or weights). Since the cosmetic warnings always refer to shared library (.so) files, we should make the filter more specific by ensuring it only suppresses messages that contain both "Failed to load" and ".so".
| logging.getLogger("torchao").addFilter(HideLoggingMessage("Failed to load ")) | |
| logging.getLogger("torchao").addFilter( | |
| lambda record: not ("Failed to load" in record.getMessage() and ".so" in record.getMessage()) | |
| ) |
Summary
Silences the cosmetic per-file torchao WARNING that shows up on
torch >= 2.11:This was reported when running the
Llama3.2 (1B and 3B) ConversationalColab notebook on a T4.Why it happens
On
torch >= 2.11,torchao/__init__.pystops taking the "Skipping import of cpp extensions" branch and insteaddlopens each prebuilt_C*.so, loggingFailed to load <path>/_C*.so: <error>per file that fails. The failures are expected here:cp310.soloaded under acp312runtime (the Colab case)._C_mxfp8needs FP8 hardware and_C_cutlass_90ais Hopper / SM90 only, so neither is usable on a T4.In all cases torchao falls back to its non-cpp paths, and Unsloth's bnb-4bit / Triton kernels do not use these extensions, so the warning is purely cosmetic.
Fix
import_fixes.pyalready filters the sibling torch < 2.11 message (Skipping import of cpp extensions) on thetorchaologger. TheFailed to load ...warning comes from that sametorchaologger, so this adds one moreHideLoggingMessagefilter next to it:This drops only those records rather than raising the whole logger to
ERROR, and it stays under the existingif not UNSLOTH_ENABLE_LOGGING:guard, soUNSLOTH_ENABLE_LOGGING=1still surfaces everything.Testing
import_fixes.pyparses viaast.parseand byte-compiles viapy_compile.torchaologger confirms bothFailed to load .../_C*.sorecords are suppressed, the existingSkipping import of cpp extensionsrecord stays suppressed, and an unrelatedtorchaowarning still passes through.