diff --git a/python/llm/dev/benchmark/perplexity/ppl.py b/python/llm/dev/benchmark/perplexity/ppl.py index 1b71d9fe..d340297e 100644 --- a/python/llm/dev/benchmark/perplexity/ppl.py +++ b/python/llm/dev/benchmark/perplexity/ppl.py @@ -74,8 +74,9 @@ class BigDLPPL: ppl_mean = np.mean(np.array(ppls)[~np.isnan(np.array(ppls))]) finally: - torch.xpu.synchronize() - torch.xpu.empty_cache() + if self.device == "xpu": + torch.xpu.synchronize() + torch.xpu.empty_cache() del self.model gc.collect() diff --git a/python/llm/dev/benchmark/perplexity/run.py b/python/llm/dev/benchmark/perplexity/run.py index d548e984..881d82e0 100644 --- a/python/llm/dev/benchmark/perplexity/run.py +++ b/python/llm/dev/benchmark/perplexity/run.py @@ -100,7 +100,7 @@ def main(): dumped = json.dumps(results, indent=2) print(dumped) - if args.output_path: + if output_path: with open(f"{log_dir}/result.json", "w") as f: f.write(dumped)