Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIGraphX EP] Add migraphx ep save load compiles #20643

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

TedThemistokleous
Copy link
Contributor

Description

Adds the ability for MIGraphX EP to save off or load compiled models to save time between inferences.

Via Command line

User should be able to set the save ability with
ORT_MIGRAPHX_SAVE_COMPILED_MODEL
ORT_MIGRAPHX_SAVE_COMPILE_PATH

User should be able to set the load ability with
ORT_MIGRAPHX_LOAD_COMPILED_MODEL
ORT_MIGRAPHX_LOAD_COMPILE_PATH

via Onnxruntime API

migx_save_compiled_model
migx_save_model_name
migx_load_compiled_model
migx_load_model_name

Motivation and Context

The motivation for this is to leverage MIGraphX's existing API to save/load models after our compile step of graph optimization. For larger models or models which were compiled with additional tuning steps, this saves time after first compile and inference run, and thus speeds up the user experience in order to encourage development.

@TedThemistokleous TedThemistokleous linked an issue May 10, 2024 that may be closed by this pull request
2 tasks
@TedThemistokleous TedThemistokleous force-pushed the add_migraphx_ep_save_load_compiles branch 2 times, most recently from e803fcb to a3c457f Compare May 11, 2024 03:33
Fixes GPU faults Seen when running Mixed Precision inferences workloads with Bert v1.1  (fp16 + int8 Quant of Conv + MatMul)

Was hitting an edge case with mixed precision where the input parameters were not being populated and using uninitizlied values for the parameters which would "work" silently as no issue in inference arise. For bert though, segment_ids is pushed through a gather onnx operator which uses these as an index.

Using uninitialized memory made this error  such that it was non obvious why we were getting failures between our runs and we saw the issue intermittently between machines/cards/etc.

Fixes here are as follows to the MIGraphX Execution Provider

-Fp16 quantization after int8
-Additional debug logging for workflow of loading/quantization
- Set input/output parameters as seperate run prior to int8 calibration
- Set all dynamic data as input parameters for int8 static calibration to be performed with MIGraphX

Without these changes models will fail to copy input parameters on mixed precision runs when we decided to quantize as MIGraphX assumes all inputs will be used for calibration not just the input data read in from a calibration table.
@TedThemistokleous TedThemistokleous force-pushed the add_migraphx_ep_save_load_compiles branch from a3c457f to e096dec Compare June 10, 2024 16:14
@TedThemistokleous TedThemistokleous force-pushed the add_migraphx_ep_save_load_compiles branch from e096dec to eaf9da7 Compare June 10, 2024 20:00
Makes it easier to handle workflow if the input model needs to be recompiled or not.
@TedThemistokleous TedThemistokleous marked this pull request as ready for review June 11, 2024 02:20
@TedThemistokleous
Copy link
Contributor Author

ping @cloudhan @ytaous @PeixuanZuo useful to speed up workflow when working with MIGraphX EP

Should come after this is merged: #20982

@TedThemistokleous
Copy link
Contributor Author

Validated with: microsoft/onnxruntime-inference-examples#441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cache for Onnxruntime Compiled Programs
1 participant