Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
368275f3
Unverified
Commit
368275f3
authored
Sep 21, 2025
by
kaixuanliu
Committed by
GitHub
Sep 21, 2025
Browse files
add xpu support HFLM (#3211)
Signed-off-by:
Liu, Kaixuan
<
kaixuan.liu@intel.com
>
parent
7f698a5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+11
-2
No files found.
lm_eval/models/huggingface.py
View file @
368275f3
...
...
@@ -124,14 +124,22 @@ class HFLM(TemplateLM):
assert
isinstance
(
pretrained
,
str
)
assert
isinstance
(
batch_size
,
(
int
,
str
))
gpus
=
torch
.
cuda
.
device_count
()
accelerator_kwargs
=
InitProcessGroupKwargs
(
timeout
=
timedelta
(
weeks
=
52
))
accelerator
=
Accelerator
(
kwargs_handlers
=
[
accelerator_kwargs
])
if
accelerator
.
num_processes
>
1
:
self
.
accelerator
=
accelerator
if
"npu"
in
accelerator
.
device
.
type
:
# Detect device count based on accelerator device type
device_type
=
accelerator
.
device
.
type
if
"cuda"
in
device_type
:
gpus
=
torch
.
cuda
.
device_count
()
elif
"npu"
in
device_type
:
gpus
=
torch
.
npu
.
device_count
()
elif
"xpu"
in
device_type
:
gpus
=
torch
.
xpu
.
device_count
()
else
:
# Fallback to CUDA count for compatibility
gpus
=
torch
.
cuda
.
device_count
()
# using one process with no model parallelism
if
not
(
parallelize
or
accelerator
.
num_processes
>
1
):
...
...
@@ -141,6 +149,7 @@ class HFLM(TemplateLM):
+
[
f
"cuda:
{
i
}
"
for
i
in
range
(
gpus
)]
+
[
"mps"
,
"mps:0"
]
+
[
f
"npu:
{
i
}
"
for
i
in
range
(
gpus
)]
+
[
f
"xpu:
{
i
}
"
for
i
in
range
(
gpus
)]
)
if
device
and
device
in
device_list
:
self
.
_device
=
torch
.
device
(
device
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment