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

update lm_eval version #1473

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/text-generation/requirements_lm_eval.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
https://github.com/EleutherAI/lm-evaluation-harness/archive/0bf683b4e6a9df359b3156ba9ba8d62bdd47e0c0.zip
datasets==2.21.0
https://github.com/EleutherAI/lm-evaluation-harness/archive/c1d8795da7610d507cb191c2769c5e7bf1060a35.zip
25 changes: 6 additions & 19 deletions examples/text-generation/run_lm_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import psutil
import torch
import torch.nn.functional as F
from lm_eval.models.huggingface import HFLM

# Local imports
from run_generation import setup_parser
Expand Down Expand Up @@ -91,17 +92,15 @@ def setup_lm_eval_parser():
return args


class HabanaModelAdapter(lm_eval.base.BaseLM):
class HabanaModelAdapter(HFLM):
def __init__(self, tokenizer, model, args, options):
super().__init__()
super().__init__(pretrained=model, tokenizer=tokenizer, batch_size=args.batch_size)
self.tokenizer = tokenizer
self.model = model
self._batch_size = args.batch_size
self.buckets = sorted(args.buckets)
self.options = options
self._device = args.device
self.model_inputs = {"use_cache": self.options.use_cache}
if self.model.config.model_type in [
if self._model.config.model_type in [
"llama",
"mistral",
"falcon",
Expand All @@ -112,11 +111,7 @@ def __init__(self, tokenizer, model, args, options):
"starcoder2",
"gemma",
]:
self.model_inputs.update(
{
"reuse_cache": self.options.reuse_cache,
}
)
self.model_inputs.update({"reuse_cache": self.options.reuse_cache})
if self.model.config.model_type in ["llama", "mistral", "qwen2", "falcon", "starcoder2", "gemma"]:
if self.model.config.model_type != "falcon":
self.model_inputs.update(
Expand All @@ -136,7 +131,7 @@ def __init__(self, tokenizer, model, args, options):

def warm_up(self):
for bucket_size in reversed(self.buckets):
inps = torch.ones((self._batch_size, bucket_size), dtype=torch.int64)
inps = torch.ones((self.batch_size, bucket_size), dtype=torch.int64)
self._model_call(inps)
pass

Expand All @@ -148,14 +143,6 @@ def eot_token_id(self):
def max_length(self):
return self.buckets[-1]

@property
def max_gen_toks(self):
raise NotImplementedError()

@property
def batch_size(self):
return self._batch_size

@property
def device(self):
# We need to do padding ourselves, otherwise we'll end up with recompilations
Expand Down
Loading