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

Fix mixed and input parameters to MIGraphX EP #38

Conversation

TedThemistokleous
Copy link

Description

Fix Mixed precision (int8 + fp16) during calibration GPU segfault. Found input params which weren't set with both int8 and fp16 as the calibration was never setting this as part of the run.

The order of quantization on the model was also changed so that we use a non quantized model for the calibration before we finally apply an fp16 quantization.

Motivation and Context

This was causing a failure in QA as part of our testing. This bug was rather intermittent as the operation without these changes would periodically fail due to the input parameters to MIGraphX being uninitialized memory. This wasn't an issue until we had an input parameter used as an index for one of our Onnx operators (Gather) which would cause the GPU fault observed.

Due to the random nature of uninitialized memory, this would actually appear differently on a few different servers/cards. We were able to find one machine that consistently reproduced the issue where others were able to run example code upto batch size 256 without fault.

@TedThemistokleous TedThemistokleous marked this pull request as ready for review June 8, 2024 17:06
@TedThemistokleous TedThemistokleous self-assigned this Jun 8, 2024
@TedThemistokleous TedThemistokleous added the bug Something isn't working label Jun 8, 2024
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.
Copy link

@groenenboomj groenenboomj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split the logging up a little to reduce output when logging is on as a matter of preference but nothing technically incorrect other than what Jeff has noted.

@TedThemistokleous TedThemistokleous merged commit d5697e5 into ROCm:rocm6.1_internal_testing Jun 11, 2024
7 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants