diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc index a4e11f705e250..add20db5e557b 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc @@ -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_) { @@ -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 @@ -1284,11 +1295,13 @@ void calibrate_and_quantize(migraphx::program& prog, migraphx::quantize_int8(prog, t, quant_opts); LOGS_DEFAULT(WARNING) << "Quantizing int8: Complete"; } else if (fp8_enable) { +#if HIP_VERSION_MAJOR > 6 || (HIP_VERSION_MAJOR == 6 && HIP_VERSION_MINOR >= 3) LOGS_DEFAULT(WARNING) << "Quantizing input program to fp8"; migraphx::quantize_fp8_options quant_opts; quant_opts.add_calibration_data(quant_params); migraphx::quantize_fp8(prog, t, quant_opts); LOGS_DEFAULT(WARNING) << "Quantizing fp8: Complete"; +#endif } }