Skip to content

Commit c4ed78b

Browse files
[Compile] Fix Compile Warning for w4a8_mm_entry.cu (#23660)
Signed-off-by: yewentao256 <[email protected]> Co-authored-by: Luka Govedič <[email protected]>
1 parent 1bd007f commit c4ed78b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

csrc/quantization/cutlass_w4a8/w4a8_mm_entry.cu

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "core/registration.h"
1212

1313
#include "cutlass/cutlass.h"
14+
#include <limits>
1415

1516
#include "cute/tensor.hpp"
1617
#include "cutlass/gemm/collective/collective_builder.hpp"
@@ -169,6 +170,11 @@ struct W4A8GemmKernel {
169170
int k = A.size(1);
170171
int n = B.size(1);
171172

173+
// safely cast group_size to int
174+
TORCH_CHECK(group_size > 0 && group_size <= std::numeric_limits<int>::max(),
175+
"group_size out of supported range for int: ", group_size);
176+
int const group_size_int = static_cast<int>(group_size);
177+
172178
// Allocate output
173179
const at::cuda::OptionalCUDAGuard device_guard(device_of(A));
174180
auto device = A.device();
@@ -192,7 +198,7 @@ struct W4A8GemmKernel {
192198
cute::tile_to_shape(LayoutAtomQuant{}, shape_B);
193199

194200
// strides
195-
int const scale_k = cutlass::ceil_div(k, group_size);
201+
int const scale_k = cutlass::ceil_div(k, group_size_int);
196202
StrideA stride_A =
197203
cutlass::make_cute_packed_stride(StrideA{}, cute::make_shape(m, k, 1));
198204
// Reverse stride here due to swap and transpose
@@ -211,8 +217,8 @@ struct W4A8GemmKernel {
211217
using EpilogueArguments = typename GemmKernelShuffled::EpilogueArguments;
212218

213219
MainloopArguments mainloop_arguments{
214-
B_ptr, layout_B_reordered, A_ptr, stride_A,
215-
S_ptr, stride_S, group_size};
220+
B_ptr, layout_B_reordered, A_ptr, stride_A,
221+
S_ptr, stride_S, group_size_int};
216222

217223
EpilogueArguments epilogue_arguments{
218224
ChTokScalesEpilogue::prepare_args(channel_scales, token_scales),

0 commit comments

Comments
 (0)