Skip to content

Commit 305f764

Browse files
committed
Reduce short-K NVFP4 accumulation overhead
1 parent 6bbb29e commit 305f764

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

test/test_nvfp4_tma.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def test_nvfp4_tma_scale_layout_and_paired_loads(block_n, num_compute_warps):
154154
torch.testing.assert_close(actual, expected, atol=2.0, rtol=0.05)
155155

156156

157-
def test_nvfp4_tma_pairwise_fp16_reduction_preserves_extreme_values():
158-
"""Keep the exact FP16 pairwise range before accumulating partials in FP32."""
157+
def test_nvfp4_tma_fp16_partial_reduction_preserves_extreme_values():
158+
"""Keep exact FP16 partial sums before accumulating them in FP32."""
159159
n, k = 128, 2048
160160
input_codes = torch.full((1, k), 7, dtype=torch.uint8, device="cuda")
161161
weight_codes = torch.full((n, k), 7, dtype=torch.uint8, device="cuda")

transformer_nuggets/cute/nvfp4_tma.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ def accumulate_scaled_products(
169169
weight_scales,
170170
):
171171
"""Accumulate two independently scaled 16-value E2M1 blocks."""
172+
fp16_reduction_width = 8 if self.k <= 4096 else 2
172173
products = (
173174
(x_values * w_values)
174-
.reshape((2, 8, 2))
175+
.reshape((fp16_reduction_width, 16 // fp16_reduction_width, 2))
175176
.reduce(
176177
cute.ReductionOp.ADD,
177178
cutlass.Float16(0.0),

0 commit comments

Comments
 (0)