Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit b4af28c

Browse files
authored
Fix memory leak in falcon weight loader (#8)
1 parent 6b32b40 commit b4af28c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/falcon/weight.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def split(weight: np.ndarray, tp_size: int, rank: int = 0, dim: int = 0):
3131
if tp_size == 1:
3232
return weight
3333
elif weight.ndim == 1:
34-
return np.ascontiguousarray(np.split(weight, tp_size)[rank])
35-
return np.ascontiguousarray(np.split(weight, tp_size, axis=dim)[rank])
34+
return np.ascontiguousarray(np.split(weight, tp_size)[rank].copy())
35+
return np.ascontiguousarray(
36+
np.split(weight, tp_size, axis=dim)[rank].copy())
3637

3738

3839
def reorder_qkv_weight_or_bias(weight: np.ndarray,

0 commit comments

Comments
 (0)