Skip to content

Commit

Permalink
Gate FP8 MIraphX API usage to ROCm 6.3.2 or greater
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Themistokleous committed Jan 31, 2025
1 parent 3c0f071 commit 72f2101
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ void MIGraphXExecutionProvider::get_flags_from_session_info(const MIGraphXExecut

// Quantization
fp16_enable_ = info.fp16_enable;

#if HIP_VERSION_MAJOR > 6 || (HIP_VERSION_MAJOR == 6 && HIP_VERSION_MINOR >= 3)
fp8_enable_ = info.fp8_enable;
#else
LOGS_WARNING(WARNING) << "MIGraphX: FP8 Quantization requires ROCm 6.3.2 or greater";
fp8_enable = false;
#endif
int8_enable_ = info.int8_enable;

if (int8_enable_ and fp8_enable_) {
Expand Down Expand Up @@ -172,8 +178,13 @@ void MIGraphXExecutionProvider::get_flags_from_env() {
// whether fp8 quantization is enabled
const std::string fp8_enable_env = onnxruntime::GetEnvironmentVar(migraphx_env_vars::kFP8Enable);
if (!fp8_enable_env.empty()) {
#if HIP_VERSION_MAJOR > 6 || (HIP_VERSION_MAJOR == 6 && HIP_VERSION_MINOR >= 3)
fp8_enable_ = (std::stoi(fp8_enable_env) == 0 ? false : true);
LOGS_DEFAULT(WARNING) << "\nORT_MIGRAPHX_FP8_ENABLE: " << fp8_enable_;
#else
LOGS_WARNING(WARNING) << "MIGraphX: FP8 Quantization requires ROCm 6.3.2 or greater";
fp8_enable = false;
#endif
}

// whether int8 is enabled
Expand Down Expand Up @@ -1287,8 +1298,10 @@ void calibrate_and_quantize(migraphx::program& prog,
LOGS_DEFAULT(WARNING) << "Quantizing input program to fp8";
migraphx::quantize_fp8_options quant_opts;
quant_opts.add_calibration_data(quant_params);
#if HIP_VERSION_MAJOR > 6 || (HIP_VERSION_MAJOR == 6 && HIP_VERSION_MINOR >= 3)
migraphx::quantize_fp8(prog, t, quant_opts);
LOGS_DEFAULT(WARNING) << "Quantizing fp8: Complete";
#endif
}
}

Expand Down

0 comments on commit 72f2101

Please sign in to comment.