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

[Bugs] fix dispatch bugs #775

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
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: 8 additions & 2 deletions xtuner/model/modules/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def replace_rote(model):
from mmengine import print_log
print_log = log_once(print_log)

assert hasattr(model.config, 'rope_theta'), \
'`rope_theta` should be in the model config.'
rope_theta = model.config.rope_theta

def traverse(module):
for name, child in module.named_children():
cls_name = type(child).__name__
Expand All @@ -232,8 +236,10 @@ def traverse(module):
rote = rote.build()
print_log(f'replace {cls_name}', 'current')
dim_model = child.inv_freq.shape[0] * 2
child_new = rote(dim_model, child.max_seq_len_cached).to(
device=child.inv_freq.device, dtype=child.inv_freq.dtype)
child_new = rote(dim_model, child.max_seq_len_cached,
rope_theta).to(
device=child.inv_freq.device,
dtype=child.inv_freq.dtype)
setattr(module, name, child_new)
else:
traverse(child)
Expand Down
Loading