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

* fix jamba slow foward for multi-gpu

* remove comm

* oups

* style
This commit is contained in:
Marc Sun 2024-04-24 14:19:08 +02:00 committed by GitHub
parent 5d64ae9d75
commit 37fa1f654f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -919,6 +919,8 @@ class JambaMambaMixer(nn.Module):
else:
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 \
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]
@ -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_B = discrete_time_step[:, :, :, None] * B[:, None, :, :].float() # [batch, intermediade_size, seq_len, ssm_state_size]
deltaB_u = discrete_B * hidden_states[:, :, :, None].float()
# 3.c perform the recurrence y ← SSM(A, B, C)(x)
scan_outputs = []
for i in range(seq_len):