Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7c3abf6
[Common] More CuTeDSL MXFP8 special kernels
kainzhong Oct 7, 2026
6e854d5
Merge branch 'main' into more_cutedsl_mxfp8_specialized
kainzhong Oct 7, 2026
1be6447
wip
kainzhong Oct 8, 2026
1995fea
wip
kainzhong Oct 8, 2026
3e7a653
refactor
kainzhong Oct 9, 2026
79c5d53
refactor
kainzhong Oct 9, 2026
c51a3b8
refactor
kainzhong Oct 9, 2026
f14e433
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 9, 2026
5f9ece2
fix
kainzhong Oct 9, 2026
870b23c
disable invariant temporarily
kainzhong Oct 9, 2026
4ef3404
fix
kainzhong Oct 10, 2026
ef9877d
refactor
kainzhong Oct 12, 2026
d6bb258
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2026
fffc874
fix
kainzhong Oct 12, 2026
2fd0aca
fix
kainzhong Oct 12, 2026
8afd230
also support swizzled scale for g2r bidim
kainzhong Oct 12, 2026
87ab24e
lint
kainzhong Oct 12, 2026
cae94f5
add tests
kainzhong Oct 12, 2026
f67b1e5
fix
kainzhong Oct 12, 2026
177647e
nit
kainzhong Oct 12, 2026
8f4c54d
refactor
kainzhong Oct 13, 2026
fddd076
refactor
kainzhong Oct 14, 2026
3a8a882
more refactor
kainzhong Oct 14, 2026
30c92ab
g2r bidim can also support colwise only
kainzhong Oct 14, 2026
5c3465a
make g2r support activations
kainzhong Oct 15, 2026
b1db277
fix
kainzhong Oct 15, 2026
dcd8b08
fix
kainzhong Oct 15, 2026
86233c8
+0 and -0 should both legal
kainzhong Oct 15, 2026
dba8dbf
nit
kainzhong Oct 15, 2026
287505f
fix
kainzhong Oct 17, 2026
2c6f6ec
fix
kainzhong Oct 20, 2026
53bc647
close fp32 perf gap
kainzhong Oct 21, 2026
bfdb240
can always use static tile num
kainzhong Oct 21, 2026
1311481
nit
kainzhong Oct 28, 2026
64c2131
nit
kainzhong Oct 28, 2026
ce1f5c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2026
44d2c22
Merge branch 'main' into more_cutedsl_mxfp8_specialized
tdophung Oct 28, 2026
ddc34a2
the scale is so annoying
kainzhong Nov 5, 2026
579c3f1
refactor
kainzhong Nov 5, 2026
cce675c
Merge branch 'main' into cutedsl_mxfp8_dequant
kainzhong Nov 9, 2026
2706da2
fix
kainzhong Nov 10, 2026
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
40 changes: 40 additions & 0 deletions tests/pytorch/mxfp8/test_mxfp8_cutedsl_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,43 @@ def test_specialized_kernels(shape, block_size, in_dtype, swizzled, input_offset
swizzled,
input_offset,
)


OUT_DTYPES = [torch.float32, torch.bfloat16, torch.float16]
DEQUANT_SHAPES = MATRIX_SIZES + [(100, 48)]


# Test cases for dequantization (mirrors C++ test's OperatorTest_DequantizeMXFP8).
# With both data copies present, dequantize reads the rowwise one.
@pytest.mark.parametrize("shape", DEQUANT_SHAPES, ids=get_shape_id)
@pytest.mark.parametrize("block_size", BLOCK_SIZES, ids=get_block_id)
@pytest.mark.parametrize("out_dtype", OUT_DTYPES, ids=get_dtype_id)
@pytest.mark.parametrize("fp8_dtype", FP8_DTYPES, ids=get_fp8_id)
@pytest.mark.parametrize("swizzled", SWIZZLE_MODES, ids=get_swizzle_id)
def test_dequantize(swizzled, fp8_dtype, out_dtype, block_size, shape):
M, N = shape
rowwise = block_size[1] != 1
columnwise = block_size[0] != 1
x, _ = generate_inputs(M, N, torch.bfloat16)
set_cutedsl_backend(False)
q = MXFP8Quantizer(fp8_dtype=fp8_dtype, rowwise=rowwise, columnwise=columnwise)
q.optimize_for_gemm = swizzled
qx = q(x)
out_cuda = qx.dequantize(dtype=out_dtype)

set_cutedsl_backend(True)
try:
out_cutedsl = qx.dequantize(dtype=out_dtype)
finally:
set_cutedsl_backend(False)

major, minor = device_compute_capability()
key = (
f"cutedsl_mxfp8_dequant_sm{major * 10 + minor}_{FP8_TO_KEY[fp8_dtype]}_"
f"{DTYPE_TO_STR[out_dtype]}_{int(rowwise)}_{int(columnwise)}_{int(swizzled)}"
)
assert tvm_ffi.get_global_func(key, allow_missing=True) is not None, (
f"CuTeDSL kernel not registered for {key}; the CuTeDSL backend fell back "
"to CUDA and this case compared CUDA against itself"
)
assert torch.equal(out_cutedsl, out_cuda)
6 changes: 6 additions & 0 deletions transformer_engine/common/CuTeDSL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import tvm_ffi

from transformer_engine.common.CuTeDSL.cast.mxfp8.dequantize_mxfp8 import (
get_mxfp8_dequantization_function,
)
from transformer_engine.common.CuTeDSL.cast.mxfp8.quantize_mxfp8_common import (
get_mxfp8_quantization_function,
)
Expand All @@ -25,6 +28,9 @@ def register_cutedsl_backends():
tvm_ffi.register_global_func(
"get_mxfp8_quantization_function", get_mxfp8_quantization_function, override=True
)
tvm_ffi.register_global_func(
"get_mxfp8_dequantization_function", get_mxfp8_dequantization_function, override=True
)
tvm_ffi.register_global_func(
"get_mxfp8_requantization_function", get_mxfp8_requantization_function, override=True
)
3 changes: 2 additions & 1 deletion transformer_engine/common/CuTeDSL/cast/mxfp8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# See LICENSE for license information.

"""CuTeDSL MXFP8 quantization kernels."""
"""CuTeDSL MXFP8 quantization and dequantization kernels."""

from . import dequantize_mxfp8
from . import quantize_mxfp8_common
Loading
Loading