| 182 | } |
| 183 | |
| 184 | torch::Tensor code1x16_dequant( |
| 185 | const torch::Tensor& codes, |
| 186 | const torch::Tensor& codebooks, |
| 187 | const torch::Tensor& scales |
| 188 | ) { |
| 189 | check_use_bfloat16(codebooks); |
| 190 | auto in_features = codes.size(1) * codebooks.size(3); |
| 191 | auto out_features = scales.size(0); |
| 192 | |
| 193 | auto weight = torch::empty({out_features, in_features}, |
| 194 | torch::TensorOptions() |
| 195 | .dtype(codebooks.dtype()) |
| 196 | .device(codebooks.device()) |
| 197 | ); |
| 198 | if (codebooks.size(3) == 8) { |
| 199 | code1x16_dequant_cuda<8>( |
| 200 | codes.data_ptr(), |
| 201 | weight.data_ptr(), |
| 202 | codebooks.data_ptr(), |
| 203 | out_features, |
| 204 | in_features |
| 205 | ); |
| 206 | } else if (codebooks.size(3) == 16) { |
| 207 | code1x16_dequant_cuda<16>( |
| 208 | codes.data_ptr(), |
| 209 | weight.data_ptr(), |
| 210 | codebooks.data_ptr(), |
| 211 | out_features, |
| 212 | in_features |
| 213 | ); |
| 214 | } else { |
| 215 | throw c10::NotImplementedError( |
| 216 | {__func__, __FILE__, static_cast<uint32_t>(__LINE__)}, |
| 217 | c10::str( |
| 218 | "AQLM CUDA kernels only support codebooks with 8 or 16 features. Got ", |
| 219 | codebooks.size(3), |
| 220 | "." |
| 221 | ) |
| 222 | ); |
| 223 | } |
| 224 | weight *= scales.index({"...", 0, 0}); |
| 225 | |
| 226 | return weight; |
| 227 | } |
| 228 | |
| 229 | int4 accumulate_sizes(const torch::Tensor& codebook_partition_sizes) |
| 230 | { |
nothing calls this directly
no test coverage detected