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
8 changes: 0 additions & 8 deletions benchmarks/gemm/benchmark_gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ def _run():
ws,
ws_size,
False,
False,
)

for _ in range(num_warmup):
Expand Down Expand Up @@ -369,7 +368,6 @@ def _lead():
ws,
ws_size,
False,
False,
)

tflops, avg_ms = _time_with_cuda_events(_run, num_iters, flops, leading_fn=_lead)
Expand Down Expand Up @@ -512,7 +510,6 @@ def _run():
ws,
ws_size,
False,
False,
)

for _ in range(num_warmup):
Expand Down Expand Up @@ -547,7 +544,6 @@ def _lead():
ws,
ws_size,
False,
False,
)

tflops, avg_ms = _time_with_cuda_events(_run, num_iters, flops, leading_fn=_lead)
Expand Down Expand Up @@ -649,7 +645,6 @@ def _run():
ws,
ws_size,
False,
False,
)

for _ in range(num_warmup):
Expand Down Expand Up @@ -684,7 +679,6 @@ def _lead():
ws,
ws_size,
False,
False,
)

tflops, avg_ms = _time_with_cuda_events(_run, num_iters, flops, leading_fn=_lead)
Expand Down Expand Up @@ -784,7 +778,6 @@ def _run():
ws,
ws_size,
False,
False,
)

for _ in range(num_warmup):
Expand Down Expand Up @@ -819,7 +812,6 @@ def _lead():
ws,
ws_size,
False,
False,
)

tflops, avg_ms = _time_with_cuda_events(_run, num_iters, flops, leading_fn=_lead)
Expand Down
16 changes: 0 additions & 16 deletions benchmarks/linear/benchmark_grouped_gemm_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@
general_grouped_gemm_for_grouped_tensor,
)
from transformer_engine.pytorch.module import is_module_grouped_tensor_path_supported
from transformer_engine.pytorch.module.base import (
_2X_ACC_DGRAD,
_2X_ACC_FPROP,
_2X_ACC_WGRAD,
)
from transformer_engine.pytorch.quantization import FP8GlobalStateManager
from transformer_engine.pytorch.tensor import GroupedTensor, GroupedTensorStorage
import transformer_engine_torch as tex
Expand Down Expand Up @@ -322,15 +317,6 @@ def _assert_mxfp8_operands_are_gemm_ready(prepared: PreparedGemm) -> None:
), "MXFP8 operand was not prepared with GEMM-swizzled scales"


def _use_split_accumulator(spec: GemmSpec) -> bool:
"""Match GroupedLinear's accumulator policy for each training GEMM."""
if spec.gemm == "fwd":
return _2X_ACC_FPROP
if spec.gemm == "dgrad":
return _2X_ACC_DGRAD
return _2X_ACC_WGRAD


def _run_multistream(prepared: PreparedGemm, iterations: int) -> None:
"""Launch the multi-stream grouped GEMM repeatedly."""
spec = prepared.spec
Expand All @@ -345,7 +331,6 @@ def _run_multistream(prepared: PreparedGemm, iterations: int) -> None:
m_splits=prepared.split_sizes,
grad=spec.gemm != "fwd",
single_output=spec.gemm != "wgrad",
use_split_accumulator=_use_split_accumulator(spec),
)


Expand All @@ -357,7 +342,6 @@ def _run_cublas_grouped(prepared: PreparedGemm, iterations: int) -> None:
prepared.grouped_b,
prepared.grouped_out,
layout=prepared.spec.layout,
use_split_accumulator=_use_split_accumulator(prepared.spec),
)


Expand Down
9 changes: 8 additions & 1 deletion docs/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Key Features and Enhancements

-
-

## Fixed Issues

Expand All @@ -16,6 +16,13 @@
and their `_v2` variants, the configuration and parameter attribute accessors, and the C++
parameter wrappers. Use `transformer_engine.pytorch.DotProductAttention` or
`transformer_engine.jax.attention.fused_attn` instead.
- Remove the legacy split-accumulator option from GEMM APIs and
enable accurate FP8 accumulation automatically on Hopper. Remove
`use_split_accumulator` arguments, `transformer_engine.common.recipe.MMParams`,
and the recipe fields `fp8_gemm_fprop`, `fp8_gemm_dgrad`, and `fp8_gemm_wgrad`
from callers. Native consumers must rebuild against the updated C/C++ APIs.
The JAX environment variable `NVTE_FP8_GEMM_HIGH_PRECISION_ACCUMULATION` is
also removed; accurate accumulation is always used.

## Deprecated Features

Expand Down
8 changes: 7 additions & 1 deletion tests/cpp/operator/test_gemm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ void run_gemm_test(const GemmTestParams &params, bool with_C) {

// Launch GEMM
MatmulConfigWrapper config;
config.set_use_split_accumulator(true);
nvte_cublas_gemm_v2(transa, transb, &alpha, A.data(), B.data(), &beta,
with_C ? C.data() : nullptr, D.data(), workspace.data(), config, 0);
NVTE_CHECK_CUDA(cudaDeviceSynchronize());
Expand Down Expand Up @@ -314,6 +313,13 @@ TEST_P(GemmTestSuite, OutOfPlaceAccumulation) { run_gemm_test(GetParam(), true);
/* GEMM without accumulation input */
TEST_P(GemmTestSuite, NoAccumulationInput) { run_gemm_test(GetParam(), false); }

TEST(GemmTest, FP8LongReduction) {
for (size_t reduction_size : {4096, 16384}) {
run_gemm_test({{DType::kFloat8E4M3, DType::kFloat32}, {true, false}, {32, 32, reduction_size}},
false);
}
}

INSTANTIATE_TEST_SUITE_P(
OperatorTest, GemmTestSuite,
::testing::Combine(::testing::Values(std::make_pair(DType::kFloat32, DType::kFloat32),
Expand Down
17 changes: 1 addition & 16 deletions tests/cpp/operator/test_grouped_gemm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ struct GroupedGemmRefSetup {
std::vector<Tensor> B_tensors;
std::vector<Tensor> D_multi;
std::vector<Tensor> workspaces;
bool use_split_accum = false;
};

inline GroupedGemmRefSetup make_grouped_gemm_ref(const TestParams& params) {
Expand Down Expand Up @@ -350,8 +349,6 @@ inline GroupedGemmRefSetup make_grouped_gemm_ref(const TestParams& params) {
std::vector<size_t>{M, N}, params.output_dtype));
}

// FP8 block scaling requires split accumulator (no fast accumulation).
s.use_split_accum = is_fp8_block_recipe(params.recipe);

std::vector<NVTETensor> A_ptrs(s.num_gemms), B_ptrs(s.num_gemms), D_ptrs(s.num_gemms);
std::vector<NVTETensor> workspace_ptrs(s.num_gemms, nullptr);
Expand All @@ -368,7 +365,7 @@ inline GroupedGemmRefSetup make_grouped_gemm_ref(const TestParams& params) {
nvte_multi_tensor_gemm(A_ptrs.data(), B_ptrs.data(), D_ptrs.data(), bias_ptrs.data(),
gelu_ptrs.data(), static_cast<int>(s.num_gemms),
params.transa, params.transb, false, workspace_ptrs.data(),
false, s.use_split_accum, 0, 0);
false, 0, 0);
NVTE_CHECK_CUDA(cudaDeviceSynchronize());
return s;
}
Expand Down Expand Up @@ -518,9 +515,6 @@ void run_grouped_gemm_case(const TestParams& params) {
Tensor cublas_ws("cublas_ws", std::vector<size_t>{kCublasWorkspaceBytes}, DType::kByte);

GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) {
grouped_config.set_use_split_accumulator(true);
}

nvte_grouped_gemm(grouped_A.get_handle(), params.transa, grouped_B.get_handle(), params.transb,
params.use_null_c ? nullptr : grouped_C->get_handle(), grouped_D.get_handle(),
Expand Down Expand Up @@ -588,9 +582,6 @@ void run_grouped_gemm_discrete_out_case(const TestParams& params) {
Tensor cublas_ws("cublas_ws", std::vector<size_t>{kCublasWorkspaceBytes}, DType::kByte);

GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) {
grouped_config.set_use_split_accumulator(true);
}

nvte_grouped_gemm_with_discrete_out(
grouped_A.get_handle(), params.transa, grouped_B.get_handle(), params.transb,
Expand Down Expand Up @@ -677,9 +668,6 @@ void run_grouped_gemm_discrete_in_case(const TestParams& params) {
for (size_t i = 0; i < num_gemms; ++i) A_list_ptrs.push_back(ref.A_tensors[i].data());

GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) {
grouped_config.set_use_split_accumulator(true);
}

nvte_grouped_gemm_with_discrete_inputA(
A_list_ptrs.data(), num_gemms, params.transa, grouped_B.get_handle(), params.transb,
Expand Down Expand Up @@ -743,7 +731,6 @@ void run_grouped_gemm_graph_case(const TestParams& params) {
Tensor setup_ws("setup_ws", std::vector<size_t>{setup_ws_bytes}, DType::kByte);
Tensor cublas_ws("cublas_ws", std::vector<size_t>{kCublasWorkspaceBytes}, DType::kByte);
GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) grouped_config.set_use_split_accumulator(true);

cudaStream_t stream;
NVTE_CHECK_CUDA(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
Expand Down Expand Up @@ -816,7 +803,6 @@ void run_grouped_gemm_discrete_out_graph_case(const TestParams& params) {
Tensor setup_ws("setup_ws", std::vector<size_t>{setup_ws_bytes}, DType::kByte);
Tensor cublas_ws("cublas_ws", std::vector<size_t>{kCublasWorkspaceBytes}, DType::kByte);
GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) grouped_config.set_use_split_accumulator(true);

cudaStream_t stream;
NVTE_CHECK_CUDA(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
Expand Down Expand Up @@ -913,7 +899,6 @@ void run_grouped_gemm_discrete_in_graph_case(const TestParams& params) {
for (size_t i = 0; i < num_gemms; ++i) A_list_ptrs.push_back(ref.A_tensors[i].data());

GroupedMatmulConfigWrapper grouped_config;
if (ref.use_split_accum) grouped_config.set_use_split_accumulator(true);

cudaStream_t stream;
NVTE_CHECK_CUDA(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp_distributed/test_comm_gemm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class CommGemmFixure : public ::testing::TestWithParam<Params> {
auto aux_ref = Make<DType>(dims.d_rows_num, dims.d_cols_num, d_scale);
nvte_cublas_gemm(a.data(), b_ref.data(), d_ref.data(), bias.data(), aux_ref.data(), transa,
transb, grad, workspace.data(), accumulate,
true /* use_split_accumulator */, 0 /* math_sm_count */, stream);
0 /* math_sm_count */, stream);

std::vector<DType> out_ref(dims.d_rows_num * dims.d_cols_num);
NVTE_CHECK_CUDA(cudaMemcpy(out_ref.data(), d_ref.rowwise_dptr(),
Expand All @@ -378,7 +378,7 @@ class CommGemmFixure : public ::testing::TestWithParam<Params> {
auto aux_partial = Make<DType>(m, n, d_scale);
nvte_cublas_gemm(a.data(), b.data(), d_partial.data(), empty_bias.data(),
aux_partial.data(), transa, transb, grad, workspace.data(), accumulate,
true /* use_split_accumulator */, 0 /* math_sm_count */, stream);
0 /* math_sm_count */, stream);

std::vector<DType> partial_host(m * n);
NVTE_CHECK_CUDA(cudaMemcpy(partial_host.data(), d_partial.rowwise_dptr(),
Expand Down
6 changes: 0 additions & 6 deletions tests/pytorch/attention/test_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -4957,9 +4957,6 @@ def get_dummy_cuda_rng_tracker() -> CudaRNGStatesTracker:


_CUBLASLT_WORKSPACE_SIZE_BYTES = 33_554_432 # 32MiB
_2X_ACC_FPROP = False
_2X_ACC_DGRAD = False
_2X_ACC_WGRAD = False

META_QKV = FP8FwdTensorIdx.GEMM1_OUTPUT
META_DQKV = FP8BwdTensorIdx.GRAD_OUTPUT1
Expand Down Expand Up @@ -5014,7 +5011,6 @@ def forward(
bias=qkv_bias,
out_dtype=qkv_weight_fp8.dtype,
quantization_params=qkv_quantizer,
use_split_accumulator=_2X_ACC_FPROP,
)
qkv_layout = "bs3hd"
o_format = "bshd"
Expand Down Expand Up @@ -5141,7 +5137,6 @@ def backward(ctx, grad_output: torch.Tensor) -> Tuple[Union[torch.Tensor, None],
qkv_weight_fp8,
dqkv_c,
ctx.dtype,
use_split_accumulator=_2X_ACC_DGRAD,
layout="NN",
)

Expand All @@ -5150,7 +5145,6 @@ def backward(ctx, grad_output: torch.Tensor) -> Tuple[Union[torch.Tensor, None],
inp_fp8,
dqkv,
ctx.dtype,
use_split_accumulator=_2X_ACC_WGRAD,
layout="NT",
)

Expand Down
7 changes: 3 additions & 4 deletions tests/pytorch/attention/test_fused_mla.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,15 @@ def test_fused_mla_q_uproj_autograd() -> None:
gy = gy_quantizer(dq2d)

w.update_usage(rowwise_usage=True, columnwise_usage=True)
grad_ln_out_ref = _fused_general_gemm(
w, gy, layout="NN", grad=True, out_dtype=torch.bfloat16, use_split_accumulator=True
)[0]
grad_ln_out_ref = _fused_general_gemm(w, gy, layout="NN", grad=True, out_dtype=torch.bfloat16)[
0
]
grad_w_ref = _fused_general_gemm(
x_saved,
gy,
layout="NT",
grad=True,
out_dtype=torch.bfloat16,
use_split_accumulator=True,
)[0]
grad_x_ref, grad_gamma_ref = tex.rmsnorm_bwd(
grad_ln_out_ref.reshape(x2d.shape),
Expand Down
12 changes: 1 addition & 11 deletions tests/pytorch/debug/test_numerics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
Float8CurrentScalingQuantizer,
is_fp8_available,
)
from transformer_engine.pytorch.module.base import (
_2X_ACC_DGRAD,
_2X_ACC_FPROP,
_2X_ACC_WGRAD,
)

fp8_available, reason_for_no_fp8 = is_fp8_available(return_reason=True)

Expand Down Expand Up @@ -74,15 +69,14 @@ def _fake_cast(tensor, fp8_dtype, scale):
return fp8_tensor.dequantize()


def _fp8_gemm_kernel(tensor1, scale1, dtype1, tensor2, scale2, dtype2, use_split_accumulator):
def _fp8_gemm_kernel(tensor1, scale1, dtype1, tensor2, scale2, dtype2):
fp8_tensor1 = _cast_to_fp8(tensor1, scale1, dtype1)
fp8_tensor2 = _cast_to_fp8(tensor2, scale2, dtype2)

out, *_ = tepytorch.cpp_extensions.general_gemm(
fp8_tensor1,
fp8_tensor2,
torch.float32,
use_split_accumulator=use_split_accumulator,
)
out.requires_grad = True
return out.T
Expand Down Expand Up @@ -119,7 +113,6 @@ def _emulate_linear(
weight,
_scalar(fprop_weight_scale or 1.0),
tepytorch.DType.kFloat8E4M3,
_2X_ACC_FPROP,
)
activation = activation.clone().detach().contiguous().requires_grad_(True)
else:
Expand Down Expand Up @@ -155,7 +148,6 @@ def _emulate_linear(
gradient,
_scalar(dgrad_gradient_scale or 1.0),
tepytorch.DType.kFloat8E5M2,
_2X_ACC_DGRAD,
).T
else:
dgrad_gradient = (
Expand All @@ -179,7 +171,6 @@ def _emulate_linear(
gradient.T,
_scalar(wgrad_gradient_scale or 1.0),
tepytorch.DType.kFloat8E5M2,
_2X_ACC_WGRAD,
).T
else:
wgrad_gradient = (
Expand All @@ -200,7 +191,6 @@ def _emulate_linear(
torch.float32,
layout="NT",
grad=True,
use_split_accumulator=_2X_ACC_WGRAD,
)

return {"activation": activation, "wgrad": wgrad, "dgrad": dgrad}
Expand Down
Loading
Loading