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
norm
vllm
Commits
0d27f0c7
Commit
0d27f0c7
authored
May 12, 2024
by
zhuwenwen
Browse files
add linear bias
parent
f26ecef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
vllm/model_executor/layers/linear.py
vllm/model_executor/layers/linear.py
+7
-3
No files found.
vllm/model_executor/layers/linear.py
View file @
0d27f0c7
...
@@ -79,9 +79,13 @@ class UnquantizedLinearMethod(LinearMethodBase):
...
@@ -79,9 +79,13 @@ class UnquantizedLinearMethod(LinearMethodBase):
if
bias
:
if
bias
:
return
F
.
linear
(
x
,
weight
)
+
bias
return
F
.
linear
(
x
,
weight
)
+
bias
return
F
.
linear
(
x
,
weight
)
return
F
.
linear
(
x
,
weight
)
if
self
.
use_llama_nn
:
if
self
.
use_llama_nn
:
weight
=
weight
.
reshape
(
weight
.
shape
[
1
],
-
1
)
weight
=
weight
.
reshape
(
weight
.
shape
[
1
],
-
1
)
return
torch
.
matmul
(
x
,
weight
)
if
bias
is
not
None
:
return
torch
.
matmul
(
x
,
weight
)
+
bias
else
:
return
torch
.
matmul
(
x
,
weight
)
else
:
else
:
return
F
.
linear
(
x
,
weight
,
bias
)
return
F
.
linear
(
x
,
weight
,
bias
)
...
@@ -343,7 +347,7 @@ class MergedColumnParallelLinear(ColumnParallelLinear):
...
@@ -343,7 +347,7 @@ class MergedColumnParallelLinear(ColumnParallelLinear):
if
self
.
use_llama_nn
:
if
self
.
use_llama_nn
:
assert
param_data_
.
shape
==
loaded_weight
.
shape
assert
param_data_
.
shape
==
loaded_weight
.
shape
param_data_
.
copy_
(
loaded_weight
)
param_data_
.
copy_
(
loaded_weight
)
if
loaded_shard_id
==
1
:
if
loaded_shard_id
==
1
and
len
(
param_data
.
shape
)
==
2
:
param_data
=
param_data
.
transpose
(
0
,
1
)
param_data
=
param_data
.
transpose
(
0
,
1
)
param
.
data
=
param_data
.
reshape
(
param_data
.
shape
[
1
],
-
1
)
param
.
data
=
param_data
.
reshape
(
param_data
.
shape
[
1
],
-
1
)
else
:
else
:
...
@@ -477,7 +481,7 @@ class QKVParallelLinear(ColumnParallelLinear):
...
@@ -477,7 +481,7 @@ class QKVParallelLinear(ColumnParallelLinear):
else
:
else
:
param_data
=
param_data
.
narrow
(
output_dim
,
shard_offset
,
param_data
=
param_data
.
narrow
(
output_dim
,
shard_offset
,
shard_size
)
shard_size
)
if
loaded_shard_id
==
"q"
:
if
loaded_shard_id
==
"q"
and
len
(
param_data
.
shape
)
==
2
:
shard_id
=
tp_rank
shard_id
=
tp_rank
else
:
else
:
shard_id
=
tp_rank
//
self
.
num_kv_head_replicas
shard_id
=
tp_rank
//
self
.
num_kv_head_replicas
...
...
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