1+ from typing import Optional
12
2- from typing import Optional , Tuple
3-
4- from loguru import logger
53from torch .utils .data import DataLoader
64from transformers import PreTrainedModel
75
86from llmcompressor .args import parse_args
97from llmcompressor .core .session_functions import active_session
8+ from llmcompressor .datasets import get_calibration_dataloader
109from llmcompressor .entrypoints .utils import post_process , pre_process
11- from llmcompressor .transformers .finetune .data .data_helpers import (
12- get_calibration_dataloader ,
13- )
14- from llmcompressor .transformers .utils .helpers import resolve_processor_from_model_args
15-
1610
1711__all__ = ["Oneshot" , "oneshot" ]
1812
@@ -68,7 +62,7 @@ class Oneshot:
6862 Initializes the `Oneshot` object by parsing input arguments, performing
6963 preprocessing, and setting instance attributes.
7064
71- run (**kwargs):
65+ __call__ (**kwargs):
7266 Performs the one-shot calibration process by preparing a calibration
7367 dataloader, applying recipe modifiers to the model, and executing
7468 postprocessing steps.
@@ -83,17 +77,6 @@ class Oneshot:
8377 defined in the recipe. Each action is executed via the global
8478 `CompressionSession`.
8579
86- _pre_process():
87- Handles preprocessing steps, including model initialization,
88- tokenizer/processor setup, and resolving tied embedding issues.
89-
90- check_tied_embeddings():
91- Logs a warning if `tie_word_embeddings=True`, which may interfere with
92- saving in the one-shot workflow.
93-
94- _post_process():
95- Executes postprocessing steps such as saving the model and resetting
96- lifecycle actions, especially when a custom `output_dir` is specified.
9780 """
9881
9982 def __init__ (
@@ -182,23 +165,6 @@ def __call__(self):
182165 )
183166 post_process (model_args = self .model_args , output_dir = self .output_dir )
184167
185- def save (self ):
186- """
187- Saves the model and tokenizer/processor to the output directory.
188-
189- The model is saved in a compressed format if specified in `model_args`.
190- The tokenizer or processor, if available, is also saved.
191-
192- Raises:
193- ValueError: If saving fails due to an invalid `output_dir` or other issues.
194- """
195- self .model .save_pretrained (
196- self .output_dir ,
197- save_compressed = self .model_args .save_compressed ,
198- )
199- if self .processor is not None :
200- self .processor .save_pretrained (self .output_dir )
201-
202168 def apply_recipe_modifiers (
203169 self ,
204170 calibration_dataloader : Optional [DataLoader ],
0 commit comments