Repository navigation
[Common] Allow column-wise output in the gated FP8 TMA cast (fixes FP8 gated activations on SM 12.0) - #3929
Closed
rlaope wants to merge 3 commits into
Closed
[Common] Allow column-wise output in the gated FP8 TMA cast (fixes FP8 gated activations on SM 12.0)#3929rlaope wants to merge 3 commits into
rlaope wants to merge 3 commits into
Conversation
cast_gated_tma rejected outputs that also request column-wise data, but the delayed-scaling dispatcher already fills column-wise data with a transpose of the row-wise output after either kernel runs. On SM 12.0, which needs both usages because it has no non-TN FP8 GEMM, every delayed-scaling gated activation with an FP8 output hit this assertion. Require row-wise data instead, which is what the kernel writes. Signed-off-by: rlaope <105429536+rlaope@users.noreply.github.com>
Request row-wise and column-wise data from a delayed-scaling FP8 quantizer for each gated activation and its backward, and check that the column-wise data is the transpose of the row-wise data. Signed-off-by: rlaope <105429536+rlaope@users.noreply.github.com>
Contributor
[Medium impact] The PR appears safe to merge; the previous test failure is fixed. SummaryAllows gated FP8 TMA casts to accept outputs with both row-wise and column-wise buffers.
Reviews (2) · Last reviewed commit: "[PyTorch] Skip the gated FP8 transpose t..." · Reviewed by Greptile |
8 of 13 tasks
…EMMs On those GPUs (e.g. SM 10.0) Float8Quantizer does not allocate a separate transpose buffer, so the test has nothing to compare. Signed-off-by: rlaope <105429536+rlaope@users.noreply.github.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On SM 12.0, every delayed-scaling FP8 gated activation (SwiGLU, GeGLU, ReGLU, QGeGLU, SReGLU, clamped SwiGLU) whose output is quantized fails in forward and backward with:
SM 12.0 has no non-TN FP8 GEMM (
is_non_tn_fp8_gemm_supported()is false), so the FP8 output quantizer asks for both row-wise and column-wise data. The dispatcher (cast/dispatch/gated.cuh) pickscast_gated_tmabecauseis_supported_by_CC_100()is true for SM 12.0, and BF16/FP16 fit in shared memory since #3600. The dispatcher already fills column-wise data after either kernel with a transpose of the row-wise output, which the non-TMAcast_gated_fwd/cast_gated_bwdpath relies on. The assertion incast_gated_tmais the only thing that blocks it. SM 10.0 does not hit this because it does not request column-wise data there.This PR replaces the assertion with a check that row-wise data, which the kernel writes, is allocated. It does not change any kernel.
Related: #3299 / #3600 fixed the FP32 shared-memory overflow in the same kernel. #2833 (open) disables the gated TMA kernels on SM 12.0 entirely. This change keeps the TMA kernel on SM 12.0 and touches only the assertion. If #2833 lands first, this PR still covers any other device without non-TN FP8 GEMMs that passes the shared-memory check.
Type of change
Changes
common/cast/fp8/gated_fp8.cuh:cast_gated_tmarequires row-wise output data instead of rejecting column-wise data. The dispatcher's existing transpose fills the column-wise data.tests/pytorch/test_fusible_ops.py: newtest_gated_activation_fp8_columnwise_output. It requests row-wise and column-wise data from aFloat8Quantizerfor each gated activation and its backward (FP32 and BF16 input), compares the row-wise result with the unquantized op, and checks that the column-wise data equals the transpose of the row-wise data. It runs on any FP8-capable GPU.Testing
Hardware: RTX PRO 6000 Blackwell Max-Q (SM 12.0, 99 KB shared memory per block), driver 590.48.01. Build:
mainat a6393d0,NVTE_FRAMEWORK=pytorch NVTE_CUDA_ARCHS=120, CUDA 13.0.88, torch 2.14.1+cu130, cuDNN 9.24. The A/B swaps onlylibtransformer_engine.so(main build vs patched build) under the same Python tree.pytest -n 2 tests/pytorch/test_fusible_ops.py tests/pytorch/test_sanity.py tests/pytorch/test_recipe.py:All 84 failures on main are this assertion:
TestBasicOps::test_activation(36),TestSequentialModules::test_layernorm_mlp(24),TestBasicOps::test_clamped_swiglu(16),TestBasicOps::test_swiglu(8), all withfp8_delayed_scaling. Each also fails when run alone.New test: main 10 failed (same assertion), this PR 10 passed.
End-to-end check:
te_ops.Sequential(Linear, SwiGLU/GEGLU/ReGLU, Linear)underDelayedScaling, 3 steps, BF16 and FP32. On main it raises the assertion. With this PR, output and gradient errors against the unquantized model matchFloat8CurrentScalingon the same model, for example SwiGLU BF16 at y 0.0645 vs 0.0644 and dx 0.0913 vs 0.0916.Not run: multi-GPU tests and other architectures. I have no SM 10.0 card. On SM 10.0 the change matters only when column-wise data is requested, and that case used to raise this same assertion.
Checklist: