@@ -283,6 +283,7 @@ class gemm_4bit_cutlass_kernel {
283283 }
284284#endif
285285#else
286+ #if 0
286287 using format_type = uint32_t; //32
287288 static constexpr auto src_bits = sizeof_bits_v<SrcType>; //4
288289 static constexpr auto scalar = sizeof_bits_v<format_type> / src_bits; // 8
@@ -324,6 +325,27 @@ class gemm_4bit_cutlass_kernel {
324325 }
325326 }
326327 }
328+ #endif
329+ using compress_type = uint8_t ;
330+ static constexpr auto compress_ratio = sizeof_bits_v<compress_type> / sizeof_bits_v<SrcType>;
331+ static constexpr auto K = decltype (size (out))::value / N;
332+ auto s_tensor = make_tensor ((compress_type*)(raw_pointer_cast (in.data ())), Shape<Int<K/compress_ratio>, Int<N>>{});
333+ auto d_tensor = make_tensor (out.data (), Shape<Int<K>, Int<N>>{});
334+
335+ #pragma unroll
336+ for (int n = 0 ; n < N; n++) {
337+ float ts = tCrS_input (n);
338+ // auto& src = *(cute::array<SrcType, splits>*)(s_tensor(_, n).data());
339+ // auto& dst = *(cute::array<DstType, splits>*)(d_tensor(_, n).data());
340+ auto & src = s_tensor (_, n).data ();
341+ auto & dst = d_tensor (_, n).data ();
342+
343+ #pragma unroll
344+ for (int k = 0 ; k < K/compress_ratio/2 ; k++) {
345+ dst[k * 2 + 1 ] = static_cast <DstType>(quant_map[src[k] >> 4 ] * ts);
346+ dst[k * 2 ] = static_cast <DstType>(quant_map[src[k] & 0x0f ] * ts);
347+ }
348+ }
327349#endif
328350 }
329351
0 commit comments