Unverified Commit 37fa1f65 authored by Marc Sun's avatar Marc Sun Committed by GitHub
Browse files

fix jamba slow foward for multi-gpu (#30418)

* fix jamba slow foward for multi-gpu

* remove comm

* oups

* style
parent 5d64ae9d
...@@ -919,6 +919,8 @@ class JambaMambaMixer(nn.Module): ...@@ -919,6 +919,8 @@ class JambaMambaMixer(nn.Module):
else: else:
ssm_state = cache_params.ssm_states[self.layer_idx] ssm_state = cache_params.ssm_states[self.layer_idx]
ssm_state = ssm_state.to(hidden_states.device)
if cache_params.has_previous_state and seq_len == 1 and \ if cache_params.has_previous_state and seq_len == 1 and \
cache_params.conv_states[self.layer_idx].shape[0] == batch_size: cache_params.conv_states[self.layer_idx].shape[0] == batch_size:
conv_state = cache_params.conv_states[self.layer_idx] # [batch, intermediate_size, conv_kernel_size] conv_state = cache_params.conv_states[self.layer_idx] # [batch, intermediate_size, conv_kernel_size]
...@@ -962,7 +964,6 @@ class JambaMambaMixer(nn.Module): ...@@ -962,7 +964,6 @@ class JambaMambaMixer(nn.Module):
discrete_A = torch.exp(A[None, :, None, :] * discrete_time_step[:, :, :, None]) # [batch, intermediate_size, seq_len, ssm_state_size] discrete_A = torch.exp(A[None, :, None, :] * discrete_time_step[:, :, :, None]) # [batch, intermediate_size, seq_len, ssm_state_size]
discrete_B = discrete_time_step[:, :, :, None] * B[:, None, :, :].float() # [batch, intermediade_size, seq_len, ssm_state_size] discrete_B = discrete_time_step[:, :, :, None] * B[:, None, :, :].float() # [batch, intermediade_size, seq_len, ssm_state_size]
deltaB_u = discrete_B * hidden_states[:, :, :, None].float() deltaB_u = discrete_B * hidden_states[:, :, :, None].float()
# 3.c perform the recurrence y ← SSM(A, B, C)(x) # 3.c perform the recurrence y ← SSM(A, B, C)(x)
scan_outputs = [] scan_outputs = []
for i in range(seq_len): for i in range(seq_len):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment