-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support rope scaling * use rope scaling * update to use rope config * update config args * use allowlist for config to enforce hygeine * allow llama3 rope config * add unit test * documented allowed llama config keys * Update llmfoundry/models/mpt/modeling_mpt.py * Address comments 1 * Apply suggestions from code review Co-authored-by: Daniel King <[email protected]> * Apply suggestions from code review Co-authored-by: Daniel King <[email protected]> * use same codepath for all the hf rotary embeddings * fix * update * test WIP but fix get/pop * change the thing being popped * give up on testing hf --------- Co-authored-by: Daniel King <[email protected]>
- Loading branch information
Showing
5 changed files
with
111 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2024 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from transformers.models.llama.modeling_llama import LlamaRotaryEmbedding | ||
|
||
from llmfoundry.models.mpt.modeling_mpt import gen_rotary_embedding | ||
|
||
rope_config = { | ||
'rope_theta': 500000.0, | ||
'rope_impl': 'hf', | ||
'rope_hf_config': { | ||
'factor': 8.0, | ||
'low_freq_factor': 1.0, | ||
'high_freq_factor': 4.0, | ||
'original_max_position_embeddings': 8192, | ||
'type': 'llama3', | ||
}, | ||
} | ||
|
||
rope_dail_config = {} | ||
|
||
|
||
def test_rope_scaling(): | ||
d_model = 128 | ||
n_heads = 32 | ||
max_seq_len = 65536 | ||
|
||
embedding = gen_rotary_embedding( | ||
d_model=d_model, | ||
n_heads=n_heads, | ||
rope_dail_config=rope_dail_config, | ||
max_seq_len=max_seq_len, | ||
**rope_config, | ||
) | ||
|
||
assert isinstance(embedding, LlamaRotaryEmbedding) |