Skip to content

Commit dfd7e05

Browse files
committed
Merge remote-tracking branch 'origin' into kylesayrs/consolidate-saving
2 parents f2411ed + ffd3ef9 commit dfd7e05

File tree

8 files changed

+15
-77
lines changed

8 files changed

+15
-77
lines changed

src/llmcompressor/args/dataset_arguments.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CustomDatasetArguments(DVCDatasetArguments):
7070
class DatasetArguments(CustomDatasetArguments):
7171
"""
7272
Arguments pertaining to what data we are going to input our model for
73-
calibration, training or eval
73+
calibration, training
7474
7575
Using `HfArgumentParser` we can turn this class into argparse
7676
arguments to be able to specify them on the command line
@@ -150,13 +150,6 @@ class DatasetArguments(CustomDatasetArguments):
150150
"of training examples to this value if set."
151151
},
152152
)
153-
max_eval_samples: Optional[int] = field(
154-
default=None,
155-
metadata={
156-
"help": "For debugging purposes or quicker training, truncate the number "
157-
"of evaluation examples to this value if set."
158-
},
159-
)
160153
max_predict_samples: Optional[int] = field(
161154
default=None,
162155
metadata={

src/llmcompressor/transformers/finetune/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from .data import TextGenerationDataset
44
from .session_mixin import SessionManagerMixIn
5-
from .text_generation import apply, compress, eval, oneshot, train
5+
from .text_generation import apply, compress, oneshot, train

src/llmcompressor/transformers/finetune/data/data_helpers.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,15 @@ def get_raw_dataset(
9797
def make_dataset_splits(
9898
tokenized_datasets: Dict[str, Any],
9999
do_train: bool = False,
100-
do_eval: bool = False,
101100
do_predict: bool = False,
102101
do_oneshot: bool = False,
103102
) -> Dict[str, Dataset]:
104103
"""
105104
Restructures the datasets dictionary based on what tasks will be run
106-
(train, eval, predict)
105+
(train, predict)
107106
108107
:param tokenized_datasets: dictionary of processed datasets
109108
:param do_train: Whether to store the train dataset
110-
:param do_eval: Whether to store the validation dataset
111109
:param do_predict: Whether to store the test dataset
112110
:param do_oneshot: Whether to store the calibration dataset
113111
:return: Datasets to be used by the requested tasks
@@ -119,16 +117,12 @@ def make_dataset_splits(
119117
if isinstance(tokenized_datasets, Dataset):
120118
tokenized_datasets = {"train": tokenized_datasets}
121119

122-
train_split = eval_split = predict_split = calib_split = None
120+
train_split = predict_split = calib_split = None
123121

124122
if do_train:
125123
if "train" not in tokenized_datasets:
126124
raise ValueError("--do_train requires a train dataset")
127125
train_split = tokenized_datasets["train"]
128-
if do_eval:
129-
if "validation" not in tokenized_datasets:
130-
raise ValueError("--do_eval requires a validation dataset")
131-
eval_split = tokenized_datasets["validation"]
132126
if do_predict:
133127
if "test" not in tokenized_datasets:
134128
raise ValueError("--do_predict requires a test dataset")
@@ -142,7 +136,6 @@ def make_dataset_splits(
142136

143137
split_datasets = {
144138
"train": train_split,
145-
"validation": eval_split,
146139
"test": predict_split,
147140
"calibration": calib_split,
148141
}
@@ -222,7 +215,7 @@ def transform_dataset_keys(data_files: Dict[str, Any]):
222215
Transform dict keys to `train`, `val` or `test` for the given input dict
223216
if matches exist with the existing keys. Note that there can only be one
224217
matching file name.
225-
Ex. Folder(train_eval.json) -> Folder(train.json)
218+
Ex. Folder(train_foo.json) -> Folder(train.json)
226219
Folder(train1.json, train2.json) -> Same
227220
228221
:param data_files: The dict where keys will be transformed

src/llmcompressor/transformers/finetune/runner.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232
class StageRunner:
3333
"""
34-
Launcher class for train, eval and one_shot flows. Manages data splits for each
34+
Launcher class for train, and one_shot flows. Manages data splits for each
3535
flow and configurations. In the future this class will also handle alternating
3636
between the different flows
3737
3838
LifeCycle
3939
- populate_datasets()
4040
- set_trainer()
41-
- train() / evaluate() / predict()
41+
- train() / predict()
4242
4343
:param model_args: Arguments pertaining to model/config/processor
4444
:param data_args: Arguments pertaining to what data to use for different flows
@@ -121,7 +121,6 @@ def _get_split_name(inp_str):
121121
self.datasets = make_dataset_splits(
122122
tokenized_datasets,
123123
do_train=self._training_args.do_train,
124-
do_eval=self._training_args.do_eval,
125124
do_predict=self._training_args.do_predict,
126125
do_oneshot=self._training_args.do_oneshot,
127126
)
@@ -156,17 +155,6 @@ def train(self, checkpoint: str, stage: Optional[str] = None):
156155
# this includes saving the state, optimizer and scheduler
157156
self.trainer.save_model(output_dir=self._output_dir)
158157

159-
def evaluate(self):
160-
"""
161-
Run trainer's evaluation loop on eval_dataset, logging the desired metrics
162-
"""
163-
logger.info("*** Evaluate ***")
164-
metrics = self.trainer.evaluate(self.get_dataset_split("validation"))
165-
166-
metrics["eval_samples"] = len(self.get_dataset_split("validation"))
167-
self.trainer.log_metrics("eval", metrics)
168-
self.trainer.save_metrics("eval", metrics)
169-
170158
def predict(self):
171159
"""
172160
Run trainer's prediction loop on predict_dataset, logging the desired metrics

src/llmcompressor/transformers/finetune/session_mixin.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
TRAINER_STATE_NAME = "trainer_state.json"
4343
METADATA_ARGS = [
4444
"per_device_train_batch_size",
45-
"per_device_eval_batch_size",
4645
"max_seq_length",
4746
"save_safetensors",
4847
"fp16",
@@ -406,22 +405,6 @@ def train(self, *args, stage: Optional[str] = None, **kwargs):
406405

407406
return output
408407

409-
def evaluate(self, *args, **kwargs):
410-
"""
411-
Run a sparsification evaluation cycle.
412-
Runs initialize_structure for the sparse session before calling
413-
super().evaluate() and finalization of the session after.
414-
:param args: positional args to pass to super().evaluate()
415-
:param kwargs: keyword args to pass to super().evaluate()
416-
:return: the output from super.evaluate()
417-
"""
418-
self.initialize_structure()
419-
420-
output = super().evaluate(*args, **kwargs)
421-
self.finalize_session()
422-
423-
return output
424-
425408
def predict(self, *args, **kwargs):
426409
"""
427410
Run a sparsification prediction cycle.

src/llmcompressor/transformers/finetune/text_generation.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def oneshot(**kwargs) -> None:
9898

9999
def apply(**kwargs):
100100
"""
101-
CLI entrypoint for any of training, eval, predict or oneshot
101+
CLI entrypoint for any of training, predict or oneshot
102102
"""
103103
report_to = kwargs.get("report_to", None)
104104
model_args, data_args, recipe_args, training_args = parse_args(**kwargs)
@@ -323,12 +323,12 @@ def main(
323323
- Trainer()
324324
- SessionMixIn()
325325
- HFTransformersTrainer()
326-
- StageRunner.train() and/or evaluate() and/or predict() and/or oneshot()
326+
- StageRunner.train() and/or predict() and/or oneshot()
327327
328328
:param model_args: Arguments pertaining to which model/config/tokenizer we are
329329
going to fine-tune from
330330
:param data_args: Arguments pertaining to what data we are going to input our model
331-
for training and eval
331+
for training
332332
:param training_args: Arguments pertaining to training loop configuration
333333
"""
334334

@@ -358,7 +358,7 @@ def main(
358358
f"distributed training: {bool(training_args.local_rank != -1)}, "
359359
f"16-bits training: {training_args.fp16}"
360360
)
361-
logger.info(f"Training/evaluation parameters {training_args}")
361+
logger.info(f"Training parameters {training_args}")
362362

363363
# Detecting last checkpoint.
364364
last_checkpoint = None
@@ -397,7 +397,6 @@ def main(
397397
add_labels = training_args.do_train or training_args.run_stages
398398
stage_runner.populate_datasets(processor=processor, add_labels=add_labels)
399399
train_dataset = stage_runner.get_dataset_split("train")
400-
eval_dataset = stage_runner.get_dataset_split("validation")
401400
calib_dataset = stage_runner.get_dataset_split("calibration")
402401

403402
trainer = Trainer(
@@ -409,7 +408,6 @@ def main(
409408
model_args=model_args,
410409
data_args=data_args,
411410
train_dataset=train_dataset or calib_dataset,
412-
eval_dataset=eval_dataset,
413411
processing_class=processor,
414412
data_collator=data_args.data_collator,
415413
)
@@ -443,10 +441,6 @@ def main(
443441
checkpoint = last_checkpoint
444442
stage_runner.train(checkpoint)
445443

446-
# Evaluation
447-
if training_args.do_eval:
448-
stage_runner.evaluate()
449-
450444
# Prediction
451445
if training_args.do_predict:
452446
stage_runner.predict()

tests/llmcompressor/transformers/finetune/data/test_dataset_helpers.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,12 @@ def test_combined_datasets():
1515
raw_wikitext2 = get_raw_dataset(data_args)
1616
datasets = {"all": raw_wikitext2}
1717

18-
split_datasets = make_dataset_splits(
19-
datasets, do_train=True, do_eval=True, do_predict=True
20-
)
18+
split_datasets = make_dataset_splits(datasets, do_train=True, do_predict=True)
2119
assert split_datasets.get("train") is not None
22-
assert split_datasets.get("validation") is not None
2320
assert split_datasets.get("test") is not None
2421

25-
split_datasets = make_dataset_splits(
26-
datasets, do_train=True, do_eval=False, do_predict=True
27-
)
22+
split_datasets = make_dataset_splits(datasets, do_train=True, do_predict=True)
2823
assert split_datasets.get("train") is not None
29-
assert split_datasets.get("validation") is None
3024
assert split_datasets.get("test") is not None
3125

3226

@@ -41,15 +35,10 @@ def test_separate_datasets():
4135
raw_wikitext2 = get_raw_dataset(data_args, split=split_str)
4236
datasets[split_name] = raw_wikitext2
4337

44-
split_datasets = make_dataset_splits(
45-
datasets, do_train=True, do_eval=True, do_predict=False
46-
)
38+
split_datasets = make_dataset_splits(datasets, do_train=True, do_predict=False)
4739
assert split_datasets.get("train") is not None
48-
assert split_datasets.get("validation") is not None
4940
assert split_datasets.get("test") is None
5041

5142
with pytest.raises(ValueError):
5243
# fails due to no test split specified
53-
split_datasets = make_dataset_splits(
54-
datasets, do_train=True, do_eval=True, do_predict=True
55-
)
44+
split_datasets = make_dataset_splits(datasets, do_train=True, do_predict=True)

tests/llmcompressor/transformers/finetune/test_session_mixin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ def mixin_trainer():
4949
model = AutoModelForCausalLM.from_pretrained(model_state_path)
5050
recipe = "tests/llmcompressor/transformers/finetune/test_quantization.yaml"
5151
train_dataset = "open-platypus"
52-
eval_dataset = "open-platypus"
5352

5453
return MixInTest(
5554
model=model,
5655
recipe=recipe,
5756
train_dataset=train_dataset,
58-
eval_dataset=eval_dataset,
5957
)
6058

6159

0 commit comments

Comments
 (0)