-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_loader.py
More file actions
47 lines (42 loc) · 1.28 KB
/
Copy pathfix_loader.py
File metadata and controls
47 lines (42 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Removes leftover debug patches from unsloth's loader.py.
Run after installing unsloth if you see SyntaxError in loader.py.
"""
import os
path = ".venv/lib/python3.12/site-packages/unsloth/models/loader.py"
if not os.path.exists(path):
print(" loader.py not found, skipping")
exit(0)
with open(path) as f:
content = f.read()
# Known debug patches to remove
patches = [
(
' "Please separate the LoRA and base models to 2 repos."\n'
' print("PRE-CALL model_config:", model_config, "peft_config:", peft_config)\n'
' )',
' "Please separate the LoRA and base models to 2 repos."\n'
' )'
),
(
' print("AUTOCONFIG2 ERROR:", str(error))\n'
' autoconfig_error',
' autoconfig_error'
),
(
' print("DEBUG2 peft_config:", peft_config)\n'
' print("DEBUG2 model_config:", model_config)\n',
''
),
]
fixed = False
for old, new in patches:
if old in content:
content = content.replace(old, new)
fixed = True
if fixed:
with open(path, 'w') as f:
f.write(content)
print(" Fixed debug patches in loader.py")
else:
print(" loader.py is clean")