Skip to content

Commit

Permalink
Fix memory allocation of ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-song committed Aug 25, 2024
1 parent 259ee15 commit f993209
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,8 @@ def load_state(self, state: LlamaState) -> None:
assert self._ctx.ctx is not None
# Only filling in up to `n_tokens` and then zero-ing out the rest
self.scores[: state.n_tokens, :] = state.scores.copy()
self.scores[state.n_tokens :, :] = 0.0
rest = self.scores[state.n_tokens :, :]
rest[rest > 0] = 0.0
self.input_ids = state.input_ids.copy()
self.n_tokens = state.n_tokens
state_size = state.llama_state_size
Expand Down

0 comments on commit f993209

Please sign in to comment.