-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support OLMo models. #2832
Merged
Merged
Support OLMo models. #2832
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
Isotr0py
commented
Feb 15, 2024
Comment on lines
+69
to
+77
class SwiGLU(nn.Module): | ||
|
||
def forward(self, x: torch.Tensor) -> torch.Tensor: | ||
x, gate = x.chunk(2, dim=-1) | ||
return F.silu(gate) * x | ||
|
||
@property | ||
def output_multiplier(self) -> float: | ||
return 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that SwiGLU
activation used in olmo is different from the SiluAndMul
in vllm:
class SiluAndMul(nn.Module):
"""An activation function for SwiGLU.
The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
Shapes:
x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
return: (batch_size, seq_len, d) or (num_tokens, d)
"""
def _forward(self, x: torch.Tensor) -> torch.Tensor:
"""PyTorch-native implementation equivalent to forward()."""
d = x.shape[-1] // 2
return F.silu(x[..., :d]) * x[..., d:]
def forward(self, x: torch.Tensor) -> torch.Tensor:
d = x.shape[-1] // 2
output_shape = (x.shape[:-1] + (d, ))
out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
ops.silu_and_mul(out, x)
return out
zhuohan123
approved these changes
Feb 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for your contribution!
simon-mo
pushed a commit
that referenced
this pull request
Feb 21, 2024
xjpang
pushed a commit
to xjpang/vllm
that referenced
this pull request
Feb 22, 2024
xjpang
pushed a commit
to xjpang/vllm
that referenced
this pull request
Feb 22, 2024
This version is for more model support. Add support for Gemma models (vllm-project#2964) and OLMo models (vllm-project#2832).
xjpang
pushed a commit
to xjpang/vllm
that referenced
this pull request
Mar 4, 2024
xjpang
pushed a commit
to xjpang/vllm
that referenced
this pull request
Mar 4, 2024
This version is for more model support. Add support for Gemma models (vllm-project#2964) and OLMo models (vllm-project#2832).
Temirulan
pushed a commit
to Temirulan/vllm-whisper
that referenced
this pull request
Sep 6, 2024
Temirulan
pushed a commit
to Temirulan/vllm-whisper
that referenced
this pull request
Sep 6, 2024
This version is for more model support. Add support for Gemma models (vllm-project#2964) and OLMo models (vllm-project#2832).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue:
TODO:
OLMoConfig
OLMo-1B
OLMo-7B/7B-Twin-2T
This is still in progress before all developments and tests finish.Done.