Skip to content
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
18 changes: 18 additions & 0 deletions transformer_engine/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,27 @@ list(APPEND transformer_engine_cuda_arch_specific_sources
activation/gelu.cu
activation/gelu_dbias.cu
activation/gelu_grouped.cu
activation/gelu_grouped_bwd.cu
activation/gelu_grouped_dbias.cu
activation/qgelu_grouped.cu
activation/qgelu_grouped_bwd.cu
activation/qgelu_grouped_dbias.cu
activation/glu.cu
activation/relu.cu
activation/relu_dbias.cu
activation/relu_grouped.cu
activation/relu_grouped_bwd.cu
activation/relu_grouped_dbias.cu
activation/srelu_grouped.cu
activation/srelu_grouped_bwd.cu
activation/srelu_grouped_dbias.cu
activation/scaled_activation.cu
activation/scaled_srelu.cu
activation/scaled_swiglu.cu
activation/swiglu.cu
activation/swiglu_dbias.cu
activation/swiglu_grouped.cu
activation/swiglu_grouped_bwd.cu
activation/swiglu_grouped_dbias.cu
cast/cast.cu
cast/cast_dbias.cu
Expand Down Expand Up @@ -631,18 +640,27 @@ if (NVTE_BUILD_ACTIVATION_WITH_FAST_MATH)
list(APPEND nvte_sources_with_fast_math activation/gelu.cu
activation/gelu_dbias.cu
activation/gelu_grouped.cu
activation/gelu_grouped_bwd.cu
activation/gelu_grouped_dbias.cu
activation/qgelu_grouped.cu
activation/qgelu_grouped_bwd.cu
activation/qgelu_grouped_dbias.cu
activation/glu.cu
activation/relu.cu
activation/relu_dbias.cu
activation/relu_grouped.cu
activation/relu_grouped_bwd.cu
activation/relu_grouped_dbias.cu
activation/srelu_grouped.cu
activation/srelu_grouped_bwd.cu
activation/srelu_grouped_dbias.cu
activation/scaled_activation.cu
activation/scaled_srelu.cu
activation/scaled_swiglu.cu
activation/swiglu.cu
activation/swiglu_dbias.cu
activation/swiglu_grouped.cu
activation/swiglu_grouped_bwd.cu
activation/swiglu_grouped_dbias.cu)
endif()

Expand Down
37 changes: 0 additions & 37 deletions transformer_engine/common/activation/gelu_grouped.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,3 @@ void nvte_group_gelu(const NVTEGroupedTensor input, NVTEGroupedTensor output, cu
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, gelu<fp32, fp32>>(input, output, nullptr,
stream);
}

void nvte_group_dgelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dgelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dgelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}

void nvte_group_qgelu(const NVTEGroupedTensor input, NVTEGroupedTensor output,
cudaStream_t stream) {
NVTE_API_CALL(nvte_group_qgelu);
using namespace transformer_engine;
constexpr bool IS_ACT = true;
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, qgelu<fp32, fp32>>(input, output, nullptr,
stream);
}

void nvte_group_dqgelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dqgelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dqgelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/gelu_grouped_bwd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_dgelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dgelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dgelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
14 changes: 0 additions & 14 deletions transformer_engine/common/activation/gelu_grouped_dbias.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,3 @@ void nvte_group_quantize_dbias_dgelu(const NVTEGroupedTensor input,
dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dgelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}

void nvte_group_quantize_dbias_dqgelu(const NVTEGroupedTensor input,
const NVTEGroupedTensor activation_input,
NVTEGroupedTensor output, NVTEGroupedTensor dbias,
NVTETensor workspace, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_quantize_dbias_dqgelu);
using namespace transformer_engine;

