You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cuda backend] store scale/zero in int4_plain_mm in [N, n_groups] layout (#20038)
This PR updates int4_plain_mm in cuda backend to reads scale/zero in the
transposed [N, n_groups] layout instead of [n_groups, N]. In this way
every warp can load both scale and zero together in one cache line,
instead of 32 cache lines previously.
gemma4-31b decode perf: ~27 token/s -> 37.36 token/s.
cc @digantdesai@freddan80@per@zingo@oscarandersson8218@mansnils@Sebastian-Larsson@robell@rascani
"aoti_torch_cuda_int4_plain_mm: group_size=%lld must be a positive power of 2",
64
+
static_cast<longlong>(group_size));
65
+
66
+
constint64_t n_groups = K / group_size;
67
+
68
+
ET_CHECK_OR_RETURN_ERROR(
69
+
scale->dim() == 2 && zero->dim() == 2,
70
+
InvalidArgument,
71
+
"aoti_torch_cuda_int4_plain_mm: scale/zero must be 2D (got scale.dim()=%lld, zero.dim()=%lld)",
72
+
static_cast<longlong>(scale->dim()),
73
+
static_cast<longlong>(zero->dim()));
74
+
75
+
ET_CHECK_OR_RETURN_ERROR(
76
+
scale->size(0) == N && zero->size(0) == N,
77
+
InvalidArgument,
78
+
"aoti_torch_cuda_int4_plain_mm: scale/zero must be coalesced [N, K/group_size] (AOT layout); native [n_groups, N] is not supported - repack via pack_linear_for_cuda. Expected size(0)=N=%lld, got scale.size(0)=%lld, zero.size(0)=%lld",
"aoti_torch_cuda_int4_plain_mm: scale/zero must be coalesced [N, K/group_size] (AOT layout); native [n_groups, N] is not supported - repack via pack_linear_for_cuda. Expected size(1)=K/group_size=%lld, got scale.size(1)=%lld, zero.size(1)=%lld",
0 commit comments