Skip to content

Fix logging call that hides why torch.compile failed - #1387

Open
David-Wu1119 wants to merge 1 commit into
huggingface:mainfrom
David-Wu1119:fix-compile-warning-logging
Open

David-Wu1119 wants to merge 1 commit into
huggingface:mainfrom
David-Wu1119:fix-compile-warning-logging

Conversation

@David-Wu1119

Copy link
Copy Markdown

When config.compile is set and model.compile() raises AttributeError, the warning that should explain why is never logged:

except AttributeError as e:
    logger.warning("Could not compile the model because: ", e)

The message has no placeholder, so logging treats e as an unused argument and raises while formatting the record. The user gets a --- Logging error --- traceback on stderr instead of the warning, and the actual reason is dropped:

--- Logging error ---
Traceback (most recent call last):
  ...
  File ".../logging/__init__.py", line 400, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Message: 'Could not compile the model because: '
Arguments: (AttributeError(...),)

With %s the record is emitted normally:

WARNING Could not compile the model because: 'X' object has no attribute 'compile'

ruff check and ruff format --check pass on the file.

🤖 Generated with Claude Code

logger.warning("Could not compile the model because: ", e) passes the
exception as a logging argument for a message with no placeholder, so
logging raises internally: the warning is never emitted and stderr gets a
"--- Logging error ---" traceback instead. The reason compilation failed,
which is the point of the message, is lost.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 05:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants