Skip to content

[Common/PyTorch] Guard FP8 per-tensor scaling grouped GEMM on Hopper behind cuBLAS 13.5+#3181

Merged
ptrendx merged 2 commits into
NVIDIA:mainfrom
pggPL:grouped_gemm_fp8_hopper_guard
Jul 7, 2026
Merged

[Common/PyTorch] Guard FP8 per-tensor scaling grouped GEMM on Hopper behind cuBLAS 13.5+#3181
ptrendx merged 2 commits into
NVIDIA:mainfrom
pggPL:grouped_gemm_fp8_hopper_guard

Conversation

@pggPL

@pggPL pggPL commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Description

FP8 per-tensor (current/delayed scaling) grouped GEMM on Hopper requires cuBLAS 13.5+: cuBLAS 13.4 has no SM90 grouped GEMM algorithms for the PER_BATCH_SCALAR_32F scale mode, so cublasLtMatmulAlgoGetHeuristic returns CUBLAS_STATUS_NOT_SUPPORTED and the user gets a cryptic "Unable to find suitable cuBLAS grouped GEMM algorithm" error. This is exactly what happens in #3176 (NGC PyTorch 26.04 ships cuBLAS 13.4.0; reproduced on H100 — fails on cuBLAS 13.4.0, passes on 13.5.1 and 13.6.0). BF16 and FP8 block-scaling grouped GEMMs on Hopper work on 13.4 and keep their existing 13.4 gate.

This PR makes GroupedLinear fall back to the legacy multi-stream path when the fused grouped GEMM is not available for the current cuBLAS version, adds a dedicated version guard with a clear error message in the common library, and closes the test-coverage gap: the FP8Current grouped GEMM C++ tests were skipped on Hopper as Blackwell-only, so the only coverage of this path on SM90 was the PyTorch GroupedLinear tests, which CI runs on containers with cuBLAS 13.6.

Fixes #3176

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes

  • cublaslt_grouped_gemm.cu: add CUBLAS_FP8_TENSOR_SCALING_GROUPED_GEMM_HOPPER_VERSION (130500) and a runtime NVTE_CHECK on the FP8 tensor-scaling path for SM < 100 with an actionable error message.
  • transformer_engine/pytorch/module/grouped_linear.py and transformer_engine/pytorch/ops/basic/grouped_linear.py: route to the legacy multi-stream path instead of the fused GroupedTensor path when cuBLAS is too old (13.3+ general, 13.4+ Hopper, 13.5+ FP8 per-tensor scaling on Hopper).
  • tests/cpp/operator/test_grouped_gemm.cu: run FP8Current cases on Hopper with cuBLAS 13.5+ (previously skipped as Blackwell-only); skip with a clear reason on older cuBLAS.
  • tests/pytorch/test_grouped_linear.py: skip FP8 current scaling GroupedTensor tests on Hopper when cuBLAS < 13.5.

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

cuBLAS 13.4 has no SM90 grouped GEMM algorithms for the per-tensor
(PER_BATCH_SCALAR_32F) FP8 scale mode, so the heuristic query fails with
CUBLAS_STATUS_NOT_SUPPORTED and users get a cryptic "Unable to find
suitable cuBLAS grouped GEMM algorithm" error (see NVIDIA#3176). The support
is available starting with cuBLAS 13.5.

- Add CUBLAS_FP8_TENSOR_SCALING_GROUPED_GEMM_HOPPER_VERSION (130500) and
  a runtime check with a clear error message on the FP8 tensor-scaling
  grouped GEMM path.
- Enable the FP8Current grouped GEMM C++ tests on Hopper with
  cuBLAS 13.5+ (previously skipped as Blackwell-only, so this path had
  no C++ coverage on SM90).
