Repository navigation
Add CuTeDSL MXFP8 M-groups scale rearrange kernel - #4585
alexsamardzic wants to merge 8 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4585
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (5 Unrelated Failures)As of commit 571a062 with merge base 3818749 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This PR adds a CuTeDSL implementation of the existing CUDA Benchmarking results
Benchmarking command to produce the table above{
for c in 37 45 64 160 224 320 512 768 1024 1025 1536 2048 2049 3072 4096 4097; do
PYTHONPATH=$PWD python scripts/validate_m_groups_cutedsl.py \
--rows 131072 --cols $c --groups 8 --multiple-of 32
done
} 2>/dev/null | perl -ne '
BEGIN {
print "| MxK | CUDA us | Triton us | CuTeDSL us | Triton speedup | CuTeDSL speedup |\n";
print "|---:|---:|---:|---:|---:|---:|\n";
}
if (/shape=\((\d+),\s*(\d+)\)/) {
$shape = "$1x$2";
$triton_ok = undef;
$cutedsl_ok = undef;
}
elsif (/triton_equal=(True|False)/) {
$triton_ok = $1;
die "triton_equal=False for $shape\n" if $triton_ok ne "True";
}
elsif (/cutedsl_equal=(True|False)/) {
$cutedsl_ok = $1;
die "cutedsl_equal=False for $shape\n" if $cutedsl_ok ne "True";
}
elsif (/cuda_us=([\d.]+)/) { $cuda = $1; }
elsif (/triton_us=([\d.]+)/) { $triton = $1; }
elsif (/cutedsl_us=([\d.]+)/) {
$cutedsl = $1;
die "missing correctness lines for $shape\n"
unless defined($triton_ok) && defined($cutedsl_ok);
printf "| %s | %.2f | %.2f | %.2f | %.2f | %.2f |\n",
$shape, $cuda, $triton, $cutedsl, $cuda / $triton, $cuda / $cutedsl;
}Edit: Some additional benchmarking results: Benchmarking results, for M/K being powers of two
Benchmarking results, for M/K derived from some realistic (Mixtral, Qwen, Deepseek, Llama) models
For all benchmarking, 8 groups case is used. Summary: CuTeDSL kernel is on par or better than CUDA kernel, while Triton kernel lags behind in performance. |
| out_cuda = mx_block_rearrange_2d_M_groups_cuda(scales_ref, offsets) | ||
| out_triton = triton_mx_block_rearrange_2d_M_groups(scales_ref, offsets) |
There was a problem hiding this comment.
matching these is good. Do we have a plain PyTorch reference? We should also match against that, and do that in a unit test.
There was a problem hiding this comment.
Added test_cutedsl_mx_block_rearrange_2d_M_groups test to check against PyTorch reference.
|
Replaced by #4701. |
Stack from ghstack (oldest at bottom):