PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
Refactor evaluation in tests to use evaluate_accuracy function (#1402)
Xin He70a6bcc231af
diff --git a/test/helpers.py b/test/helpers.pyindex efd04dff5..8558fbd1b 100644--- a/test/helpers.py+++ b/test/helpers.py@@ -1,16 +1,75 @@import copyimport os+import reimport pytestimport torchimport transformersfrom packaging import version+from auto_round.eval.evaluation import simple_evaluate, simple_evaluate_user_modelfrom auto_round.utils import get_attr, llm_load_model, mllm_load_model, set_attrtransformers_version = version.parse(transformers.__version__)+def generate_prompt(model, tokenizer, text="There is a girl who likes adventure,", max_new_tokens=50):+ """Generate text using a model and tokenizer.++ Args:+ model: The model to use for generation.+ tokenizer: The tokenizer for the model.+ text: The input prompt text.+ max_new_tokens: Maximum number of new tokens to generate.++ Returns:+ str: The generated text.+ """+ inputs = tokenizer(text, return_tensors="pt").to(model.device)+ output = tokenizer.decode(model.generate(**inputs, max_new_tokens=max_new_tokens)[0])+ print(output)+ return output+++def evaluate_accuracy(+ model_or_save_dir, tokenizer=None, task="lambada_openai", threshold=0.25, batch_size="auto", limit=None+):+ """Helper function to evaluate model accuracy on a given task.++ Supports both saved model directory and in-memory model object.++ Args:+ model_or_save_dir: Either a path to the saved model directory (str) or a model object.+ tokenizer: The tokenizer for the model (required when model_or_save_dir is a model object).+ task: The evaluation task.+ threshold: The minimum accuracy threshold.+ batch_size: Batch size for evaluation.+ limit: Limit the number of samples to evaluate (only for model object).++ Returns:+ float: The accuracy value.++ Raises:+ AssertionError: If accuracy is below threshold.+ """+ if isinstance(model_or_save_dir, str):+ # save_dir mode+ model_args = f"pretrained={model_or_save_dir}"+ result = simple_evaluate(model="hf", model_args=model_args, tasks=task, batch_size=batch_size)+ else:+ # model object mode+ if tokenizer is None:+ raise ValueError("tokenizer is required when model_or_save_dir is a model object")+ result = simple_evaluate_user_model(+ model_or_save_dir, tokenizer, batch_size=batch_size, tasks=task, limit=limit+ )++ acc = result["results"][task]["acc,none"]+ print(f"{task} accuracy: {acc}")+ assert acc > threshold, f"Accuracy {acc} is below threshold {threshold}"+ return acc++# Automatic choose local path or model name.def get_model_path(model_name: str) -> str:model_name = model_name.rstrip("/")diff --git a/test/test_ark/test_model.py b/test/test_ark/test_model.pyindex 5fa30ae2c..a82a2c7ee 100644--- a/test/test_ark/test_model.py+++ b/test/test_ark/test_model.py@@ -6,9 +6,8 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_model-from ..helpers import get_model_path, model_infer+from ..helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRoundARKBackend:@@ -50,9 +49,7 @@ class TestAutoRoundARKBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=32, tasks="lambada_openai", limit=limit)- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > tar_acc+ evaluate_accuracy(model, tokenizer, threshold=tar_acc, batch_size=32, limit=limit)torch.xpu.empty_cache()shutil.rmtree(self.save_folder, ignore_errors=True)diff --git a/test/test_cpu/backends/test_torch_backend.py b/test/test_cpu/backends/test_torch_backend.pyindex ce4bc0049..814dc08ee 100644--- a/test/test_cpu/backends/test_torch_backend.py+++ b/test/test_cpu/backends/test_torch_backend.py@@ -5,10 +5,9 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.testing_utils import require_autogptq, require_gptqmodel-from ...helpers import get_model_path, model_infer+from ...helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRoundTorchBackend:@@ -47,9 +46,7 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai", limit=10)- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16, limit=10)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -58,9 +55,7 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai", limit=10)- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16, limit=10)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -88,8 +83,6 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=32, tasks="lambada_openai", limit=1000)- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.28+ evaluate_accuracy(model, tokenizer, threshold=0.28, batch_size=32, limit=1000)torch.cuda.empty_cache()shutil.rmtree(self.save_folder, ignore_errors=True)diff --git a/test/test_cpu/core/test_autoround.py b/test/test_cpu/core/test_autoround.pyindex 4a4058ca9..0a2847d0a 100644--- a/test/test_cpu/core/test_autoround.py+++ b/test/test_cpu/core/test_autoround.py@@ -7,10 +7,16 @@ from packaging import versionfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.utils import get_module-from ...helpers import get_model_path, model_infer, opt_name_or_path, qwen_name_or_path, transformers_version+from ...helpers import (+ evaluate_accuracy,+ get_model_path,+ model_infer,+ opt_name_or_path,+ qwen_name_or_path,+ transformers_version,+)class TestAutoRound:@@ -117,11 +123,7 @@ class TestAutoRound:act_data_type="mx_fp_rceil",)model, _ = autoround.quantize()- result = simple_evaluate_user_model(- model, self.tokenizer, batch_size="auto:8", tasks="lambada_openai", limit=32- )- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.3 # 0.375+ evaluate_accuracy(model, self.tokenizer, threshold=0.3, batch_size="auto:8", limit=32)def test_nv_fp4(self, dataloader):model_name = opt_name_or_path@@ -137,11 +139,7 @@ class TestAutoRound:data_type="nv_fp4",)model, _ = autoround.quantize()- result = simple_evaluate_user_model(- model, self.tokenizer, batch_size="auto:8", tasks="lambada_openai", limit=32- )- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, self.tokenizer, threshold=0.35, batch_size="auto:8", limit=32)def test_w4g1(self, tiny_opt_model_path, dataloader):model_name = tiny_opt_model_path@@ -172,11 +170,7 @@ class TestAutoRound:)model, _ = autoround.quantize()if bits > 2:- result = simple_evaluate_user_model(- model, self.tokenizer, batch_size="auto:8", tasks="lambada_openai", limit=32- )- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.3+ evaluate_accuracy(model, self.tokenizer, threshold=0.3, batch_size="auto:8", limit=32)def test_disable_quanted_input(self, dataloader):bits, group_size, sym = 4, -1, Truediff --git a/test/test_cpu/quantization/test_asym.py b/test/test_cpu/quantization/test_asym.pyindex 7b0b90100..60730686f 100644--- a/test/test_cpu/quantization/test_asym.py+++ b/test/test_cpu/quantization/test_asym.py@@ -9,10 +9,8 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_model-from auto_round.utils import get_module-from ...helpers import get_model_path, model_infer+from ...helpers import get_model_pathclass LLMDataLoader:diff --git a/test/test_cpu/quantization/test_mix_bits.py b/test/test_cpu/quantization/test_mix_bits.pyindex e5a8a7c42..8affa527a 100644--- a/test/test_cpu/quantization/test_mix_bits.py+++ b/test/test_cpu/quantization/test_mix_bits.py@@ -10,7 +10,7 @@ from transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRoundfrom auto_round.testing_utils import require_gptqmodel-from ...helpers import opt_name_or_path+from ...helpers import evaluate_accuracy, opt_name_or_pathdef _get_folder_size(path: str) -> float:@@ -227,9 +227,6 @@ class TestAutoRound:device_map="cpu",)tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)- from auto_round.eval.evaluation import simple_evaluate_user_model- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai", limit=10)- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.14+ evaluate_accuracy(model, tokenizer, threshold=0.14, batch_size=16, limit=10)shutil.rmtree(quantized_model_path, ignore_errors=True)diff --git a/test/test_cuda/advanced/test_fp8_input.py b/test/test_cuda/advanced/test_fp8_input.pyindex 1874b2ccd..adce4dced 100644--- a/test/test_cuda/advanced/test_fp8_input.py+++ b/test/test_cuda/advanced/test_fp8_input.py@@ -7,7 +7,6 @@ from packaging import versionfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluatefrom auto_round.utils import llm_load_modelfrom auto_round.utils.weight_handler import (ModuleWeightType,@@ -15,23 +14,7 @@ from auto_round.utils.weight_handler import (convert_module_to_hp_if_necessary,)-from ...helpers import get_model_path, get_tiny_model, transformers_version---def generate_prompt(model, tokenizer):- text = "There is a girl who likes adventure,"- inputs = tokenizer(text, return_tensors="pt").to(model.device)- print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))---def evaluate_accuracy(save_dir, task="lambada_openai", threshold=0.25):- """Helper function to evaluate model accuracy on a given task."""- model_args = f"pretrained={save_dir}"- result = simple_evaluate(model="hf", model_args=model_args, tasks=task, batch_size="auto")- acc = result["results"][task]["acc,none"]- print(f"{task} accuracy: {acc}")- assert acc > threshold, f"Accuracy {acc} is below threshold {threshold}"- return acc+from ...helpers import evaluate_accuracy, generate_prompt, get_model_path, get_tiny_model, transformers_versionclass TestAutoRound:diff --git a/test/test_cuda/advanced/test_multiple_card.py b/test/test_cuda/advanced/test_multiple_card.pyindex a8c008a73..1ea003501 100644--- a/test/test_cuda/advanced/test_multiple_card.py+++ b/test/test_cuda/advanced/test_multiple_card.py@@ -1,4 +1,3 @@-import reimport shutilimport pytest@@ -7,27 +6,15 @@ from lm_eval.utils import make_table # pylint: disable=E0401from transformers import AutoModelForCausalLM, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluatefrom auto_round.testing_utils import multi_card, require_gptqmodel, require_greater_than_050-from ...helpers import get_model_path, get_tiny_model---def get_accuracy(data):- match = re.search(r"\|acc\s+\|[↑↓]\s+\|\s+([\d.]+)\|", data)-- if match:- accuracy = float(match.group(1))- return accuracy- else:- return 0.0+from ...helpers import evaluate_accuracy, get_model_path, get_tiny_model# import os# os.environ["CUDA_VISIBLE_DEVICES"] = "0,1"class TestAutoRound:save_dir = "./saved"- tasks = "lambada_openai"@pytest.fixture(autouse=True, scope="class")def setup_and_teardown_class(self):@@ -53,11 +40,7 @@ class TestAutoRound:autoround.quantize()autoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- print(accuracy)- assert accuracy > 0.45 ##0.4786+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.45, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@multi_carddiff --git a/test/test_cuda/advanced/test_multiple_card_calib.py b/test/test_cuda/advanced/test_multiple_card_calib.pyindex 8eef8b981..7b4f4d6ea 100644--- a/test/test_cuda/advanced/test_multiple_card_calib.py+++ b/test/test_cuda/advanced/test_multiple_card_calib.py@@ -11,16 +11,6 @@ AUTO_ROUND_PATH = __file__.split("/")AUTO_ROUND_PATH = "/".join(AUTO_ROUND_PATH[: AUTO_ROUND_PATH.index("test")])-def get_accuracy(data):- match = re.search(r"\|acc\s+\|[↑↓]\s+\|\s+([\d.]+)\|", data)-- if match:- accuracy = float(match.group(1))- return accuracy- else:- return 0.0--class TestAutoRound:save_dir = "./saved"tasks = "lambada_openai"diff --git a/test/test_cuda/backends/test_exllamav2_backend.py b/test/test_cuda/backends/test_exllamav2_backend.pyindex d31ac4a2f..07343ca2a 100644--- a/test/test_cuda/backends/test_exllamav2_backend.py+++ b/test/test_cuda/backends/test_exllamav2_backend.py@@ -7,10 +7,9 @@ from transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import (AutoRound,)-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.testing_utils import require_autogptq, require_gptqmodel, require_package_version_ut-from ...helpers import get_model_path, model_infer+from ...helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRoundexllamaBackend:@@ -46,9 +45,7 @@ class TestAutoRoundexllamaBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -57,9 +54,7 @@ class TestAutoRoundexllamaBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -87,9 +82,7 @@ class TestAutoRoundexllamaBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.27+ evaluate_accuracy(model, tokenizer, threshold=0.27, batch_size=16)torch.cuda.empty_cache()shutil.rmtree(self.save_dir, ignore_errors=True)@@ -120,8 +113,6 @@ class TestAutoRoundexllamaBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=64, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.15+ evaluate_accuracy(model, tokenizer, threshold=0.15, batch_size=64)torch.cuda.empty_cache()shutil.rmtree(self.save_dir, ignore_errors=True)diff --git a/test/test_cuda/backends/test_marlin_backend.py b/test/test_cuda/backends/test_marlin_backend.pyindex 0fcce5e22..19dc277e0 100644--- a/test/test_cuda/backends/test_marlin_backend.py+++ b/test/test_cuda/backends/test_marlin_backend.py@@ -5,9 +5,8 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_model-from ...helpers import get_model_path, model_infer+from ...helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRoundMarlinBackend:@@ -53,9 +52,7 @@ class TestAutoRoundMarlinBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.14+ evaluate_accuracy(model, tokenizer, threshold=0.14, batch_size=16)for group_size in [32, 128]:print(f"{group_size}!!!!!!!!!!!!!!!!!")@@ -82,9 +79,7 @@ class TestAutoRoundMarlinBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.14+ evaluate_accuracy(model, tokenizer, threshold=0.14, batch_size=16)def test_marlin_4bits_sym_with_zp_m_1(self, dataloader):model = AutoModelForCausalLM.from_pretrained(self.model_name, torch_dtype="auto", trust_remote_code=True)@@ -110,9 +105,7 @@ class TestAutoRoundMarlinBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.27+ evaluate_accuracy(model, tokenizer, threshold=0.27, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -121,9 +114,7 @@ class TestAutoRoundMarlinBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.27+ evaluate_accuracy(model, tokenizer, threshold=0.27, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)diff --git a/test/test_cuda/backends/test_torch_backend.py b/test/test_cuda/backends/test_torch_backend.pyindex 28df641a3..87aed9073 100644--- a/test/test_cuda/backends/test_torch_backend.py+++ b/test/test_cuda/backends/test_torch_backend.py@@ -5,10 +5,9 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.testing_utils import require_autogptq, require_gptqmodel-from ...helpers import get_model_path, model_infer+from ...helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRoundTorchBackend:@@ -53,9 +52,7 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -64,9 +61,7 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.35+ evaluate_accuracy(model, tokenizer, threshold=0.35, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -95,8 +90,6 @@ class TestAutoRoundTorchBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.28+ evaluate_accuracy(model, tokenizer, threshold=0.28, batch_size=16)torch.cuda.empty_cache()shutil.rmtree(self.save_dir, ignore_errors=True)diff --git a/test/test_cuda/backends/test_triton_backend.py b/test/test_cuda/backends/test_triton_backend.pyindex fb67ad049..545ed013f 100644--- a/test/test_cuda/backends/test_triton_backend.py+++ b/test/test_cuda/backends/test_triton_backend.py@@ -5,10 +5,9 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.testing_utils import require_greater_than_050-from ...helpers import model_infer+from ...helpers import evaluate_accuracy, model_inferclass TestAutoRoundTritonBackend:@@ -47,9 +46,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.34+ evaluate_accuracy(model, tokenizer, threshold=0.34, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -58,9 +55,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.34+ evaluate_accuracy(model, tokenizer, threshold=0.34, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -80,9 +75,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.19+ evaluate_accuracy(model, tokenizer, threshold=0.19, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -91,9 +84,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.19+ evaluate_accuracy(model, tokenizer, threshold=0.19, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -122,9 +113,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- # print(result['results']['lambada_openai']['acc,none'])- assert result["results"]["lambada_openai"]["acc,none"] > 0.26+ evaluate_accuracy(model, tokenizer, threshold=0.26, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -133,9 +122,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- # print(result['results']['lambada_openai']['acc,none'])- assert result["results"]["lambada_openai"]["acc,none"] > 0.26+ evaluate_accuracy(model, tokenizer, threshold=0.26, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -156,9 +143,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.27+ evaluate_accuracy(model, tokenizer, threshold=0.27, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -167,9 +152,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- # print(result['results']['lambada_openai']['acc,none'])- assert result["results"]["lambada_openai"]["acc,none"] > 0.27+ evaluate_accuracy(model, tokenizer, threshold=0.27, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)@@ -195,9 +178,7 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.18+ evaluate_accuracy(model, tokenizer, threshold=0.18, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(@@ -206,8 +187,6 @@ class TestAutoRoundTritonBackend:tokenizer = AutoTokenizer.from_pretrained(self.save_folder)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- # print(result['results']['lambada_openai']['acc,none'])- assert result["results"]["lambada_openai"]["acc,none"] > 0.18+ evaluate_accuracy(model, tokenizer, threshold=0.18, batch_size=16)torch.cuda.empty_cache()shutil.rmtree("./saved", ignore_errors=True)diff --git a/test/test_cuda/core/test_main_func.py b/test/test_cuda/core/test_main_func.pyindex 955096141..dc8cdc15b 100644--- a/test/test_cuda/core/test_main_func.py+++ b/test/test_cuda/core/test_main_func.py@@ -1,5 +1,4 @@import copy-import reimport shutilimport pytest@@ -10,25 +9,13 @@ from transformers import AutoModelForCausalLM, AutoTokenizerfrom transformers.utils.versions import require_versionfrom auto_round import AutoRound, AutoRoundAdam-from auto_round.eval.evaluation import simple_evaluatefrom auto_round.testing_utils import require_awq, require_gptqmodel, require_optimum, require_package_version_ut-from ...helpers import get_model_path---def get_accuracy(data):- match = re.search(r"\|acc\s+\|[↑↓]\s+\|\s+([\d.]+)\|", data)-- if match:- accuracy = float(match.group(1))- return accuracy- else:- return 0.0+from ...helpers import evaluate_accuracy, get_model_pathclass TestMainFunc:save_dir = "./saved"- tasks = "lambada_openai"@pytest.fixture(autouse=True, scope="class")def setup_and_teardown_class(self):@@ -55,19 +42,13 @@ class TestMainFunc:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)##test auto_gptq formatautoround.save_quantized(self.save_dir, format="auto_gptq", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@require_optimum@@ -83,10 +64,7 @@ class TestMainFunc:##test auto_awq formatautoround.save_quantized(self.save_dir, format="auto_awq", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA not available")@@ -107,10 +85,7 @@ class TestMainFunc:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA not available")@@ -132,10 +107,7 @@ class TestMainFunc:##test auto_awq formatautoround.save_quantized(self.save_dir, format="auto_awq", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA not available")@@ -157,10 +129,7 @@ class TestMainFunc:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.34+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.34, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)def test_autoround_asym(self): ##need to install false@@ -178,10 +147,7 @@ class TestMainFunc:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res)- accuracy = get_accuracy(res)- assert accuracy > 0.35+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.35, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)def test_attention_mask_lm_head(self, tiny_qwen_moe_model_path):diff --git a/test/test_cuda/export/test_auto_round_format.py b/test/test_cuda/export/test_auto_round_format.pyindex 945a3d653..3eff1119b 100644--- a/test/test_cuda/export/test_auto_round_format.py+++ b/test/test_cuda/export/test_auto_round_format.py@@ -7,7 +7,6 @@ import transformersfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_modelfrom auto_round.testing_utils import (require_autogptq,require_awq,@@ -16,7 +15,7 @@ from auto_round.testing_utils import (require_package_version_ut,)-from ...helpers import get_model_path, get_tiny_model, model_infer+from ...helpers import evaluate_accuracy, get_model_path, get_tiny_model, model_inferclass TestAutoRound:@@ -87,9 +86,8 @@ class TestAutoRound:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.32+ evaluate_accuracy(model, tokenizer, threshold=0.32, batch_size=16)+ shutil.rmtree(self.save_dir, ignore_errors=True)@require_awq@require_package_version_ut("transformers", "<4.57.0")@@ -114,9 +112,7 @@ class TestAutoRound:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.18+ evaluate_accuracy(model, tokenizer, threshold=0.18, batch_size=16)torch.cuda.empty_cache()model = AutoModelForCausalLM.from_pretrained(diff --git a/test/test_cuda/export/test_gguf.py b/test/test_cuda/export/test_gguf.pyindex 60182aa48..11159844b 100644--- a/test/test_cuda/export/test_gguf.py+++ b/test/test_cuda/export/test_gguf.py@@ -11,7 +11,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizerfrom auto_round import AutoRoundfrom auto_round.testing_utils import require_gguf-from ...helpers import get_model_path, get_tiny_model, save_tiny_model, transformers_version+from ...helpers import evaluate_accuracy, get_model_path, get_tiny_model, save_tiny_model, transformers_versionAUTO_ROUND_PATH = __file__.split("/")AUTO_ROUND_PATH = "/".join(AUTO_ROUND_PATH[: AUTO_ROUND_PATH.index("test")])@@ -123,10 +123,7 @@ class TestAutoRound:inputs = autoround.tokenizer(text, return_tensors="pt").to(model.device)print(autoround.tokenizer.decode(model.generate(**inputs, max_new_tokens=10)[0]))- from auto_round.eval.evaluation import simple_evaluate_user_model-- result = simple_evaluate_user_model(model, autoround.tokenizer, batch_size=16, tasks="piqa")- assert result["results"]["piqa"]["acc,none"] > 0.54+ evaluate_accuracy(model, autoround.tokenizer, threshold=0.54, batch_size=16, task="piqa")shutil.rmtree(quantized_model_path, ignore_errors=True)@require_ggufdiff --git a/test/test_cuda/quantization/test_2_3bits.py b/test/test_cuda/quantization/test_2_3bits.pyindex c03d5e593..4f68612f8 100644--- a/test/test_cuda/quantization/test_2_3bits.py+++ b/test/test_cuda/quantization/test_2_3bits.py@@ -1,5 +1,4 @@import copy-import reimport shutilimport pytest@@ -9,25 +8,13 @@ from lm_eval.utils import make_table # pylint: disable=E0401from transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate, simple_evaluate_user_modelfrom auto_round.testing_utils import require_autogptq, require_greater_than_050, require_greater_than_051-from ...helpers import get_model_path, model_infer---def get_accuracy(data):- match = re.search(r"\|acc\s+\|[↑↓]\s+\|\s+([\d.]+)\|", data)-- if match:- accuracy = float(match.group(1))- return accuracy- else:- return 0.0+from ...helpers import evaluate_accuracy, get_model_path, model_inferclass TestAutoRound:save_dir = "./saved"- tasks = "lambada_openai"@pytest.fixture(autouse=True, scope="class")def setup_and_teardown_class(self):@@ -56,9 +43,7 @@ class TestAutoRound:tokenizer = AutoTokenizer.from_pretrained(self.save_dir)model_infer(model, tokenizer)- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.3+ evaluate_accuracy(model, tokenizer, threshold=0.3, batch_size=16)@require_greater_than_051def test_3bits_asym_autoround(self):@@ -67,17 +52,7 @@ class TestAutoRound:autoround = AutoRound(model_name, bits=bits, sym=sym)autoround.quantize_and_save(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(- model="hf",- model_args=model_args,- # tasks="arc_easy",- tasks=self.tasks,- batch_size="auto",- )-- ## 0.3423- accuracy = res["results"]["lambada_openai"]["acc,none"]- assert accuracy > 0.32+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.32, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@require_greater_than_050@@ -89,10 +64,7 @@ class TestAutoRound:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res) ##0.2212 0.1844- accuracy = get_accuracy(res)- assert accuracy > 0.18+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.18, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)@require_greater_than_050@@ -104,16 +76,10 @@ class TestAutoRound:##test auto_round formatautoround.save_quantized(self.save_dir, format="auto_round", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res) ##0.1745- accuracy = get_accuracy(res)- assert accuracy > 0.17+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.17, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)autoround.save_quantized(self.save_dir, format="auto_gptq", inplace=False)model_args = f"pretrained={self.save_dir}"- res = simple_evaluate(model="hf", model_args=model_args, tasks=self.tasks, batch_size="auto")- res = make_table(res) ##0.1745- accuracy = get_accuracy(res)- assert accuracy > 0.17+ evaluate_accuracy(model="hf", model_args=model_args, threshold=0.17, batch_size="auto")shutil.rmtree("./saved", ignore_errors=True)diff --git a/test/test_cuda/quantization/test_asym.py b/test/test_cuda/quantization/test_asym.pyindex d55934898..846ccac34 100644--- a/test/test_cuda/quantization/test_asym.py+++ b/test/test_cuda/quantization/test_asym.py@@ -8,10 +8,6 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_model-from auto_round.utils import get_module--from ...helpers import model_inferclass LLMDataLoader:diff --git a/test/test_cuda/quantization/test_mix_bits.py b/test/test_cuda/quantization/test_mix_bits.pyindex eadaf8f53..eee5874a0 100644--- a/test/test_cuda/quantization/test_mix_bits.py+++ b/test/test_cuda/quantization/test_mix_bits.py@@ -228,11 +228,9 @@ class TestAutoRound:device_map="auto",)tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)- from auto_round.eval.evaluation import simple_evaluate_user_model+ from ...helpers import evaluate_accuracy- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.32+ evaluate_accuracy(model, tokenizer, threshold=0.32, batch_size=16)shutil.rmtree(quantized_model_path, ignore_errors=True)def test_mixed_autoround_format_vllm(self, tiny_opt_model_path, dataloader):diff --git a/test/test_cuda/quantization/test_mxfp_nvfp.py b/test/test_cuda/quantization/test_mxfp_nvfp.pyindex e5ff3a636..75fe039ce 100644--- a/test/test_cuda/quantization/test_mxfp_nvfp.py+++ b/test/test_cuda/quantization/test_mxfp_nvfp.py@@ -158,9 +158,7 @@ class TestAutoRound:autoround.quantize_and_save(output_dir=quantized_model_path, inplace=False, format="auto_round")model = AutoModelForCausalLM.from_pretrained(quantized_model_path, torch_dtype="auto", device_map="auto")tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)- from auto_round.eval.evaluation import simple_evaluate_user_model+ from ...helpers import evaluate_accuracy- result = simple_evaluate_user_model(model, tokenizer, batch_size=16, tasks="piqa", limit=10)- print(result["results"]["piqa"]["acc,none"])- assert result["results"]["piqa"]["acc,none"] > 0.49+ evaluate_accuracy(model, tokenizer, threshold=0.49, batch_size=16, task="piqa", limit=10)shutil.rmtree(quantized_model_path, ignore_errors=True)diff --git a/test/test_cuda/schemes/test_auto_scheme.py b/test/test_cuda/schemes/test_auto_scheme.pyindex 7b4195f37..ecfc7cb34 100644--- a/test/test_cuda/schemes/test_auto_scheme.py+++ b/test/test_cuda/schemes/test_auto_scheme.py@@ -8,11 +8,10 @@ from transformers import AutoRoundConfigfrom auto_round import AutoRound, AutoSchemefrom auto_round.auto_scheme.utils import compute_avg_bits_for_model-from auto_round.eval.evaluation import simple_evaluatefrom auto_round.testing_utils import multi_cardfrom auto_round.utils import get_module-from ...helpers import get_model_path, get_tiny_model+from ...helpers import evaluate_accuracy, get_model_path, get_tiny_modelclass TestAutoScheme:@@ -239,10 +238,8 @@ class TestAutoScheme:scheme = AutoScheme(avg_bits=3, options=("W2A16", "W4A16", "W8A16", "BF16"))ar = AutoRound(model=model_name, scheme=scheme)ar.quantize_and_save(self.save_dir)- model_args = f"pretrained={self.save_dir}"- result = simple_evaluate(model="hf", model_args=model_args, tasks="lambada_openai", batch_size="auto")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.25+ evaluate_accuracy(self.save_dir, threshold=0.25)+ shutil.rmtree(self.save_dir, ignore_errors=True)def test_auto_scheme_export_gguf(self, tiny_qwen_model_path):scheme = AutoScheme(avg_bits=3, options=("gguf:q2_k_s,gguf:q4_k_s"), nsamples=1, ignore_scale_zp_bits=True)@@ -254,7 +251,5 @@ class TestAutoScheme:scheme = AutoScheme(avg_bits=2, options=("W2A16"), ignore_scale_zp_bits=True)ar = AutoRound(model=model_name, scheme=scheme, enable_torch_compile=True)ar.quantize_and_save(self.save_dir)- model_args = f"pretrained={self.save_dir}"- result = simple_evaluate(model="hf", model_args=model_args, tasks="lambada_openai", batch_size="auto")- print(result["results"]["lambada_openai"]["acc,none"])- assert result["results"]["lambada_openai"]["acc,none"] > 0.10+ evaluate_accuracy(self.save_dir, threshold=0.10)+ shutil.rmtree(self.save_dir, ignore_errors=True)diff --git a/test/test_cuda/utils/test_alg_ext.py b/test/test_cuda/utils/test_alg_ext.pyindex a29bffdac..e599ec77a 100644--- a/test/test_cuda/utils/test_alg_ext.py+++ b/test/test_cuda/utils/test_alg_ext.py@@ -6,9 +6,8 @@ import torchfrom transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizerfrom auto_round import AutoRound-from auto_round.eval.evaluation import simple_evaluate_user_model-from ...helpers import get_model_path+from ...helpers import evaluate_accuracy, get_model_pathAUTO_ROUND_PATH = __file__.split("/")AUTO_ROUND_PATH = "/".join(AUTO_ROUND_PATH[: AUTO_ROUND_PATH.index("test")])@@ -40,10 +39,7 @@ class TestAlgExt:)tokenizer = AutoTokenizer.from_pretrained(self.save_folder)- result = simple_evaluate_user_model(model, tokenizer, batch_size=64, tasks="lambada_openai")- print(result["results"]["lambada_openai"]["acc,none"])- # wo alg ext 0.2078, with 0.2371- assert result["results"]["lambada_openai"]["acc,none"] > 0.22+ evaluate_accuracy(model, tokenizer, threshold=0.22, batch_size=64)shutil.rmtree(self.save_folder, ignore_errors=True)def test_cli(self, tiny_opt_model_path):