constexpr bool IS_DBIAS = true;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dqgelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}
17 changes: 17 additions & 0 deletions transformer_engine/common/activation/qgelu_grouped.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_qgelu(const NVTEGroupedTensor input, NVTEGroupedTensor output,
cudaStream_t stream) {
NVTE_API_CALL(nvte_group_qgelu);
using namespace transformer_engine;
constexpr bool IS_ACT = true;
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, qgelu<fp32, fp32>>(input, output, nullptr,
stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/qgelu_grouped_bwd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_dqgelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dqgelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dqgelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/qgelu_grouped_dbias.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_quantize_dbias_dqgelu(const NVTEGroupedTensor input,
const NVTEGroupedTensor activation_input,
NVTEGroupedTensor output, NVTEGroupedTensor dbias,
NVTETensor workspace, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_quantize_dbias_dqgelu);
using namespace transformer_engine;

constexpr bool IS_DBIAS = true;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dqgelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}
37 changes: 0 additions & 37 deletions transformer_engine/common/activation/relu_grouped.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,3 @@ void nvte_group_relu(const NVTEGroupedTensor input, NVTEGroupedTensor output, cu
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, relu<fp32, fp32>>(input, output, nullptr,
stream);
}

void nvte_group_drelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_drelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, drelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}

void nvte_group_srelu(const NVTEGroupedTensor input, NVTEGroupedTensor output,
cudaStream_t stream) {
NVTE_API_CALL(nvte_group_srelu);
using namespace transformer_engine;
constexpr bool IS_ACT = true;
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, srelu<fp32, fp32>>(input, output, nullptr,
stream);
}

void nvte_group_dsrelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dsrelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsrelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/relu_grouped_bwd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_drelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_drelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, drelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
14 changes: 0 additions & 14 deletions transformer_engine/common/activation/relu_grouped_dbias.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,3 @@ void nvte_group_quantize_dbias_drelu(const NVTEGroupedTensor input,
dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, drelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}

void nvte_group_quantize_dbias_dsrelu(const NVTEGroupedTensor input,
const NVTEGroupedTensor activation_input,
NVTEGroupedTensor output, NVTEGroupedTensor dbias,
NVTETensor workspace, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_quantize_dbias_dsrelu);
using namespace transformer_engine;

constexpr bool IS_DBIAS = true;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsrelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}
17 changes: 17 additions & 0 deletions transformer_engine/common/activation/srelu_grouped.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_srelu(const NVTEGroupedTensor input, NVTEGroupedTensor output,
cudaStream_t stream) {
NVTE_API_CALL(nvte_group_srelu);
using namespace transformer_engine;
constexpr bool IS_ACT = true;
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, srelu<fp32, fp32>>(input, output, nullptr,
stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/srelu_grouped_bwd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_dsrelu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dsrelu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsrelu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/srelu_grouped_dbias.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_quantize_dbias_dsrelu(const NVTEGroupedTensor input,
const NVTEGroupedTensor activation_input,
NVTEGroupedTensor output, NVTEGroupedTensor dbias,
NVTETensor workspace, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_quantize_dbias_dsrelu);
using namespace transformer_engine;

constexpr bool IS_DBIAS = true;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsrelu<fp32, fp32>>(
input, activation_input, output, dbias, workspace, nullptr, stream);
}
14 changes: 0 additions & 14 deletions transformer_engine/common/activation/swiglu_grouped.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,3 @@ void nvte_group_silu(const NVTEGroupedTensor input, NVTEGroupedTensor output, cu
dispatch::group_quantize_fwd_helper<IS_ACT, Empty, silu<fp32, fp32>>(input, output, nullptr,
stream);
}

void nvte_group_dsilu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dsilu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsilu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
22 changes: 22 additions & 0 deletions transformer_engine/common/activation/swiglu_grouped_bwd.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*************************************************************************
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* See LICENSE for license information.
************************************************************************/

#include "../util/math.h"
#include "./activation_template.h"

void nvte_group_dsilu(const NVTEGroupedTensor grad, const NVTEGroupedTensor input,
NVTEGroupedTensor output, cudaStream_t stream) {
NVTE_API_CALL(nvte_group_dsilu);
using namespace transformer_engine;
NVTEGroupedTensor dbias = nullptr;
NVTETensor workspace = nullptr;

constexpr bool IS_DBIAS = false;
constexpr bool IS_DACT = true;

dispatch::group_quantize_bwd_helper<IS_DBIAS, IS_DACT, Empty, dsilu<fp32, fp32>>(
grad, input, output, dbias, workspace, nullptr, stream);
}
Loading