Skip to content

Fix missing logs when calling oneshot #1446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kelkelcheng
Copy link
Contributor

Fix missing logs when calling oneshot #1441

Summary:

When calling oneshot (e.g., in gemma2_example.py), a sparse_logs folder is created, but the log file inside is nearly empty. This is because the logging setup in lifecycle.py and state.py uses loguru, but oneshot itself didn’t configure loguru to write logs to a file. As a result, logs were not being saved properly.

This PR fixes the issue by adding a log file configuration directly in the oneshot init. This ensures loguru writes to the appropriate file by default.

To clean up the nearly empty log file, I removed the two lines from stage.py that were generating it. These messages appear to be redundant, as similar info is already captured by loguru.

Currently, I set the log path defaults to sparse_logs. Maybe we can consider making the log file path an optional input, allowing users to disable file logging by passing None. Let me know what you guys think.

Test Plan:

Ran gemma2_example.py after the changes:
A proper log file was generated in sparse_logs
The original nearly empty log file was no longer created

Also ran make test and got the same results as the current main.

Copy link

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

Copy link
Collaborator

@brian-dellabetta brian-dellabetta left a comment

Choose a reason for hiding this comment

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

Thanks @kelkelcheng for looking into this! One comment regarding your TODO, otherwise I think this looks great!

Copy link
Collaborator

@brian-dellabetta brian-dellabetta left a comment

Choose a reason for hiding this comment

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

thanks @kelkelcheng ! LGTM

@kylesayrs kylesayrs added the ready When a PR is ready for review label May 19, 2025
Copy link
Collaborator

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

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

Thank you! 🚀

@kylesayrs kylesayrs enabled auto-merge (squash) May 19, 2025 20:06
@brian-dellabetta
Copy link
Collaborator

Looks like tests are failing for an unrelated reason, will look into it and then we can merge this in

@kelkelcheng
Copy link
Contributor Author

Looks like tests are failing for an unrelated reason, will look into it and then we can merge this in

Got it, thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready When a PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants