Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
10e63222
Unverified
Commit
10e63222
authored
Mar 28, 2024
by
Roy
Committed by
GitHub
Mar 28, 2024
Browse files
[Model] Fix and clean commandr (#3671)
parent
6d9aa00f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
vllm/model_executor/models/commandr.py
vllm/model_executor/models/commandr.py
+4
-12
No files found.
vllm/model_executor/models/commandr.py
View file @
10e63222
...
...
@@ -26,7 +26,6 @@ import torch
import
torch.utils.checkpoint
from
torch
import
nn
from
transformers
import
CohereConfig
from
transformers.pytorch_utils
import
ALL_LAYERNORM_LAYERS
from
vllm.attention
import
Attention
,
AttentionMetadata
from
vllm.model_executor.layers.activation
import
SiluAndMul
...
...
@@ -46,8 +45,6 @@ from vllm.model_executor.weight_utils import (default_weight_loader,
hf_model_weights_iterator
)
from
vllm.sequence
import
SamplerOutput
KVCache
=
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]
class
LayerNorm
(
nn
.
Module
):
...
...
@@ -70,9 +67,6 @@ class LayerNorm(nn.Module):
return
hidden_states
.
to
(
input_dtype
),
residuals
ALL_LAYERNORM_LAYERS
.
append
(
LayerNorm
)
# Copied from transformers.models.llama.modeling_llama.LlamaMLP Llama->Cohere
class
CohereMLP
(
nn
.
Module
):
...
...
@@ -137,7 +131,6 @@ class CohereAttention(nn.Module):
self
.
max_position_embeddings
=
config
.
max_position_embeddings
self
.
rope_theta
=
config
.
rope_theta
self
.
rope_scaling
=
getattr
(
config
,
"rope_scaling"
,
None
)
self
.
is_causal
=
True
self
.
qkv_proj
=
QKVParallelLinear
(
self
.
hidden_size
,
self
.
head_dim
,
...
...
@@ -171,7 +164,7 @@ class CohereAttention(nn.Module):
self
,
positions
:
torch
.
Tensor
,
hidden_states
:
torch
.
Tensor
,
kv_cache
:
KVCache
,
kv_cache
:
torch
.
Tensor
,
attn_metadata
:
AttentionMetadata
,
)
->
torch
.
Tensor
:
qkv
,
_
=
self
.
qkv_proj
(
hidden_states
)
...
...
@@ -200,7 +193,7 @@ class CohereDecoderLayer(nn.Module):
self
,
positions
:
torch
.
Tensor
,
hidden_states
:
torch
.
Tensor
,
kv_cache
:
KVCache
,
kv_cache
:
torch
.
Tensor
,
attn_metadata
:
AttentionMetadata
,
residual
:
Optional
[
torch
.
Tensor
],
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]:
...
...
@@ -242,7 +235,7 @@ class CohereModel(nn.Module):
self
,
input_ids
:
torch
.
Tensor
,
positions
:
torch
.
Tensor
,
kv_caches
:
List
[
KVCache
],
kv_caches
:
List
[
torch
.
Tensor
],
attn_metadata
:
AttentionMetadata
,
)
->
torch
.
Tensor
:
hidden_states
=
self
.
embed_tokens
(
input_ids
)
...
...
@@ -269,7 +262,6 @@ class CohereForCausalLM(nn.Module):
)
->
None
:
super
().
__init__
()
self
.
config
=
config
self
.
unpadded_vocab_size
=
config
.
vocab_size
self
.
linear_method
=
linear_method
self
.
logits_processor
=
LogitsProcessor
(
config
.
vocab_size
,
scale
=
config
.
logit_scale
)
...
...
@@ -281,7 +273,7 @@ class CohereForCausalLM(nn.Module):
self
,
input_ids
:
torch
.
Tensor
,
positions
:
torch
.
Tensor
,
kv_caches
:
List
[
KVCache
],
kv_caches
:
List
[
torch
.
Tensor
],
attn_metadata
:
AttentionMetadata
,
)
->
torch
.
Tensor
:
hidden_states
=
self
.
model
(
input_ids
,
positions
,
kv_caches
,
...
...
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