(a, qw, qzeros, scales, *, M, N, K, pack_num, group_size, w_bit, offset)
| 101 | |
| 102 | |
| 103 | def quant_matmul_v2(a, qw, qzeros, scales, *, M, N, K, pack_num, group_size, w_bit, offset): |
| 104 | c = torch.empty((M, N), dtype=torch.float16, device=a.device) |
| 105 | assert qw.shape == (K // pack_num, N) |
| 106 | # assert qzeros.shape == (K // group_size // pack_num, N) |
| 107 | # assert scales.shape == (K // group_size, N) |
| 108 | assert all(x.is_contiguous() for x in [a, qw, c, qzeros, scales]) |
| 109 | # BLOCK_SIZE_K has possible values of 32, 64 |
| 110 | # group_size, K must be divisible by BLOCK_SIZE_K |
| 111 | assert group_size % 64 == 0, f"group_size {group_size} is not a multiple of 64" |
| 112 | assert K % 64 == 0, f"K {K} is not a multiple of 64" |
| 113 | # BLOCK_SIZE_N has possible values of 32, 64, 128, 256 |
| 114 | # N must be divisible by BLOCK_SIZE_N |
| 115 | assert N % 256 == 0, f"N {N} is not a multiple of 256" |
| 116 | |
| 117 | grid_1d = lambda META: ( |
| 118 | triton.cdiv(M, META["BLOCK_SIZE_M"]) * triton.cdiv(N, META["BLOCK_SIZE_N"]), |
| 119 | ) |
| 120 | quant_matmul_kernel[grid_1d]( |
| 121 | a_ptr=a, |
| 122 | qw_ptr=qw, |
| 123 | c_ptr=c, |
| 124 | scales_ptr=scales, |
| 125 | zeros_ptr=qzeros, |
| 126 | M=M, |
| 127 | N=N, |
| 128 | K=K, |
| 129 | pack_num=pack_num, |
| 130 | w_bit=w_bit, |
| 131 | group_size=group_size, |
| 132 | offset=offset |
| 133 | ) |
| 134 | return c |
| 135 | |
| 136 | |
| 137 |
no outgoing calls
no test coverage detected