Skip to content

Commit 70baafe

Browse files
iseeyuanfacebook-github-bot
authored andcommitted
Update model arg name rope_theta to be consistent with those in llama's website (#3147)
Summary: As title Pull Request resolved: #3147 Reviewed By: larryliu0820 Differential Revision: D56357117 Pulled By: iseeyuan fbshipit-source-id: 85544712794681c8006a8f3713b8e0fba712650f
1 parent c8b43d2 commit 70baafe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/models/llama2/llama_transformer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class ModelArgs:
8888
use_sdpa_with_kv_cache_op: bool = (
8989
False # Use custom sdpa op that updates kv cache in-place
9090
)
91-
rope_freq_base: float = 10000.0 # The base frequency for RoPE
91+
rope_theta: Optional[float] = (
92+
None # The official name to override self.rope_freq_base.
93+
)
94+
rope_freq_base: float = 10000.0 # The base frequency for RoPE. Keep it for BC.
9295
# Additional Model Metadata needed at runtime
9396
bos_idx: int = 1
9497
eos_idx: int = 3
@@ -99,6 +102,10 @@ def __post_init__(self):
99102
if self.n_kv_heads is None:
100103
self.n_kv_heads = self.n_heads
101104

105+
# rope_theta overrides rope_freq_base since it's the official name.
106+
if self.rope_theta is not None:
107+
self.rope_freq_base = self.rope_theta
108+
102109
if self.use_sdpa_with_kv_cache_op:
103110
assert self.use_kv_cache, "use_sdpa_with_kv_cache_op requires use_kv_cache"
104111

0 commit comments

Comments
 (0)