Skip to content

Commit 79ff313

Browse files
authored
[Tests] Remove the compress entrypoint (#1317)
Summary - We no longer support the `compress` entrypoint, an alias to `apply` since landing the removal of the StageRunner - Update the test case to reflect this - Also update the recipe such that the constant pruning modifier reflects the layers being targeted by the SparseGPT Modifier. down_proj was missing, resulting in different sparsities
1 parent eb7c61c commit 79ff313

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

tests/llmcompressor/transformers/finetune/test_alternate_recipe.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test_train_stage:
1515
"re:.*self_attn.k_proj",
1616
"re:.*self_attn.v_proj",
1717
"re:.*self_attn.o_proj",
18+
"re:.*mlp.down_proj",
1819
"re:.*mlp.gate_proj",
1920
"re:.*mlp.up_proj"
2021
]

tests/llmcompressor/transformers/finetune/test_oneshot_and_finetune_with_tokenizer.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class TestOneshotAndFinetuneWithTokenizer(unittest.TestCase):
1818
dataset_config_name = None
1919

2020
def setUp(self):
21-
self.output = "./finetune_output"
21+
self.output = "./sparsity_finetune_output"
2222
# finetune workflows in general seem to have trouble with multi-gpus
2323
# use just one atm
2424

2525
def test_oneshot_and_finetune_with_tokenizer(self):
2626
from datasets import load_dataset
2727
from transformers import AutoModelForCausalLM, AutoTokenizer
2828

29-
from llmcompressor.transformers import compress
29+
from llmcompressor import oneshot, train
3030

3131
recipe_str = (
3232
"tests/llmcompressor/transformers/finetune/test_alternate_recipe.yaml"
@@ -47,23 +47,33 @@ def test_oneshot_and_finetune_with_tokenizer(self):
4747
max_steps = 50
4848
splits = {"train": "train[:50%]", "calibration": "train[50%:60%]"}
4949

50-
compress(
51-
model=model_loaded,
50+
model_and_data_kwargs = dict(
5251
dataset=dataset_loaded,
5352
dataset_config_name=self.dataset_config_name,
54-
run_stages=run_stages,
55-
output_dir=self.output,
5653
recipe=recipe_str,
57-
max_steps=max_steps,
5854
concatenate_data=concatenate_data,
5955
splits=splits,
6056
tokenizer=tokenizer,
57+
output_dir=self.output,
58+
)
59+
60+
oneshot_model = oneshot(
61+
model=model_loaded,
62+
**model_and_data_kwargs,
63+
stage="test_oneshot_stage",
64+
)
65+
finetune_model = train(
66+
run_stages=run_stages,
67+
model=oneshot_model,
68+
max_steps=max_steps,
69+
stage="test_train_stage",
70+
**model_and_data_kwargs,
6171
)
6272

6373
input_ids = tokenizer("Hello my name is", return_tensors="pt").input_ids.to(
6474
"cuda"
6575
)
66-
output = model_loaded.generate(input_ids, max_new_tokens=100)
76+
output = finetune_model.generate(input_ids, max_new_tokens=20)
6777
print(tokenizer.decode(output[0]))
6878

6979
def tearDown(self):

0 commit comments

Comments
 (0)