Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelikefeet committed Aug 7, 2024
1 parent 5e5f6e7 commit 2fa1472
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions swift/llm/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def get_max_model_len(config: PretrainedConfig, ignore_rope_scaling=False) -> Op
if max_model_len == INF:
max_model_len = None

if (not ignore_rope_scaling and max_model_len and hasattr(config, 'rope_scaling')
if (not ignore_rope_scaling and max_model_len and getattr(config, 'rope_scaling', None)
and config.rope_scaling.get('factor')):
max_model_len = max(int(max_model_len * config.rope_scaling.get('factor')), max_model_len)
return max_model_len
Expand All @@ -990,7 +990,7 @@ def set_rope_scaling(config: PretrainedConfig, rope_scaling: Dict[str, Any]):
config = llm_config
break

if hasattr(config, 'rope_scaling'):
if getattr(config, 'rope_scaling', None):
rope_scaling['factor'] = max(config.rope_scaling.get('factor', -1), rope_scaling['factor'])
rope_scaling = {**config.rope_scaling, **rope_scaling}
config.rope_scaling = rope_scaling
Expand Down

0 comments on commit 2fa1472

Please sign in to comment.