| 121 | } |
| 122 | |
| 123 | std::vector<at::Tensor> ds_swizzle_quant(at::Tensor& input_vals, |
| 124 | int groups, |
| 125 | int num_bits, |
| 126 | quantize::Type quant_type, |
| 127 | int pipeline_size, |
| 128 | int nodes, |
| 129 | int devices_per_node) |
| 130 | { |
| 131 | auto scales_options = at::TensorOptions() |
| 132 | .dtype(at::kFloat) |
| 133 | .layout(at::kStrided) |
| 134 | .device(at::kCUDA) |
| 135 | .requires_grad(false); |
| 136 | const int scales_elems = (quantize::requires_offset(quant_type)) ? 2 : 1; |
| 137 | auto scales = torch::empty({groups, scales_elems}, scales_options); |
| 138 | |
| 139 | auto output_options = at::TensorOptions() |
| 140 | .dtype(at::kChar) |
| 141 | .layout(at::kStrided) |
| 142 | .device(at::kCUDA) |
| 143 | .requires_grad(false); |
| 144 | |
| 145 | const int quantization_scalar = 8 / num_bits; |
| 146 | const int compressed_vals = at::numel(input_vals) / quantization_scalar; |
| 147 | |
| 148 | auto output = torch::empty({compressed_vals}, output_options); |
| 149 | const int elems_per_group = at::numel(input_vals) / groups; |
| 150 | |
| 151 | launch_swizzled_quant((int8_t*)output.data_ptr(), |
| 152 | (float*)scales.data_ptr(), |
| 153 | (__half*)input_vals.data_ptr(), |
| 154 | num_bits, |
| 155 | quant_type, |
| 156 | groups, |
| 157 | elems_per_group, |
| 158 | pipeline_size, |
| 159 | nodes, |
| 160 | devices_per_node, |
| 161 | at::cuda::getCurrentCUDAStream()); |
| 162 | |
| 163 | return {output, scales}; |
| 164 | } |
| 165 | |
| 166 | std::vector<at::Tensor> quantized_reduction(at::Tensor& input_vals, |
| 167 | at::Tensor& input_scales, |
nothing calls this directly
no test coverage detected