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
change
sglang
Commits
651a23ee
Unverified
Commit
651a23ee
authored
Jun 07, 2024
by
Amos You
Committed by
GitHub
Jun 07, 2024
Browse files
remove redundant pad_input_ids function (#500)
parent
bf3e271f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
30 deletions
+0
-30
python/sglang/srt/models/llava.py
python/sglang/srt/models/llava.py
+0
-30
No files found.
python/sglang/srt/models/llava.py
View file @
651a23ee
...
@@ -323,36 +323,6 @@ class LlavaQwenForCausalLM(LlavaLlamaForCausalLM):
...
@@ -323,36 +323,6 @@ class LlavaQwenForCausalLM(LlavaLlamaForCausalLM):
torch
.
empty
(
config
.
text_config
.
hidden_size
,
dtype
=
torch
.
float16
)
torch
.
empty
(
config
.
text_config
.
hidden_size
,
dtype
=
torch
.
float16
)
)
)
def
pad_input_ids
(
self
,
input_ids
,
pad_value
,
pt_shape
=
None
,
image_size
=
None
):
new_image_feature_len
=
self
.
image_feature_len
# now only support spatial_unpad + anyres
if
self
.
mm_patch_merge_type
.
startswith
(
"spatial"
):
height
=
width
=
self
.
num_patches_per_side
if
pt_shape
[
0
]
>
1
:
if
self
.
image_aspect_ratio
==
"anyres"
:
num_patch_width
,
num_patch_height
=
get_anyres_image_grid_shape
(
image_size
,
self
.
image_grid_pinpoints
,
self
.
vision_tower
.
config
.
image_size
,
)
if
"unpad"
in
self
.
mm_patch_merge_type
:
h
=
num_patch_height
*
height
w
=
num_patch_width
*
width
new_h
,
new_w
=
unpad_image_shape
(
h
,
w
,
image_size
)
new_image_feature_len
+=
new_h
*
(
new_w
+
1
)
pad_ids
=
pad_value
*
(
(
new_image_feature_len
+
len
(
pad_value
))
//
len
(
pad_value
)
)
offset
=
input_ids
.
index
(
self
.
config
.
image_token_index
)
# old_len + pad_len - 1, because we need to remove image_token_id
new_input_ids
=
(
input_ids
[:
offset
]
+
pad_ids
[:
new_image_feature_len
]
+
input_ids
[
offset
+
1
:]
)
return
new_input_ids
,
offset
class
LlavaMistralForCausalLM
(
LlavaLlamaForCausalLM
):
class
LlavaMistralForCausalLM
(
LlavaLlamaForCausalLM
):
def
__init__
(
def
__init__
(
...
...
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