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

Speculator wt init fix #38

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion fms_extras/models/speculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(
def reset_parameters(self):
for m in self.modules():
if isinstance(m, nn.Embedding) or isinstance(m, nn.Linear):
nn.init.trunc_normal_(m.weight, 0, 1 / math.sqrt(self.inner_dim))
nn.init.normal_(m.weight, 0, 1 / math.sqrt(self.inner_dim))
elif isinstance(m, LayerNormParameterized) and hasattr(m, "weight"):
m.weight.data.fill_(1)
m.bias.data.zero_()
Expand Down
4 changes: 2 additions & 2 deletions fms_extras/modules/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ def forward(
# if use_cache=True, we return the hidden_state as well as the kv cache.
# We only reduce the output, and keep the cache thread-local
if use_cache:
out = reduce_from_tensor_model_parallel_region(out_par[0])
out = reduce_from_tensor_model_parallel_region(out_par[0], self.world_size)
return out, out_par[1]
else:
out = reduce_from_tensor_model_parallel_region(out_par)
out = reduce_from_tensor_model_parallel_region(out_par, self.world_size)
return out
4 changes: 3 additions & 1 deletion fms_extras/utils/cache/paged.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def create(cls, kernel, *args, mutated_inputs=[], **kwargs) -> None:
tensor_args,
non_tensor_args,
unflatten_args,
) = cls.process_kernel(kernel, *args, **kwargs)
) = cls.process_kernel(
kernel, *args, **kwargs
) # type: ignore
for tensor_arg in tensor_args:
tensor_arg.realize()

Expand Down
Loading