File tree 3 files changed +30
-1
lines changed
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
default_device = "cpu" # 'cuda' if torch.cuda.is_available() else 'cpu'
15
15
16
+ strict = False
17
+
18
+ def check_args (args , command_name : str ):
19
+ global strict
20
+
21
+ # chat and generate support the same options
22
+ if command_name in ["generate" , "chat" , "gui" ]:
23
+ # examples, can add more. Note that attributes convert dash to _
24
+ disallowed_args = ['output_pte_path' , 'output_dso_path' ]
25
+ elif command_name == "export" :
26
+ # examples, can add more. Note that attributes convert dash to _
27
+ disallowed_args = ['pte_path' , 'dso_path' ]
28
+ elif command_name == "eval" :
29
+ # TBD
30
+ disallowed_args = []
31
+ else :
32
+ raise RuntimeError (f"{ command_name } is not a valid command" )
33
+
34
+ for disallowed in disallowed_args :
35
+ if args .hasattr (disallow ):
36
+ text = f"command { command_name } does not support option { disallowed .replace ('_' , '-' )} "
37
+ if strict :
38
+ raise RuntimeError (text )
39
+ else :
40
+ print (f"Warning: { text } " )
41
+
42
+
16
43
def cli_args ():
17
44
import argparse
18
45
Original file line number Diff line number Diff line change 28
28
except :
29
29
lm_eval_available = False
30
30
31
- from generate import _load_model , encode_tokens , model_forward
31
+ from generate import _load_inference_model , encode_tokens , model_forward
32
32
33
33
if lm_eval_available :
34
34
try : # lm_eval version 0.4
Original file line number Diff line number Diff line change @@ -23,10 +23,12 @@ def cli():
23
23
args = cli_args ()
24
24
25
25
if args .generate or args .chat :
26
+ check_args (args , "generate" )
26
27
generate_main (args )
27
28
elif args .eval :
28
29
eval_main (args )
29
30
elif args .export :
31
+ check_args (args , "export" )
30
32
export_main (args )
31
33
else :
32
34
raise RuntimeError ("must specify either --generate or --export" )
You can’t perform that action at this time.
0 commit comments