Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4de007e
Add SM120 NVFP4 blockscaled GEMM support
Jul 3, 2026
be805b1
Address SM120 NVFP4 review cleanup
Jul 8, 2026
0ce22e8
Remove SM120 private C-fragment store helpers
Jul 8, 2026
2bdaffb
Unify SM120 blockscaled MMA TIR helper
Jul 8, 2026
e84c318
Clean SM120 NVFP4 blockscaled fast path
Jul 8, 2026
c450de2
Prune SM120 NVFP4 debug lowering paths
Jul 8, 2026
850ebe2
Simplify SM120 NVFP4 blockscaled example
Jul 8, 2026
d4c646e
Remove SM120 fulltile debug macros and compile flags
Jul 9, 2026
1a1062d
Fix TensorCoreIntrinEmitter.mma base signature regression
Jul 9, 2026
66c8a30
Pin scale layout byte-compat with CuTeDSL blocked SF layout
Jul 9, 2026
3e4984e
Remove unreachable SM120 blockscale exploration code
Jul 10, 2026
be668c6
Scope shared-memory bit-exact sizing to packed scalar NVFP4
Jul 10, 2026
9c673b5
Add T.copy_ue4m3_scale_tile scale staging helper
Jul 10, 2026
790a3f0
Support M or N tail tiles in the SM120 NVFP4 example
Jul 10, 2026
f681a83
Slim tilelang/quantize/nvfp4.py
Jul 10, 2026
831652e
Converge quantizer kernels and drop example debug input modes
Jul 10, 2026
87d99c2
Keep tilelang.quantize to device helpers and format contract
Jul 10, 2026
cb81c7e
Import layout oracle from the nvfp4 submodule in the language test
Jul 10, 2026
c48e373
Group SM120 NVFP4 maint files and use native target API
Jul 21, 2026
c1ae801
Keep NVFP4 scale staging out of the tilelang.language surface
Jul 21, 2026
d3de762
Merge origin/main into nvf4-block-scale-sm120
Jul 21, 2026
1784d83
Drop stale scale-load metadata from the SM120 WS benchmark
Jul 21, 2026
317455c
Strip trailing blank lines left in gemm_op.py
Jul 21, 2026
b6f70a4
Trim the SF staging comment to the load-bearing caveat
Jul 21, 2026
c34e750
Consolidate NVFP4 tests into a single file
Jul 24, 2026
fceddda
Merge origin/main (language dialect split) into nvf4-block-scale-sm120
Jul 24, 2026
4ceee6c
Evaluate emitter dtype defaults lazily under the dialect facade
Jul 24, 2026
1fce4e9
Restore the scale-layout contract tests; keep the example CLI file fo…
Jul 24, 2026
97abc1f
Merge remote-tracking branch 'origin/main' into pr-2364-main-merge
LeiWang1999 Jul 28, 2026
70dec36
refactpr example
LeiWang1999 Jul 28, 2026
679f5f2
[SM120] Simplify NVFP4 benchmark
LeiWang1999 Jul 28, 2026
3c6cecc
[SM120] Simplify NVFP4 correctness comparison
LeiWang1999 Jul 28, 2026
5933fc9
[SM120] Inline NVFP4 quantizer pass configs
LeiWang1999 Jul 28, 2026
3e774df
[SM120] Move block-scaled MMA helper to instruction headers
LeiWang1999 Jul 28, 2026
53e3f20
[CUDA] Fix packed FP4 address codegen
LeiWang1999 Jul 28, 2026
2d69257
[SM120] Simplify NVFP4 lowering internals
LeiWang1999 Jul 28, 2026
d6a230d
[SM120] Generalize NVFP4 block-scaled MMA lowering
Rachmanino Jul 29, 2026
f29a144
[SM120] Fix package macro source test
LeiWang1999 Jul 30, 2026
bef4aff
Merge origin/main into nvf4-block-scale-sm120-pr-clean
LeiWang1999 Jul 30, 2026
9a8d1fc
[SM120] Remove redundant local FP4 access pointer test
LeiWang1999 Jul 30, 2026
a1b21a7
[SM120] Split block-scaled MMA emitter
LeiWang1999 Jul 30, 2026
ddd1098
Merge branch 'main' of https://github.com/tile-ai/tilelang into nvf4-…
LeiWang1999 Jul 30, 2026
11dae61
[SM120] Split block-scaled GEMM lowering
LeiWang1999 Jul 30, 2026
a0996a8
[SM120] Isolate block-scaled GEMM plumbing
LeiWang1999 Jul 30, 2026
acdd66b
Merge branch 'main' of https://github.com/tile-ai/tilelang into nvf4-…
LeiWang1999 Jul 30, 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
Prev Previous commit
Next Next commit
Fix TensorCoreIntrinEmitter.mma base signature regression
Merging the SM120 block-scale mode into TensorCoreIntrinEmitter changed
mma()'s 4th/5th positional parameters to SFA_buf/SFB_buf, so the plain
gemm lowering's positional mma(A_local, B_local, C_buf, ki) call bound
ki to SFA_buf and raised 'Scale buffers require TensorCoreIntrinEmitter
block-scale mode' for every non-blockscaled MMA GEMM (CI examples:
attention_sink, deepseek_nsa/mhc/v32).

