Skip to content
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 rope scaling #1391

Merged
merged 24 commits into from
Jul 24, 2024
Merged
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions llmfoundry/models/mpt/modeling_mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import logging

from transformers import PreTrainedModel, PreTrainedTokenizerBase
from transformers.models.llama.modeling_llama import LlamaRotaryEmbedding
milocress marked this conversation as resolved.
Show resolved Hide resolved
from transformers.modeling_outputs import (
BaseModelOutputWithPast,
CausalLMOutputWithPast,
Expand Down Expand Up @@ -134,6 +135,15 @@ def gen_rotary_embedding(
device=
'cpu', # FSDP does not materialize modules with meta buffers, hence device is set to cpu
milocress marked this conversation as resolved.
Show resolved Hide resolved
)
elif rope_hf_config['type'] == 'llama3':
return LlamaRotaryEmbedding(
dim=rope_head_dim,
max_position_embeddings=max_seq_len,
base=rope_theta,
scaling_factor=rope_hf_config['factor'],
device=
'cpu', # FSDP does not materialize modules with meta buffers, hence device is set to cpu
)
raise ValueError('rope_impl needs to be either dail or hf')


Expand Down
Loading