Skip to content

Commit

Permalink
initial enablement for device support (pytorch#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekgfb authored and malfet committed Jul 17, 2024
1 parent a9f134c commit ae8a253
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ def __init__(
model: Transformer,
tokenizer,
max_seq_length: Optional[int] = None,
device = "cpu"
):
super().__init__()
self._model = model
self._tokenizer = tokenizer
self._device = torch.device("cuda")
self._device = torch.device(device)
self._max_seq_length = 2048 if max_seq_length is None else max_seq_length

@property
Expand Down Expand Up @@ -174,6 +175,7 @@ def eval(
tasks: Optional[list] = None,
limit: Optional[int] = None,
max_seq_length: Optional[int] = None,
device: str = "cpu"
) -> dict:
"""
Evaluates a language model on a specified task using the lm-evaluation-harness library.
Expand All @@ -195,6 +197,7 @@ def eval(
model,
tokenizer,
max_seq_length,
device=device
)

try:
Expand Down Expand Up @@ -267,6 +270,7 @@ def main(args) -> None:
tasks,
limit,
max_seq_length,
device=builder_args.device,
)
print(f"Time to run eval: {time.time() - t1:.02f} seconds.")
if builder_args.dso_path:
Expand Down

0 comments on commit ae8a253

Please sign in to comment.