Skip to content
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

[Bugfix] Staged 2of4 example #1238

Merged
merged 4 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion src/llmcompressor/recipe/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _check_compile_recipe(self):

:return: True if the recipes were compiled, False otherwise
"""
if self.compiled_recipe is None and self.recipes:
if self.recipes:
self.compiled_recipe = Recipe.simplify_combine_recipes(self.recipes)

def check_any_recipe_exists(self) -> bool:
Expand Down
9 changes: 6 additions & 3 deletions src/llmcompressor/transformers/finetune/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from llmcompressor.core import active_session
from llmcompressor.pytorch.model_load.helpers import (
get_completed_stages,
get_session_model,
save_checkpoint,
save_completed_stages,
)
Expand Down Expand Up @@ -183,6 +182,10 @@ def run_sequential_stages(
"the stage name."
)

# skip stages which have already been applied
if stage_name in completed_stages:
continue

# setup checkpoint dir, TODO: this should be optional
self._output_dir = os.path.join(
self.parent_output_dir, "stage_" + stage_name
Expand Down Expand Up @@ -222,6 +225,7 @@ def run_sequential_stages(
recipe_stage=stage_name,
)
elif run_type is StageRunType.TRAIN:
self.trainer.model = model
self.train(checkpoint=checkpoint, stage=stage_name)

checkpoint = None
Expand All @@ -248,11 +252,10 @@ def run_sequential_stages(

# setup for next stage
session = active_session()
session.reset_stage()
session.reset()

# synchronize and clean up memory
self.trainer.accelerator.wait_for_everyone()
self.trainer.model = get_session_model()
torch.cuda.empty_cache()
self.trainer.accelerator.free_memory()
self.trainer.accelerator.wait_for_everyone()
Loading