Gausson commited on
Commit
258a310
·
verified ·
1 Parent(s): 7f0640f

Update custom_generate/generate.py

Browse files
Files changed (1) hide show
  1. custom_generate/generate.py +31 -0
custom_generate/generate.py CHANGED
@@ -1,3 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import torch
2
 
3
  import types
@@ -8,6 +38,7 @@ import torch.nn as nn
8
  from transformers.modeling_utils import PreTrainedModel
9
 
10
 
 
11
  from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
12
  from ..monkey_patching_utils import monkey_patching
13
  from ..sep_cache_utils import SepCache
 
1
+ def debug_imports():
2
+ import sys
3
+ import os
4
+ import inspect
5
+
6
+ print("\n===== 导入调试信息 =====")
7
+ print(f"当前工作目录: {os.getcwd()}")
8
+ print(f"脚本路径: {os.path.abspath(__file__)}")
9
+ print(f"脚本所在目录: {os.path.dirname(os.path.abspath(__file__))}")
10
+ print(f"父目录: {os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}")
11
+ print(f"Python路径(sys.path):")
12
+ for p in sys.path:
13
+ print(f" - {p}")
14
+
15
+ try:
16
+ from .. import monkey_patching_utils
17
+ print("成功导入 monkey_patching_utils")
18
+ except ImportError as e:
19
+ print(f"导入失败: {e}")
20
+ print(f"当前包: {__package__}")
21
+ frame = inspect.currentframe().f_back
22
+ print(f"调用栈: {inspect.getframeinfo(frame)}")
23
+
24
+ print("=======================\n")
25
+
26
+ # 在脚本开头调用
27
+ debug_imports()
28
+
29
+
30
+
31
  import torch
32
 
33
  import types
 
38
  from transformers.modeling_utils import PreTrainedModel
39
 
40
 
41
+
42
  from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
43
  from ..monkey_patching_utils import monkey_patching
44
  from ..sep_cache_utils import SepCache