fix: break shared-buffer memory leak in GatedDeltaNet cache (#1077)
Co-authored-by: Angelos Katharopoulos <[email protected]>
This commit is contained in:
co-authored by
Angelos Katharopoulos
parent
bdeac59767
commit
9dcefa5272
@@ -267,7 +267,7 @@ class ShortConv1d(nn.Module):
|
||||
positions = (ends[:, None] + mx.arange(n_keep))[..., None]
|
||||
new_state = mx.take_along_axis(conv_input, positions, axis=1)
|
||||
else:
|
||||
new_state = conv_input[:, -n_keep:, :]
|
||||
new_state = mx.contiguous(conv_input[:, -n_keep:, :])
|
||||
|
||||
return out, new_state
|
||||
|
||||
|
||||
@@ -157,7 +157,8 @@ class GatedDeltaNet(nn.Module):
|
||||
qkv = mx.where(mask[..., None], qkv, 0)
|
||||
conv_input = mx.concatenate([conv_state, qkv], axis=1)
|
||||
if cache is not None:
|
||||
cache[0] = conv_input[:, -(self.conv_kernel_size - 1) :]
|
||||
n_keep = self.conv_kernel_size - 1
|
||||
cache[0] = mx.contiguous(conv_input[:, -n_keep:])
|
||||
conv_out = nn.silu(self.conv1d(conv_input))
|
||||
|
||||
q, k, v = [
|
||||
|
||||
@@ -266,7 +266,7 @@ class Qwen3NextGatedDeltaNet(nn.Module):
|
||||
positions = (ends[:, None] + mx.arange(n_keep))[..., None]
|
||||
cache[0] = mx.take_along_axis(conv_input, positions, axis=1)
|
||||
else:
|
||||
cache[0] = conv_input[:, -n_keep:, :]
|
||||
cache[0] = mx.contiguous(conv_input[:, -n_keep:, :])
|
||||
|
||||
conv_out = nn.silu(self.conv1d(conv_input))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user