Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

[LLM Runtime]Fixed straightforward-API issues #80

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion scripts/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,27 @@ def main(args_in: Optional[List[str]] = None) -> None:
help="Try with bestla flash attn managed format for kv memory (Currently GCC13 & AMX required); "
"fall back to fp16 if failed (default option for kv-memory)",
)
parser.add_argument(
"--one_click_run",
type=str,
default="False",
choices=["True", "False"],
help="one-click for quantization and inference",
)

args = parser.parse_args(args_in)
print(args)
model_name = model_maps.get(args.model_name, args.model_name)
if is_win():
path = Path(args.build_dir, "./Bin/Release/run_{}.exe".format(model_name))
else:
path = Path(args.build_dir, "./bin/run_{}".format(model_name))
if args.one_click_run == "True":
import neural_speed
package_path = os.path.dirname(neural_speed.__file__)
path = Path(package_path, "./run_{}".format(model_name))
else:
path = Path(args.build_dir, "./bin/run_{}".format(model_name))

if not path.exists():
print("Please build graph first or select the correct model name.")
sys.exit(1)
Expand Down
14 changes: 13 additions & 1 deletion scripts/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,25 @@ def main(args_in: Optional[List[str]] = None) -> None:
action="store_true",
help="enable ggml for quantization and inference",
)
parser.add_argument(
"--one_click_run",
type=str,
default="False",
choices=["True", "False"],
help="one-click for quantization and inference",
)
args = parser.parse_args(args_in)

model_name = model_maps.get(args.model_name, args.model_name)
if is_win():
path = Path(args.build_dir, "./Bin/Release/quant_{}.exe".format(model_name))
else:
path = Path(args.build_dir, "./bin/quant_{}".format(model_name))
if args.one_click_run == "True":
import neural_speed
package_path = os.path.dirname(neural_speed.__file__)
path = Path(package_path, "./quant_{}".format(model_name))
else:
path = Path(args.build_dir, "./bin/quant_{}".format(model_name))
if not path.exists():
print(path)
print("Please build graph first or select the correct model name.")
Expand Down
4 changes: 4 additions & 0 deletions scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def main(args_in: Optional[List[str]] = None) -> None:
if args.use_ggml:
quant_cmd.extend(["--use_ggml"])
quant_cmd.extend(["--build_dir", args.build_dir])
quant_cmd.extend(["--one_click_run", "True"])
print("quantize model ...")
subprocess.run(quant_cmd)

Expand All @@ -202,8 +203,11 @@ def main(args_in: Optional[List[str]] = None) -> None:
infer_cmd.extend(["--repeat_penalty", str(args.repeat_penalty)])
infer_cmd.extend(["--keep", str(args.keep)])
infer_cmd.extend(["--build_dir", args.build_dir])
infer_cmd.extend(["--one_click_run", "True"])
if args.shift_roped_k:
infer_cmd.extend(["--shift-roped-k"])
if (model_type == "baichuan" or model_type == "qwen"):
infer_cmd.extend(["--tokenizer", dir_model])
print("inferce model ...")
subprocess.run(infer_cmd)

Expand Down