Skip to content

Commit

Permalink
[CI] [FIX] used wrong tokenizer get dataset (ModelCloud#171)
Browse files Browse the repository at this point in the history
* fix not defined error

* fix test_perplexity fail

* modify dataset filter text length

* modify assert the difference of ppl

* modify dataset filter with text length

* fix use wrong tokenizer get dataset

* simplify code
  • Loading branch information
ZYC-ModelCloud authored Jul 5, 2024
1 parent 87ef93f commit 61191d5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/test_perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def calculate_native_ppl(self, tokenizer, format):

length = 512 if format == FORMAT.MARLIN or format == FORMAT.BITBLAS else 2048
traindata = load_dataset(dataset_path, dataset_name, split=dataset_split).filter(lambda x: len(x[dataset_column]) >= length)
calibration_dataset = [self.tinyllama_tokenizer(example[dataset_column]) for example in traindata.select(range(1024))]
calibration_dataset = [tokenizer(example[dataset_column]) for example in traindata.select(range(1024))]
return calibration_dataset, native_ppl

@parameterized.expand(
Expand All @@ -101,12 +101,9 @@ def test_quantized_perplexity(self, format: FORMAT):
bits=4,
group_size=128,
format=format,
desc_act=False if format == FORMAT.MARLIN else True
)

if format == FORMAT.MARLIN or format == FORMAT.BITBLAS:
# MARLIN and BITBLAS Only supported when desc_act is False.
quantize_config.desc_act = False
desc_act=False if format == FORMAT.MARLIN or format == FORMAT.BITBLAS else True
)

model = GPTQModel.from_pretrained(
self.OPT_MODEL_ID if format == FORMAT.MARLIN or format == FORMAT.BITBLAS else self.TINYLLAMA_MODEL_ID,
Expand Down Expand Up @@ -134,9 +131,9 @@ def test_quantized_perplexity(self, format: FORMAT):

# 4090: [wikitext-2-raw-v1, test, text, 512, 512] data split
# FORMAT.GTPQ and FORMAT.GTPQ_V2 Tinyllama ppl == 8.7863, FORMAT.MARLIN Tinyllama ppl == 9.0036
# FORMAT.MARLIN opt ppl == 34.85, FORMAT.BITBLAS opt ppl == 34.11, native opt ppl == 30.39
# FORMAT.MARLIN opt ppl == 33.43, FORMAT.BITBLAS opt ppl == 32.61, native opt ppl == 30.39
# FORMAT.GTPQ and FORMAT.GTPQ_V2 Tinyllama-15M ppl == 111.32, native Tinyllama-15M ppl == 54.61
if format == FORMAT.MARLIN or format == FORMAT.BITBLAS:
assert abs(quantized_ppl - self.opt_native_ppl) < 4.7
assert abs(quantized_ppl - self.opt_native_ppl) < 3.5
else:
assert abs(quantized_ppl - self.tinyllama_native_ppl) < 56.8

0 comments on commit 61191d5

Please sign in to comment.