File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 5
5
import uuid
6
6
import time
7
7
import json
8
+ import ctypes
8
9
import fnmatch
9
10
import multiprocessing
11
+
10
12
from typing import (
11
13
List ,
12
14
Optional ,
20
22
from collections import deque
21
23
from pathlib import Path
22
24
23
- import ctypes
24
25
25
26
from llama_cpp .llama_types import List
26
27
@@ -1789,15 +1790,15 @@ def save_state(self) -> LlamaState:
1789
1790
state_size = llama_cpp .llama_get_state_size (self ._ctx .ctx )
1790
1791
if self .verbose :
1791
1792
print (f"Llama.save_state: got state size: { state_size } " , file = sys .stderr )
1792
- llama_state = (llama_cpp .c_uint8 * int (state_size ))()
1793
+ llama_state = (ctypes .c_uint8 * int (state_size ))()
1793
1794
if self .verbose :
1794
1795
print ("Llama.save_state: allocated state" , file = sys .stderr )
1795
1796
n_bytes = llama_cpp .llama_copy_state_data (self ._ctx .ctx , llama_state )
1796
1797
if self .verbose :
1797
1798
print (f"Llama.save_state: copied llama state: { n_bytes } " , file = sys .stderr )
1798
1799
if int (n_bytes ) > int (state_size ):
1799
1800
raise RuntimeError ("Failed to copy llama state data" )
1800
- llama_state_compact = (llama_cpp .c_uint8 * int (n_bytes ))()
1801
+ llama_state_compact = (ctypes .c_uint8 * int (n_bytes ))()
1801
1802
llama_cpp .ctypes .memmove (llama_state_compact , llama_state , int (n_bytes ))
1802
1803
if self .verbose :
1803
1804
print (
You can’t perform that action at this time.
0 commit comments