|
37 | 37 | from torchao.quantization.granularity import PerGroup, PerAxis |
38 | 38 | from torchao.quantization.quant_primitives import MappingType |
39 | 39 |
|
40 | | -# This script requires a fairly recent version of transformers |
41 | | - |
42 | | -gen_ai_utils = os.getcwd() + "/gen_ai_utils/" |
43 | | -local_packages = gen_ai_utils + "/genai_local_packages" |
44 | | -install_script = gen_ai_utils + "/setup_local_packages.py" |
45 | | -subprocess.run([sys.executable, install_script, local_packages, "transformers==4.47.1"]) |
46 | | -sys.path.insert(0, local_packages) |
47 | | - |
48 | 40 | from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer |
49 | 41 | from torch.profiler import profile, ProfilerActivity, tensorboard_trace_handler |
50 | 42 |
|
@@ -95,7 +87,7 @@ def load_model_components(model_folder_path): |
95 | 87 |
|
96 | 88 |
|
97 | 89 | def get_quantized_model(args): |
98 | | - model_name = f"{args.model.name}" |
| 90 | + model_name = f"{args.model}" |
99 | 91 | print("Running model ", model_name) |
100 | 92 | config, tokenizer, model = load_model_components(args.model) |
101 | 93 | if model is None: |
@@ -189,7 +181,7 @@ def eval_quantized_output(quantized_model, tokenizer, input_tensor, max_min_toke |
189 | 181 |
|
190 | 182 |
|
191 | 183 | def main(args): |
192 | | - name_string = f"{args.model.name}" |
| 184 | + name_string = f"{args.model}" |
193 | 185 | quantized_model_, tokenizer_, config_ = get_quantized_model(args) |
194 | 186 | input_tensor = tokenizer_.encode(args.prompt, return_tensors="pt") |
195 | 187 | eval_quantized_output( |
@@ -223,8 +215,8 @@ def main(args): |
223 | 215 | ) |
224 | 216 | parser.add_argument( |
225 | 217 | "--model", |
226 | | - type=Path, |
227 | | - default=Path("TinyLlama/TinyLlama-1.1B-Chat-v1.0"), |
| 218 | + type=str, |
| 219 | + default="TinyLlama/TinyLlama-1.1B-Chat-v1.0", |
228 | 220 | help="Hugging Face model ID or Cloned model repository with model files", |
229 | 221 | ) |
230 | 222 | parser.add_argument( |
|
0 commit comments