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

Switch to using hipBLASLt by default instead of rocBLAS #3783

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -323,7 +323,6 @@ rocm_enable_cppcheck(
${CMAKE_CURRENT_SOURCE_DIR}/test/include
DEFINE
MIGRAPHX_MLIR=1
MIGRAPHX_ENABLE_HIPBLASLT_GEMM=1
MIGRAPHX_HAS_EXECUTORS=0
CPPCHECK=1
MIGRAPHX_USE_MIOPEN=1
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/env_vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ Use it in conjunction with ``MIGRAPHX_DISABLE_MLIR=1``.
Set to "1", "enable", "enabled", "yes", or "true" to use.
Disables use of the rocMLIR library.

.. envvar:: MIGRAPHX_ENABLE_HIPBLASLT_GEMM
.. envvar:: MIGRAPHX_DISABLE_HIPBLASLT_GEMM
Set to "1", "enable", "enabled", "yes", or "true" to use.
Enables use of hipBLASLt.
Disables use of hipBLASLt.

.. envvar:: MIGRAPHX_COPY_LITERALS

Expand Down
3 changes: 1 addition & 2 deletions src/targets/gpu/fuse_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -43,7 +43,6 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_HIPBLASLT_GEMM)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_MIOPEN_FUSION)
#if MIGRAPHX_USE_MIOPEN
struct fusion
Expand Down
6 changes: 3 additions & 3 deletions src/targets/gpu/lowering.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -55,7 +55,7 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_HIPBLASLT_GEMM);
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_HIPBLASLT_GEMM);
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_MIOPEN_POOLING)

struct miopen_apply
Expand Down Expand Up @@ -254,7 +254,7 @@ struct miopen_apply
auto output = insert_allocation(ins, ins->get_shape());
refs.push_back(output);
#if MIGRAPHX_USE_HIPBLASLT
if(not enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) or not hipblaslt_supported())
if(enabled(MIGRAPHX_DISABLE_HIPBLASLT_GEMM{}) or not hipblaslt_supported())
{
#endif
return mod->replace_instruction(
Expand Down
15 changes: 5 additions & 10 deletions src/targets/gpu/target.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -82,7 +82,7 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_NHWC)
#ifndef _WIN32
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_CK)
#endif
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_HIPBLASLT_GEMM)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_HIPBLASLT_GEMM)

std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_options& options) const
{
Expand All @@ -107,7 +107,7 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
// different between fp8e4m3fnuz and OCP types because rocBLAS only has
// support for fp8e4m3fnuz
std::set<std::string> unsupported_fp8e4m3fnuz_ops = {};
if(not enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) and not gpu::rocblas_fp8_available())
if(enabled(MIGRAPHX_DISABLE_HIPBLASLT_GEMM{}) and not gpu::rocblas_fp8_available())
{
unsupported_fp8e4m3fnuz_ops.insert("dot");
unsupported_fp8e4m3fnuz_ops.insert("quant_dot");
Expand All @@ -134,19 +134,14 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti

std::set<std::string> unsupported_fp8e5m2fnuz_ops = unsupported_fp8e4m3fnuz_ops;
// disable gemm for fp8e5m2fnuz if rocBLAS is being used
if(not enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}))
if(enabled(MIGRAPHX_DISABLE_HIPBLASLT_GEMM{}))
{
unsupported_fp8e5m2fnuz_ops.insert("dot");
unsupported_fp8e5m2fnuz_ops.insert("quant_dot");
}

std::set<std::string> unsupported_fp8ocp_ops = {};
// TODO: remove this when the flag is removed
if(not enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}))
{
unsupported_fp8ocp_ops.insert("dot");
unsupported_fp8ocp_ops.insert("quant_dot");
}

#if MIGRAPHX_USE_MIOPEN
// MIOpen doesn't have support for fp8 pooling yet.
unsupported_fp8ocp_ops.insert("pooling");
Expand Down
5 changes: 3 additions & 2 deletions test/gpu/compile_hipblaslt.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -43,7 +43,8 @@ void run_lowering(migraphx::module& m, bool offload_copy = false)
#if MIGRAPHX_USE_HIPBLASLT
TEST_CASE(hipblaslt_op)
{
if(migraphx::enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) and migraphx::gpu::hipblaslt_supported())
if(not migraphx::disabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) and
migraphx::gpu::hipblaslt_supported())
{
migraphx::module m1;
{
Expand Down
4 changes: 2 additions & 2 deletions test/gpu/fuse_gemm.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -82,7 +82,7 @@ TEST_CASE(gemm_pointwise_add)

auto output = mm->add_instruction(migraphx::op::allocate{s, std::nullopt});

if(migraphx::enabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) and
if(not migraphx::disabled(MIGRAPHX_ENABLE_HIPBLASLT_GEMM{}) and
migraphx::gpu::hipblaslt_supported())
{
migraphx::op::dot dot_instance;
Expand Down
Loading