-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b8a267
commit a9f4cf7
Showing
4 changed files
with
406 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"input_model": { | ||
"type": "PyTorchModel", | ||
"config": { | ||
"model_loader": "model_loader", | ||
"model_script": "user_script.py", | ||
"dummy_inputs_func": "dummy_inputs", | ||
"io_config": "get_io_config", | ||
"hf_config": { | ||
"model_name": "microsoft/phi-2", | ||
"task": "text-generation", | ||
"from_pretrained_args": { | ||
"trust_remote_code": true | ||
} | ||
} | ||
} | ||
}, | ||
"systems": { | ||
"local_system": { | ||
"type": "LocalSystem", | ||
"config": { | ||
"accelerators": [ | ||
"cpu" | ||
] | ||
} | ||
} | ||
}, | ||
"evaluators": { | ||
"common_evaluator": { | ||
"metrics": [ | ||
{ | ||
"name": "latency", | ||
"type": "latency", | ||
"sub_types": [ | ||
{ | ||
"name": "avg", | ||
"priority": 1 | ||
} | ||
], | ||
"user_config": { | ||
"user_script": "user_script.py", | ||
"dataloader_func": "create_dataloader", | ||
"batch_size": 2, | ||
"inference_settings": { | ||
"onnx": { | ||
"session_options": { | ||
"enable_profiling": false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"passes": { | ||
"convert_optimum": { | ||
"type": "OptimumConversion", | ||
"config": { | ||
"target_opset": 14, | ||
"extra_args": { | ||
"legacy": false, | ||
"no_post_process": false, | ||
"trust_remote_code": true | ||
} | ||
} | ||
}, | ||
"convert": { | ||
"type": "OnnxConversion", | ||
"config": { | ||
"target_opset": 17, | ||
"save_as_external_data": true, | ||
"all_tensors_to_one_file": true | ||
} | ||
}, | ||
"perf_tuning": { | ||
"type": "OrtPerfTuning", | ||
"config": { | ||
"user_script": "user_script.py", | ||
"dataloader_func": "create_dataloader", | ||
"batch_size": 2, | ||
"enable_profiling": false | ||
} | ||
} | ||
}, | ||
"pass_flows": [ | ||
[ | ||
"convert" | ||
] | ||
], | ||
"engine": { | ||
"search_strategy": false, | ||
"evaluate_input_model": false, | ||
"evaluator": "common_evaluator", | ||
"target": "local_system", | ||
"cache_dir": "cache", | ||
"output_name": "phi2", | ||
"output_dir": "phi2", | ||
"clean_cache": false, | ||
"log_severity_level": 0, | ||
"log_to_file": false | ||
} | ||
} |
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,10 @@ | ||
## Prerequisites | ||
* einops | ||
|
||
## Usage | ||
```bash | ||
python -m olive.workflows.run --config phi2_optimize.json | ||
``` | ||
|
||
## Limitations | ||
From the time being, the official [phi2](https://huggingface.co/microsoft/phi-2) model could not be exported to ONNX by using the offical model code. Therefore, we need patch the forward method to do preprocessing and postprocessing for the past_key_values arguments. When the official model could be exported to ONNX, we will remove this patch. | ||
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 @@ | ||
einops |
Oops, something went wrong.