add tests.cal_flops.py

Former-commit-id: 469f859161
This commit is contained in:
hiyouga
2023-09-16 23:40:41 +08:00
parent 65854736c3
commit 4e6e42bb55
2 changed files with 46 additions and 4 deletions

View File

@@ -86,10 +86,8 @@ def load_model_and_tokenizer(
# Fix config (for Qwen)
if is_trainable and hasattr(config, "fp16") and hasattr(config, "bf16"):
if model_args.compute_dtype == torch.bfloat16:
setattr(config, "bf16", True)
else:
setattr(config, "fp16", True)
setattr(config, "fp16", model_args.compute_dtype == torch.float16)
setattr(config, "bf16", model_args.compute_dtype == torch.bfloat16)
# Set RoPE scaling
if model_args.rope_scaling is not None: