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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/llmcompressor/entrypoints/oneshot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
from datetime import datetime
from typing import Optional

from loguru import logger
from torch.utils.data import DataLoader
from transformers import PreTrainedModel

Expand Down Expand Up @@ -100,6 +103,15 @@ def __init__(
:param output_dir: Path to save the output model after carrying out oneshot

"""
base_log_path = "sparse_logs" # TODO: maybe make this an input argument?
if base_log_path:
os.makedirs(base_log_path, exist_ok=True)
date_str = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
logger.add(
f"{base_log_path}/oneshot_{date_str}.log",
level="DEBUG",
)

model_args, dataset_args, recipe_args, _, output_dir = parse_args(**kwargs)

self.model_args = model_args
Expand Down
2 changes: 0 additions & 2 deletions src/llmcompressor/modifiers/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def initialize(self, state: "State", **kwargs):
modifier.initialize(state, **kwargs)
if accelerator:
accelerator.wait_for_everyone()
state.loggers.system.info(tag="stage", string="Modifiers initialized")

def finalize(self, state: "State", **kwargs):
"""
Expand All @@ -88,7 +87,6 @@ def finalize(self, state: "State", **kwargs):
accelerator.wait_for_everyone()

self.applied = True
state.loggers.system.info(tag="stage", string="Modifiers finalized")

def update_event(self, state: "State", event: "Event", **kwargs):
"""
Expand Down