Keep the base (A, B, C, k_inner) positional signature, make all
scale-related parameters keyword-only, forward k_inner to the base
implementation, and drop the unused blockscaled mma_atom override that
shadowed the base method the same way. Add a signature-contract
regression test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
  • Loading branch information
qutao and claude committed Jul 10, 2026
commit 1a1062da7bcb523e0bcff25f7ef3ff40e84fc465
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ def transform_func(i, j):
return T.Layout(shape, transform_func)


def test_tensor_core_intrin_emitter_mma_keeps_base_positional_signature():
"""The block-scale extension must not shift the base positional signature.

The non-blockscaled gemm lowering calls ``emitter.mma(A, B, C, ki)``
positionally, so every scale-related parameter has to stay keyword-only.
"""
import inspect

from tilelang.cuda.intrinsics.macro.mma_macro_generator import _TensorCoreIntrinEmitterBase

base = list(inspect.signature(_TensorCoreIntrinEmitterBase.mma).parameters.values())
override = list(inspect.signature(TensorCoreIntrinEmitter.mma).parameters.values())
assert [p.name for p in override[: len(base)]] == [p.name for p in base]
for extra in override[len(base) :]:
assert extra.kind == inspect.Parameter.KEYWORD_ONLY, extra.name


def test_sm120_mma_blockscaled_strategy_helpers_are_not_public_api():
assert not hasattr(T, "sm120_mma_blockscaled")
assert not hasattr(T, "sm120_mma_blockscaled_kblock_fulltile")
Expand Down
111 changes: 7 additions & 104 deletions tilelang/cuda/intrinsics/macro/mma_macro_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,18 +1762,21 @@ def mma(
A_local_buf,
B_local_buf,
C_local_buf,
k_inner: PrimExpr | None = 0,
*,
SFA_buf=None,
SFB_buf=None,
ki: PrimExpr = 0,
k_start: PrimExpr = 0,
sf_a_granularity_k: int | None = None,
sf_b_granularity_k: int | None = None,
sf_layout: str = "rowmajor",
):
# Keep the base-class positional signature (A, B, C, k_inner): the
# non-blockscaled gemm lowering calls mma(A_local, B_local, C_buf, ki).
if not self.is_blockscaled:
if SFA_buf is not None or SFB_buf is not None:
raise ValueError("Scale buffers require TensorCoreIntrinEmitter block-scale mode")
return super().mma(A_local_buf, B_local_buf, C_local_buf)
return super().mma(A_local_buf, B_local_buf, C_local_buf, k_inner)
if SFA_buf is None or SFB_buf is None:
raise ValueError("Block-scaled MMA requires SFA and SFB buffers")
warp_rows = self.warp_rows
Expand All @@ -1795,8 +1798,8 @@ def mma(
sf_vec_size = self.sf_vec_size
sf_a_granularity_k = sf_vec_size if sf_a_granularity_k is None else sf_a_granularity_k
sf_b_granularity_k = sf_vec_size if sf_b_granularity_k is None else sf_b_granularity_k
scale_a_word_k = self._scale_word_k(k_start, ki, sf_a_granularity_k)
scale_b_word_k = self._scale_word_k(k_start, ki, sf_b_granularity_k)
scale_a_word_k = self._scale_word_k(k_start, k_inner, sf_a_granularity_k)
scale_b_word_k = self._scale_word_k(k_start, k_inner, sf_b_granularity_k)
thread_binding = self.get_thread_binding()
SFA_data, SFA_other, SFA_base_m, SFA_base_k = self._scale_region_parts(SFA_buf)
SFB_data, SFB_other, SFB_base_n, SFB_base_k = self._scale_region_parts(SFB_buf)
Expand Down Expand Up @@ -3309,103 +3312,3 @@ def _warp_mma_block_scale_full_b_atom_prefetched(
SFB_local_buf,
SFB_rep_local_buf,
)

def mma_atom(
self,
A_local_buf,
B_local_buf,
C_local_buf,
SFA_buf,
SFB_buf,
inst_m_idx: PrimExpr | int,
inst_n_idx: PrimExpr | int,
ki: PrimExpr = 0,
k_start: PrimExpr = 0,
sf_a_granularity_k: int | None = None,
sf_b_granularity_k: int | None = None,
):
local_size_a = self.local_size_a
local_size_b = self.local_size_b
local_size_out = self.local_size_out
kind = self.kind
scale_vec_size = self.scale_vec_size
stype = self.stype
accum_dtype = self.accum_dtype
a_dtype_abbrv = self.a_dtype_abbrv
b_dtype_abbrv = self.b_dtype_abbrv
mma_prefix = self.mma_prefix
warp_cols = self.warp_cols
warp_row_tiles = self.warp_row_tiles
warp_col_tiles = self.warp_col_tiles
micro_size_x = self.micro_size_x
micro_size_y = self.micro_size_y
sf_vec_size = self.sf_vec_size
sf_a_granularity_k = sf_vec_size if sf_a_granularity_k is None else sf_a_granularity_k
sf_b_granularity_k = sf_vec_size if sf_b_granularity_k is None else sf_b_granularity_k
scale_a_word_k = self._scale_word_k(k_start, ki, sf_a_granularity_k)
scale_b_word_k = self._scale_word_k(k_start, ki, sf_b_granularity_k)
thread_binding = self.get_thread_binding()
SFA_data, SFA_other, SFA_base_m, SFA_base_k = self._scale_region_parts(SFA_buf)
SFB_data, SFB_other, SFB_base_n, SFB_base_k = self._scale_region_parts(SFB_buf)
replicate_b = self.n_dim == 16

@T.macro
def _warp_mma_block_scale_atom(A_local_buf, B_local_buf, C_local_buf, SFA_data, SFB_data, thread_binding):
tx, warp_n, warp_m = self.extract_thread_binding(thread_binding)
sfa_row = self._sfa_row_in_atom(tx)
sfb_col = self._sfb_col_in_atom(tx)
scale_m = warp_m * warp_row_tiles + inst_m_idx * micro_size_x + sfa_row
scale_n = warp_n * warp_col_tiles + inst_n_idx * micro_size_y + sfb_col
scale_a_ptr = T.access_ptr(
SFA_data[tuple(SFA_other) + (SFA_base_m + scale_m, SFA_base_k + scale_a_word_k)],
"r",
)
scale_b_ptr = T.access_ptr(
SFB_data[tuple(SFB_other) + (SFB_base_n + scale_n, SFB_base_k + scale_b_word_k)],
"r",
)
T.ptx_mma_block_scale(
accum_dtype,
mma_prefix,
"row",
"col",
kind,
scale_vec_size,
a_dtype_abbrv,
b_dtype_abbrv,
stype,
A_local_buf.data,
inst_m_idx * local_size_a,
B_local_buf.data,
0,
C_local_buf.data,
inst_m_idx * warp_cols * local_size_out + inst_n_idx * local_size_out,
scale_a_ptr,
scale_b_ptr,
)
if replicate_b:
scale_b_rep_ptr = T.access_ptr(
SFB_data[tuple(SFB_other) + (SFB_base_n + scale_n + 8, SFB_base_k + scale_b_word_k)],
"r",
)
T.ptx_mma_block_scale(
accum_dtype,
mma_prefix,
"row",
"col",
kind,
scale_vec_size,
a_dtype_abbrv,
b_dtype_abbrv,
stype,
A_local_buf.data,
inst_m_idx * local_size_a,
B_local_buf.data,
lift(local_size_b) // 2,
C_local_buf.data,
inst_m_idx * warp_cols * local_size_out + inst_n_idx * local_size_out + lift(local_size_out) // 2,
scale_a_ptr,
scale_b_rep_ptr,
)

return _warp_mma_block_scale_atom(A_local_buf, B_local_buf, C_local_buf, SFA_data, SFB_data, thread_binding)
6 changes: 3 additions & 3 deletions tilelang/cuda/op/gemm/gemm_mma.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ def _gemm_ss_blockscaled() -> None:
A_local,
B_local,
C_buf,
self.SFARegion,
self.SFBRegion,
ki=ki,
ki,
SFA_buf=self.SFARegion,
SFB_buf=self.SFBRegion,
k_start=self.sf_k_start,
sf_a_granularity_k=int(sf_a_granularity_k),
sf_b_granularity_k=int(sf_b_granularity_k),
Expand Down