Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load LLMs in FP16 for Faster Inference #10

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Next Next commit
Load LLMs in FP16 for faster inference
  • Loading branch information
Kyle1668 committed Jul 5, 2023
commit acbb67fc8044d496062127261ad69def63635c2a
3 changes: 1 addition & 2 deletions inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def load_model(split_name):
isDeduped = split_name.startswith("deduped")
model = split_name.split("duped.")[-1]
corresponding_model = f"EleutherAI/pythia-{model}{'-deduped' if isDeduped else ''}"
return GPTNeoXForCausalLM.from_pretrained(corresponding_model, device_map="auto")
return GPTNeoXForCausalLM.from_pretrained(corresponding_model, device_map="auto", torch_dtype=torch.float16)


def calculate_perplexity(logits: torch.Tensor, labels: torch.Tensor) -> torch.float64:
Expand Down Expand Up @@ -293,7 +293,6 @@ def parse_cli_args():
"--models",
type=str,
help=models_arg_help,
choices=models_args_default,
default=models_args_default,
)

Expand Down