Skip to content

Commit

Permalink
Enabled LMCorrectness inference tests on HPU. (microsoft#5271)
Browse files Browse the repository at this point in the history
Since lm_eval API(v0.3.0) does not currently support HPU accelerator, so
to run LMCorrectness tests on HPU, get lm_eval model with CPU and move
it to HPU accelerator.
  • Loading branch information
vshekhawat-hlab authored and rraminen committed May 9, 2024
1 parent 1498312 commit b1ba60a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/unit/inference/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,15 @@ def no_pool_bootstrap_stderr(f, xs, iters):
setattr(lm, model_family, getattr(lm, model_family).half().to(device))
lm._device = device
else:
lm = lm_eval.models.get_model(model_family).create_from_arg_string(
f"pretrained={model_name}", {"device": get_accelerator().device_name()})
if get_accelerator().device_name() == 'hpu':
#lm_eval not supporting HPU device, so get model with CPU and move it to HPU.
lm = lm_eval.models.get_model(model_family).create_from_arg_string(f"pretrained={model_name}",
{"device": "cpu"})
setattr(lm, model_family, getattr(lm, model_family).to(device))
lm._device = device
else:
lm = lm_eval.models.get_model(model_family).create_from_arg_string(
f"pretrained={model_name}", {"device": get_accelerator().device_name()})

get_accelerator().synchronize()
start = time.time()
Expand Down

0 comments on commit b1ba60a

Please sign in to comment.