-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New python based entry point for containers
Signed-off-by: Jiri Podivin <[email protected]>
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ RUN make | |
|
||
ENV LC_ALL=C.utf8 | ||
|
||
ENTRYPOINT ["/app/.devops/tools.sh"] | ||
ENTRYPOINT ["/app/.devops/tools.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/env python3 | ||
|
||
import argparse | ||
import os | ||
import subprocess as sp | ||
from glob import glob | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
subparsers = parser.add_subparsers(dest='command') | ||
|
||
parser.add_argument( | ||
'-m', "--model", type=str, required=True, | ||
help="Directory containing model file, or model file itself (*.pth, *.pt, *.bin)") | ||
|
||
run = subparsers.add_parser("run", help="Run a model previously converted into ggml") | ||
convert = subparsers.add_parser("convert", help="Convert a llama model into ggml") | ||
quantize = subparsers.add_parser("quantize", help="Optimize with quantization process ggml") | ||
allinone = subparsers.add_parser("all-in-one", help="Execute --convert & --quantize") | ||
|
||
known_args, unknown_args = parser.parse_known_args() | ||
model_path = known_args.model | ||
converted_models = glob(os.path.join(model_path, 'ggml-model-*.bin')) | ||
|
||
if known_args.command == 'convert': | ||
sp.run(['python3', './convert.py', model_path] + unknown_args, check=True) | ||
|
||
if known_args.command == 'run': | ||
sp.run(['./main', '-m', model_path] + unknown_args, check=True) | ||
|
||
if known_args.command == 'quantize': | ||
if not converted_models: | ||
print(f"No models ready for quantization found in {model_path}") | ||
exit(1) | ||
sp.run(['./quantize', converted_models[0]] + unknown_args, check=True) | ||
|
||
if known_args.command == 'all-in-one': | ||
if not converted_models: | ||
sp.run(['python3', './convert.py', model_path], check=True) | ||
converted_models = glob(os.path.join(model_path, 'ggml-model-*.bin')) | ||
else: | ||
print( | ||
f"Converted models found {converted_models}! No need to convert.") | ||
|
||
quantized_models = glob(os.path.join(model_path, f'ggml-model-q*_*.bin')) | ||
|
||
if not quantized_models: | ||
sp.run(['./quantize', converted_models[0]] + unknown_args, check=True) | ||
else: | ||
print( | ||
f"Quantized models found {quantized_models}! No need to quantize.") | ||
exit() |