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
OpenDAS
text-generation-inference
Commits
9ab99374
Unverified
Commit
9ab99374
authored
Aug 01, 2024
by
Wang, Yi
Committed by
GitHub
Aug 01, 2024
Browse files
enable HuggingFaceM4/idefics-9b in intel gpu (#2338)
Signed-off-by:
Wang, Yi A
<
yi.a.wang@intel.com
>
parent
7451041e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
server/text_generation_server/models/custom_modeling/idefics_modeling.py
...eration_server/models/custom_modeling/idefics_modeling.py
+13
-1
server/text_generation_server/models/idefics.py
server/text_generation_server/models/idefics.py
+10
-0
No files found.
server/text_generation_server/models/custom_modeling/idefics_modeling.py
View file @
9ab99374
...
@@ -351,7 +351,19 @@ class IdeficsRMSNorm(nn.Module):
...
@@ -351,7 +351,19 @@ class IdeficsRMSNorm(nn.Module):
self
.
variance_epsilon
=
eps
self
.
variance_epsilon
=
eps
def
forward
(
self
,
hidden_states
,
residual
=
None
):
def
forward
(
self
,
hidden_states
,
residual
=
None
):
if
hidden_states
.
shape
[
-
1
]
>
8192
:
if
SYSTEM
==
"ipex"
:
import
intel_extension_for_pytorch
as
ipex
out
=
ipex
.
llm
.
functional
.
add_rms_norm
(
residual
,
hidden_states
,
self
.
weight
,
None
,
self
.
variance_epsilon
,
residual
is
not
None
,
)
return
out
elif
hidden_states
.
shape
[
-
1
]
>
8192
:
if
residual
is
not
None
:
if
residual
is
not
None
:
hidden_states
+=
residual
hidden_states
+=
residual
residual
=
hidden_states
residual
=
hidden_states
...
...
server/text_generation_server/models/idefics.py
View file @
9ab99374
...
@@ -20,6 +20,8 @@ from text_generation_server.utils import (
...
@@ -20,6 +20,8 @@ from text_generation_server.utils import (
)
)
from
text_generation_server.utils.quantization
import
get_loader
from
text_generation_server.utils.quantization
import
get_loader
from
text_generation_server.utils.import_utils
import
SYSTEM
class
IDEFICSSharded
(
IdeficsCausalLM
):
class
IDEFICSSharded
(
IdeficsCausalLM
):
def
__init__
(
def
__init__
(
...
@@ -37,6 +39,14 @@ class IDEFICSSharded(IdeficsCausalLM):
...
@@ -37,6 +39,14 @@ class IDEFICSSharded(IdeficsCausalLM):
# 9b seems to work correctly enough in float16, but 80b seems
# 9b seems to work correctly enough in float16, but 80b seems
# to be really saturating for f16.
# to be really saturating for f16.
dtype
=
torch
.
float16
if
dtype
is
None
else
dtype
dtype
=
torch
.
float16
if
dtype
is
None
else
dtype
elif
SYSTEM
==
"ipex"
:
if
hasattr
(
torch
,
"xpu"
)
and
torch
.
xpu
.
is_available
():
device
=
torch
.
device
(
f
"xpu:
{
rank
}
"
)
dtype
=
torch
.
float16
if
dtype
is
None
else
dtype
else
:
device
=
torch
.
device
(
"cpu"
)
# Float16 doesn't exist on target.
dtype
=
torch
.
bfloat16
if
dtype
is
None
else
dtype
else
:
else
:
device
=
torch
.
device
(
"cpu"
)
device
=
torch
.
device
(
"cpu"
)
dtype
=
torch
.
float32
if
dtype
is
None
else
dtype
dtype
=
torch
.
float32
if
dtype
is
None
else
dtype
...
...
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