- Skip FP8 current scaling GroupedLinear tests on Hopper when
  cuBLAS < 13.5 instead of failing in algorithm selection.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds clearer gating for FP8 tensor-scaling grouped GEMM on Hopper. The main changes are:

  • A cuBLAS 13.5 runtime check in the common grouped GEMM path.
  • Updated grouped GEMM C++ test skips for Hopper FP8 current scaling.
  • Updated PyTorch grouped-linear skips and grouped-path selection checks.
  • Notes in grouped-linear code about legacy fallback behavior.

Confidence Score: 4/5

This is close, but the fallback path should be fixed before merging.

  • Direct grouped-linear skips and path checks now cover Hopper with older cuBLAS.
  • The basic grouped-linear fallback can still send FP8 current-scaling grouped MLP work into the guarded C++ grouped GEMM path.
  • That case can still fail at runtime on Hopper with cuBLAS 13.4.

transformer_engine/pytorch/ops/basic/grouped_linear.py

Important Files Changed

Filename Overview
transformer_engine/common/gemm/cublaslt_grouped_gemm.cu Adds the Hopper cuBLAS 13.5 runtime check for FP8 tensor-scaling grouped GEMM.
transformer_engine/pytorch/module/grouped_linear.py Adds cuBLAS version gating to the module grouped-tensor path selection.
transformer_engine/pytorch/ops/basic/grouped_linear.py Adds cuBLAS version gating to the graph-safe path selection, but the fallback can still reach FP8 grouped GEMM.
tests/pytorch/test_grouped_linear.py Adds Hopper cuBLAS 13.5 skips for FP8 current-scaling grouped-linear tests.
tests/cpp/operator/test_grouped_gemm.cu Updates grouped GEMM skip reasons for Hopper FP8 current scaling.

Reviews (2): Last reviewed commit: "Fall back to legacy GroupedLinear path w..." | Re-trigger Greptile

Comment on lines +1062 to +1068
if (sm < 100) {
NVTE_CHECK(transformer_engine::cuda::cublas_version() >=
CUBLAS_FP8_TENSOR_SCALING_GROUPED_GEMM_HOPPER_VERSION,
"FP8 tensor scaling grouped GEMM on Hopper (SM90) requires cuBLAS 13.5+, "
"but run-time cuBLAS version is ",
transformer_engine::cuda::cublas_version());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Grouped MLP Tests Hit Guard

When FP8 current-scaling grouped MLP tests run on Hopper with cuBLAS 13.4, this new guard fails before algorithm selection. The grouped-linear tests now skip that runtime state, but the existing grouped-MLP current-scaling path still allows it, so the affected test run still ends in an NVTE_CHECK failure instead of a skip.

…vailable

Route around the fused GroupedTensor path instead of erroring out when
the cuBLAS version is too old: grouped GEMM needs cuBLAS 13.3+ (13.4+ on
Hopper), and FP8 per-tensor current scaling on Hopper needs 13.5+. Both
the module (_is_grouped_tensor_path_supported) and the ops
(_is_graph_safe_path_supported) checks now fall back to the legacy
multi-stream path in these cases.

Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
@pggPL pggPL requested review from ksivaman and timmoon10 as code owners July 6, 2026 20:53
Comment on lines +799 to +800
):
return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fallback still hits guard

Returning False here only disables the graph-safe grouped path. The caller can then use the split-quantize fallback, which still calls general_grouped_gemm with FP8 tensors for current-scaling grouped MLP cases. On Hopper with cuBLAS 13.4, that fallback reaches the new C++ cuBLAS 13.5 check and raises NVTE_CHECK instead of avoiding the unsupported grouped GEMM path. The Hopper/cuBLAS<13.5 case needs to skip this path or route it away from FP8 grouped GEMM before the fallback call.

@timmoon10 timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vthumbe1503

vthumbe1503 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

/te-ci

@ptrendx ptrendx merged commit 50bd21b into NVIDIA:main Jul 7, 2026
21 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PyTorch] grouped linear with fp8 current scaling fails with exception: Unable to find suitable cuBLAS grouped GEMM algorithm

4 participants