project_name
string
class_name
string
class_modifiers
string
class_implements
int64
class_extends
int64
function_name
string
function_body
string
cyclomatic_complexity
int64
NLOC
int64
num_parameter
int64
num_token
int64
num_variable
int64
start_line
int64
end_line
int64
function_index
int64
function_params
string
function_variable
string
function_return_type
string
function_body_line_type
string
function_num_functions
int64
function_num_lines
int64
outgoing_function_count
int64
outgoing_function_names
string
incoming_function_count
int64
incoming_function_names
string
lexical_representation
string
pytorch_ao
public
public
0
0
test_weight_t_and_non_t_numerics_match
def test_weight_t_and_non_t_numerics_match(self):# verify that numerics match whether weight is stored# in transposed format (for cuBLAS) vs non-transposed format# (for torch.compile)dtype = torch.halfdevice = "cuda"lin_ref = nn.Linear(32, 16, dtype=dtype, device=device)lin_eager_t = copy.deepcopy(lin_ref)lin_opt_t = c...
3
36
1
308
0
379
431
379
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_t_and_non_t_numerics_match) defined within the public class called public.The function start at line 379 and ends at 431. It contains 36 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_selective_torch_compile
def test_selective_torch_compile(self):m = nn.Sequential(nn.Linear(4, 4),nn.Sequential(nn.Linear(4, 4),nn.Linear(4, 4),),nn.Linear(4, 4),)x = torch.randn(4, 4)y_ref = m(x)_replace_with_custom_fn_if_matches_filter(m,lambda mod: torch.compile(mod),lambda mod, fqn: isinstance(mod, nn.Linear) and fqn != "1.0",)self.assertT...
2
22
1
201
0
433
457
433
null
[]
None
null
0
0
0
null
0
null
The function (test_selective_torch_compile) defined within the public class called public.The function start at line 433 and ends at 457. It contains 22 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_debug_x_absmax
def test_debug_x_absmax(self):m = nn.Sequential(nn.Linear(3, 4))x0 = torch.randn(4, 5, 3)m(x0)swap_linear_with_smooth_fq_linear(m)# no calibration, straight to inference, should not crashsmooth_fq_linear_to_inference(m, debug_skip_calibration=True)m(x0)
1
7
1
52
0
459
466
459
null
[]
None
null
0
0
0
null
0
null
The function (test_debug_x_absmax) defined within the public class called public.The function start at line 459 and ends at 466. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_dynamic_quant_per_channel_numerics_impl
def _test_dynamic_quant_per_channel_numerics_impl(self, qmin, qmax, int_dtype, qint_dtype, float_dtype, device):# verifies that dynamic quant per channel in plain pytorch matches# numerics of production AO code# TODO(future): test this on cpu-half, need to first make# torch.aminmax support half on cpux = torch.randn(16...
2
35
7
275
0
470
523
470
null
[]
None
null
0
0
0
null
0
null
The function (_test_dynamic_quant_per_channel_numerics_impl) defined within the public class called public.The function start at line 470 and ends at 523. It contains 35 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [470.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dynamic_quant_per_channel_numerics_cpu
def test_dynamic_quant_per_channel_numerics_cpu(self):test_cases = ((-128, 127, torch.int8, torch.qint8, torch.float32, "cpu"),)for row in test_cases:self._test_dynamic_quant_per_channel_numerics_impl(*row)
2
4
1
42
0
525
528
525
null
[]
None
null
0
0
0
null
0
null
The function (test_dynamic_quant_per_channel_numerics_cpu) defined within the public class called public.The function start at line 525 and ends at 528. It contains 4 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_dynamic_quant_per_channel_numerics_cuda
def test_dynamic_quant_per_channel_numerics_cuda(self):test_cases = ((-128, 127, torch.int8, torch.qint8, torch.float32, "cuda"),(-128, 127, torch.int8, torch.qint8, torch.float16, "cuda"),)for row in test_cases:self._test_dynamic_quant_per_channel_numerics_impl(*row)
2
7
1
63
0
532
538
532
null
[]
None
null
0
0
0
null
0
null
The function (test_dynamic_quant_per_channel_numerics_cuda) defined within the public class called public.The function start at line 532 and ends at 538. It contains 7 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_quantize_per_token_impl
def _test_quantize_per_token_impl(self, device, dtype):x = torch.randn(3, 3, 3, device=device, dtype=dtype)xq, scales = _quantize_activation_per_token_absmax(x)block_size = (1, 1, 3)x_dq = dequantize_affine(xq, block_size, scales, None, torch.int8, output_dtype=x.dtype)sqnr = compute_error(x, x_dq)self.assertTrue(sqnr ...
1
9
3
86
0
540
548
540
null
[]
None
null
0
0
0
null
0
null
The function (_test_quantize_per_token_impl) defined within the public class called public.The function start at line 540 and ends at 548. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [540.0] and does not return any value..
pytorch_ao
public
public
0
0
test_quantize_per_token_cpu
def test_quantize_per_token_cpu(self):for dtype in (torch.float32, torch.float16, torch.bfloat16):self._test_quantize_per_token_impl("cpu", dtype)
2
3
1
30
0
550
552
550
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_per_token_cpu) defined within the public class called public.The function start at line 550 and ends at 552. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_quantize_per_token_cuda
def test_quantize_per_token_cuda(self):for dtype in (torch.float32, torch.float16, torch.bfloat16):self._test_quantize_per_token_impl("cuda", dtype)
2
3
1
30
0
555
557
555
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_per_token_cuda) defined within the public class called public.The function start at line 555 and ends at 557. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_quantize_per_token_xpu
def test_quantize_per_token_xpu(self):for dtype in (torch.float32, torch.float16, torch.bfloat16):self._test_quantize_per_token_impl("xpu", dtype)
2
3
1
30
0
560
562
560
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_per_token_xpu) defined within the public class called public.The function start at line 560 and ends at 562. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_per_token_linear_impl
def _test_per_token_linear_impl(self, device, dtype):x = torch.randn(2, 16, 8, device=device, dtype=dtype)w = torch.randn(16, 8, device=device, dtype=dtype)wq, w_scales, _w_zp = dynamically_quantize_per_channel(w, -127, 127, torch.int8)# Note: need to make the weight contiguous because we are# testing in eager mode and...
1
10
3
120
0
564
576
564
null
[]
None
null
0
0
0
null
0
null
The function (_test_per_token_linear_impl) defined within the public class called public.The function start at line 564 and ends at 576. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [564.0] and does not return any value..
pytorch_ao
public
public
0
0
test_per_token_linear_cpu
def test_per_token_linear_cpu(self):for dtype in (torch.float32,):self._test_per_token_linear_impl("cpu", dtype)
2
3
1
23
0
578
580
578
null
[]
None
null
0
0
0
null
0
null
The function (test_per_token_linear_cpu) defined within the public class called public.The function start at line 578 and ends at 580. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_per_token_linear_cuda
def test_per_token_linear_cuda(self):for dtype in (torch.float32, torch.float16, torch.bfloat16):self._test_per_token_linear_impl("cuda", dtype)
2
3
1
30
0
584
586
584
null
[]
None
null
0
0
0
null
0
null
The function (test_per_token_linear_cuda) defined within the public class called public.The function start at line 584 and ends at 586. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test__int_mm
def test__int_mm(self):# TODO(future): figure out what here needs to move to PT core,# if it's not already tested therem, k, n = 32, 32, 16x = torch.randint(-128, 127, (m, k), dtype=torch.int8, device="cuda")w = torch.randint(-128, 127, (k, n), dtype=torch.int8, device="cuda")y_ref = torch.matmul(x.float(), w.float())....
1
10
1
159
0
589
607
589
null
[]
None
null
0
0
0
null
0
null
The function (test__int_mm) defined within the public class called public.The function start at line 589 and ends at 607. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test__int_mm_eager_and_torch_compile_numerics.__int_mm_ref
def __int_mm_ref(x, w):x = x.cpu().to(torch.int32)w = w.cpu().to(torch.int32)y = torch.matmul(x, w)return y.cuda()
1
5
2
51
0
611
615
611
null
[]
None
null
0
0
0
null
0
null
The function (test__int_mm_eager_and_torch_compile_numerics.__int_mm_ref) defined within the public class called public.The function start at line 611 and ends at 615. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [611.0] and does not return any value..
pytorch_ao
public
public
0
0
test__int_mm_eager_and_torch_compile_numerics.wrap_torch_int_mm
def wrap_torch_int_mm(x, w):b, n, k = x.shapek, m = w.shapex = x.reshape(b * n, k)res = safe_int_mm(x, w)res = res.reshape(b, n, m)return res
1
7
2
57
0
631
637
631
null
[]
None
null
0
0
0
null
0
null
The function (test__int_mm_eager_and_torch_compile_numerics.wrap_torch_int_mm) defined within the public class called public.The function start at line 631 and ends at 637. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [631.0] and does not return any value..
pytorch_ao
public
public
0
0
test__int_mm_eager_and_torch_compile_numerics
def test__int_mm_eager_and_torch_compile_numerics(self):def __int_mm_ref(x, w):x = x.cpu().to(torch.int32)w = w.cpu().to(torch.int32)y = torch.matmul(x, w)return y.cuda()shapes = (# minimal test shape((1, 32, 32), (32, 16)),# paste of real linear shapes from LLaMa 1.5b((17, 1, 1536), (1536, 1536)),((17, 8, 4096), (4096...
2
23
1
250
0
610
654
610
null
[]
None
null
0
0
0
null
0
null
The function (test__int_mm_eager_and_torch_compile_numerics) defined within the public class called public.The function start at line 610 and ends at 654. It contains 23 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_dequantize_impl
def _test_dequantize_impl(self,test_subclass_from_float,test_device,min_sqnr=35,test_dtype=torch.bfloat16,test_shape=(32, 64, 64),):m, k, n = test_shapelin = torch.nn.Linear(k, n, device=test_device).to(test_dtype)w = lin.weight.detach()lin.weight = torch.nn.Parameter(test_subclass_from_float(lin.weight), requires_grad...
1
24
8
142
0
659
682
659
null
[]
None
null
0
0
0
null
0
null
The function (_test_dequantize_impl) defined within the public class called public.The function start at line 659 and ends at 682. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [659.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dequantize_int8_dynamic_quant_subclass
def test_dequantize_int8_dynamic_quant_subclass(self, device, dtype):self._test_dequantize_impl(Int8DynamicallyQuantizedLinearWeight.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
685
691
685
null
[]
None
null
0
0
0
null
0
null
The function (test_dequantize_int8_dynamic_quant_subclass) defined within the public class called public.The function start at line 685 and ends at 691. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [685.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dequantize_int8_weight_only_quant_subclass
def test_dequantize_int8_weight_only_quant_subclass(self, device, dtype):self._test_dequantize_impl(Int8WeightOnlyQuantizedLinearWeight.from_float, device, 35, test_dtype=dtype)
1
4
3
25
0
694
697
694
null
[]
None
null
0
0
0
null
0
null
The function (test_dequantize_int8_weight_only_quant_subclass) defined within the public class called public.The function start at line 694 and ends at 697. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [694.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dequantize_int4_weight_only_quant_subclass
def test_dequantize_int4_weight_only_quant_subclass(self, device, dtype):if device == "cpu":self.skipTest(f"Temporarily skipping for {device}")if dtype != torch.bfloat16:self.skipTest("Currently only supports bfloat16.")for test_shape in [(16, 1024, 16)] + ([(1, 1024, 8)] if device == "cuda" else []):self._test_dequant...
5
15
3
87
0
701
715
701
null
[]
None
null
0
0
0
null
0
null
The function (test_dequantize_int4_weight_only_quant_subclass) defined within the public class called public.The function start at line 701 and ends at 715. It contains 15 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [701.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dequantize_int4_weight_only_quant_subclass_grouped
def test_dequantize_int4_weight_only_quant_subclass_grouped(self, device, dtype):if device == "cpu":self.skipTest(f"Temporarily skipping for {device}")if dtype != torch.bfloat16:self.skipTest("Currently only supports bfloat16.")m_shapes = [16, 256] + ([1] if device == "cuda" else [])n_shapes = [16] + ([8, 13] if device...
9
20
3
141
0
719
738
719
null
[]
None
null
0
0
0
null
0
null
The function (test_dequantize_int4_weight_only_quant_subclass_grouped) defined within the public class called public.The function start at line 719 and ends at 738. It contains 20 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [719.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_lin_weight_subclass_impl
def _test_lin_weight_subclass_impl(self,test_subclass_from_float,test_device,min_sqnr=35,test_dtype=torch.bfloat16,test_shape=(32, 64, 32),):if not "cuda" in test_device:self.skipTest("test requires cuda")with torch.no_grad():m, k, n = test_shapex = torch.randn(m, k, device=test_device, dtype=test_dtype)lin = torch.nn....
2
31
8
180
0
741
772
741
null
[]
None
null
0
0
0
null
0
null
The function (_test_lin_weight_subclass_impl) defined within the public class called public.The function start at line 741 and ends at 772. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 8 parameters, represented as [741.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8_dynamic_quant_subclass
def test_int8_dynamic_quant_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(Int8DynamicallyQuantizedLinearWeight.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
775
781
775
null
[]
None
null
0
0
0
null
0
null
The function (test_int8_dynamic_quant_subclass) defined within the public class called public.The function start at line 775 and ends at 781. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [775.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8_weight_only_quant_subclass
def test_int8_weight_only_quant_subclass(self, device, dtype):undo_recommended_configs()self._test_lin_weight_subclass_impl(Int8WeightOnlyQuantizedLinearWeight.from_float, device, 40, test_dtype=dtype)
1
5
3
28
0
784
788
784
null
[]
None
null
0
0
0
null
0
null
The function (test_int8_weight_only_quant_subclass) defined within the public class called public.The function start at line 784 and ends at 788. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [784.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_int8_dynamic_quant_subclass
def test_aq_int8_dynamic_quant_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQInt8DynamicallyQuantizedLinearWeight.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
791
797
791
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_int8_dynamic_quant_subclass) defined within the public class called public.The function start at line 791 and ends at 797. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [791.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_int8_weight_only_quant_subclass
def test_aq_int8_weight_only_quant_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQInt8WeightOnlyQuantizedLinearWeight.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
804
810
804
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_int8_weight_only_quant_subclass) defined within the public class called public.The function start at line 804 and ends at 810. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [804.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_int8_weight_only_quant_2_subclass
def test_aq_int8_weight_only_quant_2_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQInt8WeightOnlyQuantizedLinearWeight2.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
813
819
813
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_int8_weight_only_quant_2_subclass) defined within the public class called public.The function start at line 813 and ends at 819. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [813.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_int8_weight_only_quant_3_subclass
def test_aq_int8_weight_only_quant_3_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQInt8WeightOnlyQuantizedLinearWeight3.from_float,device,35,test_dtype=dtype,)
1
7
3
26
0
822
828
822
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_int8_weight_only_quant_3_subclass) defined within the public class called public.The function start at line 822 and ends at 828. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [822.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_float8_weight_only_quant_subclass
def test_aq_float8_weight_only_quant_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQFloat8WeightOnlyQuantizedLinearWeight.from_float,device,30,test_dtype=dtype,)
1
7
3
26
0
832
838
832
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_float8_weight_only_quant_subclass) defined within the public class called public.The function start at line 832 and ends at 838. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [832.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquantizable_flatten_unflatten
def test_autoquantizable_flatten_unflatten(self):from torchao.quantization import DEFAULT_AUTOQUANT_CLASS_LISTweight = torch.randn(16, 32)qtensor_class_list = DEFAULT_AUTOQUANT_CLASS_LISTaqw = AutoQuantizableLinearWeight.from_float(weight, qtensor_class_list)tensor_data_name_dict, tensor_attributes = aqw.__tensor_flatt...
2
12
1
88
0
840
852
840
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquantizable_flatten_unflatten) defined within the public class called public.The function start at line 840 and ends at 852. It contains 12 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_aq_float8_dynamic_quant_rowwise_scaling_subclass
def test_aq_float8_dynamic_quant_rowwise_scaling_subclass(self, device, dtype, name):if dtype != torch.bfloat16:with self.assertRaisesRegex(AssertionError, "PerRow quantization only works for bfloat16 precision"):self._test_lin_weight_subclass_impl(AQFloat8PerRowScalingDynamicallyQuantizedLinearWeight.from_float,device...
2
20
4
64
0
862
881
862
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_float8_dynamic_quant_rowwise_scaling_subclass) defined within the public class called public.The function start at line 862 and ends at 881. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [862.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aq_float8_dynamic_quant_tensorwise_scaling_subclass
def test_aq_float8_dynamic_quant_tensorwise_scaling_subclass(self, device, dtype):self._test_lin_weight_subclass_impl(AQFloat8PerTensorScalingDynamicallyQuantizedLinearWeight.from_float,device,25,test_dtype=dtype,)
1
7
3
26
0
886
892
886
null
[]
None
null
0
0
0
null
0
null
The function (test_aq_float8_dynamic_quant_tensorwise_scaling_subclass) defined within the public class called public.The function start at line 886 and ends at 892. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [886.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_quant_subclass
def test_int4_weight_only_quant_subclass(self, device, dtype):if device == "cpu":self.skipTest(f"Temporarily skipping for {device}")if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")for test_shape in [(16, 1024, 16)] + ([(1, 1024, 8)] if device == "cuda" else []):self._test_lin_weight_subclass_impl(Int4Weig...
5
15
3
88
0
896
910
896
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_quant_subclass) defined within the public class called public.The function start at line 896 and ends at 910. It contains 15 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [896.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_quant_subclass_grouped
def test_int4_weight_only_quant_subclass_grouped(self, device, dtype):if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")m_shapes = [16, 256] + ([1] if device == "cuda" else [])n_shapes = [16] + ([8, 13] if device == "cuda" else [])for groupsize in [128, 64]:for inner_k_tiles in [8, 4, 2]:for m in m_shapes:f...
8
18
3
130
0
915
932
915
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_quant_subclass_grouped) defined within the public class called public.The function start at line 915 and ends at 932. It contains 18 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [915.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_lin_weight_subclass_api_impl
def _test_lin_weight_subclass_api_impl(self,api,test_device,min_sqnr=35,test_dtype=torch.bfloat16,test_shape=(32, 64, 32),):m, k, n = test_shapex = torch.randn(m, k, device=test_device, dtype=test_dtype)mod = nn.Sequential(nn.Linear(k, n, device=test_device),nn.ReLU(),nn.Linear(n, n, device=test_device),).to(test_dtype...
2
32
8
192
0
936
972
936
null
[]
None
null
0
0
0
null
0
null
The function (_test_lin_weight_subclass_api_impl) defined within the public class called public.The function start at line 936 and ends at 972. It contains 32 lines of code and it has a cyclomatic complexity of 2. It takes 8 parameters, represented as [936.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8_dynamic_quant_subclass_api
def test_int8_dynamic_quant_subclass_api(self, device, dtype, act_mapping):api = partial(_int8da_int8w_api,act_mapping_type=act_mapping,)self._test_lin_weight_subclass_api_impl(api, device, 35, test_dtype=dtype)
1
6
4
36
0
984
989
984
null
[]
None
null
0
0
0
null
0
null
The function (test_int8_dynamic_quant_subclass_api) defined within the public class called public.The function start at line 984 and ends at 989. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [984.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8_weight_only_quant_subclass_api
def test_int8_weight_only_quant_subclass_api(self, device, dtype):undo_recommended_configs()self._test_lin_weight_subclass_api_impl(_int8wo_api, device, 40, test_dtype=dtype)
1
5
3
26
0
993
997
993
null
[]
None
null
0
0
0
null
0
null
The function (test_int8_weight_only_quant_subclass_api) defined within the public class called public.The function start at line 993 and ends at 997. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [993.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8_weight_only_quant_with_freeze
def test_int8_weight_only_quant_with_freeze(self, device, dtype):torch._dynamo.reset()self._test_lin_weight_subclass_api_impl(_int8wo_api, device, 40, test_dtype=dtype)
1
5
3
30
0
1,002
1,006
1,002
null
[]
None
null
0
0
0
null
0
null
The function (test_int8_weight_only_quant_with_freeze) defined within the public class called public.The function start at line 1002 and ends at 1006. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1002.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_quant_subclass_api
def test_int4_weight_only_quant_subclass_api(self, device, dtype):if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")for test_shape in [(16, 1024, 16)] + ([(1, 1024, 256)] if device == "cuda" else []):self._test_lin_weight_subclass_api_impl(_int4wo_api, device, 15, test_shape=test_shape, test_dtype=dtype)
4
9
3
73
0
1,009
1,017
1,009
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_quant_subclass_api) defined within the public class called public.The function start at line 1009 and ends at 1017. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [1009.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_hqq_quant_subclass_api
def test_int4_weight_only_hqq_quant_subclass_api(self, device, dtype):if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")for test_shape in [(16, 1024, 16), (1, 1024, 256)]:api = partial(_int4wo_api,use_hqq=True,)self._test_lin_weight_subclass_api_impl(api, device, 15, test_shape=test_shape, test_dtype=dtype)
3
11
3
73
0
1,020
1,030
1,020
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_hqq_quant_subclass_api) defined within the public class called public.The function start at line 1020 and ends at 1030. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [1020.0] and does not return any value..
pytorch_ao
public
public
0
0
test_gemlite_layout
def test_gemlite_layout(self, device, dtype):from torchao.quantization import GemliteUIntXWeightOnlyConfigif dtype != torch.float16:self.skipTest("gemlite only works for fp16 dtype")if device == "cpu":self.skipTest(f"gemlite is for cuda, not {device}")for packing_bitwidth in [32, 8]:for bit_width in [4, 8]:for group_si...
8
37
3
197
0
1,034
1,074
1,034
null
[]
None
null
0
0
0
null
0
null
The function (test_gemlite_layout) defined within the public class called public.The function start at line 1034 and ends at 1074. It contains 37 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [1034.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_quant_subclass_api_grouped.api
def api(mod):kwargs_copy = kwargs.copy()kwargs_copy["group_size"] = groupsizedel kwargs_copy["groupsize"]quantize_(mod, Int4WeightOnlyConfig(**kwargs_copy))
1
5
1
33
0
1,096
1,100
1,096
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_quant_subclass_api_grouped.api) defined within the public class called public.The function start at line 1096 and ends at 1100. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_int4_weight_only_quant_subclass_api_grouped
def test_int4_weight_only_quant_subclass_api_grouped(self, device, dtype):if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")layout_list = []if check_cpu_version(device):layout_list.append(Int4CPULayout())elif check_xpu_version(device):layout_list.append(Int4XPULayout())else:for inner_k_tiles in [4, 2]:layou...
9
25
3
159
0
1,078
1,108
1,078
null
[]
None
null
0
0
0
null
0
null
The function (test_int4_weight_only_quant_subclass_api_grouped) defined within the public class called public.The function start at line 1078 and ends at 1108. It contains 25 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [1078.0] and does not return any value..
pytorch_ao
public
public
0
0
test_dynamic_quant
def test_dynamic_quant(self):M, K, N = 8, 16, 8x = torch.randn(M, K)m = nn.Sequential(nn.Linear(K, N))y_ref = m(x)quantize_(m, Int8DynamicActivationInt8WeightConfig())y_test = m(x)sqnr = compute_error(y_ref, y_test)self.assertGreater(sqnr, 40.0)
1
9
1
79
0
1,112
1,122
1,112
null
[]
None
null
0
0
0
null
0
null
The function (test_dynamic_quant) defined within the public class called public.The function start at line 1112 and ends at 1122. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_weight_only_quant
def test_weight_only_quant(self):for x_shape in [[2, 4], [5, 5, 5, 4], [1, 4, 4]]:x = torch.randn(*x_shape)m = nn.Sequential(nn.Linear(4, 5))y_ref = m(x)_int8wo_api(m)y_wo = m(x)sqnr = compute_error(y_ref, y_wo)self.assertGreater(sqnr, 43.0)
2
9
1
92
0
1,127
1,135
1,127
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_only_quant) defined within the public class called public.The function start at line 1127 and ends at 1135. It contains 9 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_weight_only_groupwise_quant
def test_weight_only_groupwise_quant(self):for x_shape in [[128, 512]]:x = torch.randn(*x_shape)m = nn.Sequential(nn.Linear(512, 32))y_ref = m(x)_int8wo_groupwise_api(m)self.assertEqual(m[0].weight.tensor_impl.int_data.shape, torch.Size([32, 512]))self.assertEqual(m[0].weight.tensor_impl.scale.shape, torch.Size([32, 16...
2
13
1
130
0
1,137
1,149
1,137
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_only_groupwise_quant) defined within the public class called public.The function start at line 1137 and ends at 1149. It contains 13 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_weight_only_groupwise_embedding_quant
def test_weight_only_groupwise_embedding_quant(self):group_size = 64m = nn.Embedding(4096, 128)input = torch.randint(0, 4096, (1, 6))quantize_(m,Int8WeightOnlyConfig(group_size=group_size),filter_fn=lambda x, *args: isinstance(x, nn.Embedding),)y_q = m(input)y_ref = m.weight.dequantize()[input]sqnr = compute_error(y_re...
1
13
1
99
0
1,151
1,166
1,151
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_only_groupwise_embedding_quant) defined within the public class called public.The function start at line 1151 and ends at 1166. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_weight_only_quant_force_mixed_mm
def test_weight_only_quant_force_mixed_mm(self, device, dtype):undo_recommended_configs()if device != "cuda":self.skipTest(f"weight_only_quant_force_mixed_mm can't be constructed on {device}")if dtype == torch.bfloat16 and torch.cuda.get_device_capability() < (8, 0):self.skipTest("test requires SM capability of at leas...
5
27
3
218
0
1,171
1,199
1,171
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_only_quant_force_mixed_mm) defined within the public class called public.The function start at line 1171 and ends at 1199. It contains 27 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [1171.0] and does not return any value..
pytorch_ao
public
public
0
0
test_weight_only_quant_use_mixed_mm
def test_weight_only_quant_use_mixed_mm(self, device, dtype):undo_recommended_configs()if device != "cuda":self.skipTest(f"weight_only_quant_force_mixed_mm can't be constructed on {device}")if dtype == torch.bfloat16 and torch.cuda.get_device_capability() < (8, 0):self.skipTest("test requires SM capability of at least ...
5
27
3
222
0
1,203
1,231
1,203
null
[]
None
null
0
0
0
null
0
null
The function (test_weight_only_quant_use_mixed_mm) defined within the public class called public.The function start at line 1203 and ends at 1231. It contains 27 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [1203.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_handle_save_load_meta_impl.__init__
def __init__(self):super().__init__()self.lin1 = nn.Linear(k, n)self.relu = nn.ReLU()self.lin2 = nn.Linear(n, n)
1
5
1
45
0
1,244
1,248
1,244
null
[]
None
null
0
0
0
null
0
null
The function (_test_handle_save_load_meta_impl.__init__) defined within the public class called public.The function start at line 1244 and ends at 1248. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_handle_save_load_meta_impl.forward
def forward(self, x):x = self.lin1(x)x = self.relu(x)x = self.lin2(x)return x
1
5
2
33
0
1,250
1,254
1,250
null
[]
None
null
0
0
0
null
0
null
The function (_test_handle_save_load_meta_impl.forward) defined within the public class called public.The function start at line 1250 and ends at 1254. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1250.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_handle_save_load_meta_impl
def _test_handle_save_load_meta_impl(self, api, test_device, min_sqnr=35, test_dtype=torch.bfloat16):logger.info(f"TestSaveLoad: {api}, {test_device}, {test_dtype}")m, k, n = 32, 64, 32class test_model(nn.Module):def __init__(self):super().__init__()self.lin1 = nn.Linear(k, n)self.relu = nn.ReLU()self.lin2 = nn.Linear(...
1
33
5
272
0
1,237
1,298
1,237
null
[]
None
null
0
0
0
null
0
null
The function (_test_handle_save_load_meta_impl) defined within the public class called public.The function start at line 1237 and ends at 1298. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [1237.0] and does not return any value..
pytorch_ao
public
public
0
0
test_save_load_dqtensors
def test_save_load_dqtensors(self, device, dtype):if device == "cpu":self.skipTest("indcutor failed for cpu right now")self._test_handle_save_load_meta_impl(_int8da_int8w_api, device, test_dtype=dtype)
2
6
3
32
0
1,305
1,310
1,305
null
[]
None
null
0
0
0
null
0
null
The function (test_save_load_dqtensors) defined within the public class called public.The function start at line 1305 and ends at 1310. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [1305.0] and does not return any value..
pytorch_ao
public
public
0
0
test_save_load_int8woqtensors
def test_save_load_int8woqtensors(self, device, dtype):undo_recommended_configs()self._test_handle_save_load_meta_impl(_int8wo_api, device, test_dtype=dtype)
1
3
3
24
0
1,315
1,317
1,315
null
[]
None
null
0
0
0
null
0
null
The function (test_save_load_int8woqtensors) defined within the public class called public.The function start at line 1315 and ends at 1317. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1315.0] and does not return any value..
pytorch_ao
public
public
0
0
test_save_load_int4woqtensors
def test_save_load_int4woqtensors(self, device, dtype):if dtype != torch.bfloat16:self.skipTest(f"Fails for {dtype}")self._test_handle_save_load_meta_impl(_int4wo_api, device, 20, test_dtype=dtype)
2
4
3
37
0
1,321
1,324
1,321
null
[]
None
null
0
0
0
null
0
null
The function (test_save_load_int4woqtensors) defined within the public class called public.The function start at line 1321 and ends at 1324. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [1321.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fullgraph
def test_fullgraph(self):lin_fp16 = nn.Linear(32, 16, device="cuda", dtype=torch.float16)lin_smooth = SmoothFakeDynamicallyQuantizedLinear.from_float(lin_fp16, alpha=0.25)x0 = torch.randn(17, 1, 32, device="cuda", dtype=torch.float16)# calibrate_ = lin_smooth(x0)# inferencelin_smooth.to_inference()# torch.compilelin_sm...
1
10
1
88
0
1,329
1,347
1,329
null
[]
None
null
0
0
0
null
0
null
The function (test_fullgraph) defined within the public class called public.The function start at line 1329 and ends at 1347. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_shape_logger
def test_shape_logger(self):x = torch.randn(4, 4)m = nn.Sequential(nn.Linear(4, 4),nn.Sequential(nn.Linear(4, 4),),)_apply_logging_hook(m)with LoggingTensorMode():m(x)m(x)for fqn, d1 in _fqn_to_op_to_shape_to_count.items():# noqa: PERF102for op, d2 in d1.items():# noqa: PERF102for shape, count in d2.items():# noqa: PER...
4
16
1
97
0
1,352
1,371
1,352
null
[]
None
null
0
0
0
null
0
null
The function (test_shape_logger) defined within the public class called public.The function start at line 1352 and ends at 1371. It contains 16 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_non_dynamically_quantizable_linear
def test_non_dynamically_quantizable_linear(self):if torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0):self.skipTest("test requires SM capability of at least (8, 0).")model = (torch.nn.Sequential(torch.nn.modules.linear.NonDynamicallyQuantizableLinear(32, 32),torch.nn.ReLU(),).to("cuda").to(torc...
3
21
1
166
0
1,378
1,398
1,378
null
[]
None
null
0
0
0
null
0
null
The function (test_non_dynamically_quantizable_linear) defined within the public class called public.The function start at line 1378 and ends at 1398. It contains 21 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_on_dummy_distilbert
def test_on_dummy_distilbert(self):# https://huggingface.co/distilbert-base-uncased#how-to-usefrom transformers import (# type: ignore[import-untyped]DistilBertModel,DistilBertTokenizer,)tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased")model = DistilBertModel.from_pretrained("distilbert-base-un...
1
35
1
203
0
1,402
1,453
1,402
null
[]
None
null
0
0
0
null
0
null
The function (test_on_dummy_distilbert) defined within the public class called public.The function start at line 1402 and ends at 1453. It contains 35 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_one_input
def test_autoquant_one_input(self, device, dtype, m, k, n):undo_recommended_configs()print("(m, k, n): ", (m, k, n))if device != "cuda" or not torch.cuda.is_available():self.skipTest(f"autoquant currently does not support {device}")if torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0):if dtype ==...
7
29
6
239
0
1,472
1,501
1,472
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_one_input) defined within the public class called public.The function start at line 1472 and ends at 1501. It contains 29 lines of code and it has a cyclomatic complexity of 7. It takes 6 parameters, represented as [1472.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_compile
def test_autoquant_compile(self, device, dtype, m1, m2, k, n):undo_recommended_configs()is_supported_device = device == "cuda" and (torch.cuda.is_available() or torch.version.hip is not None)if not is_supported_device:self.skipTest(f"autoquant currently does not support {device}")# Check CUDA-specific requirements if r...
12
39
7
277
0
1,513
1,559
1,513
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_compile) defined within the public class called public.The function start at line 1513 and ends at 1559. It contains 39 lines of code and it has a cyclomatic complexity of 12. It takes 7 parameters, represented as [1513.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_mha.__init__
def __init__(self):super().__init__()self.mha = torch.nn.MultiheadAttention(4096, 32)self.lin = torch.nn.Linear(4096, 4096)
1
4
1
40
0
1,567
1,570
1,567
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_mha.__init__) defined within the public class called public.The function start at line 1567 and ends at 1570. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_mha.forward
def forward(self, x):y = self.mha(x, x, x)[0]return self.lin(y)
1
3
2
29
0
1,572
1,574
1,572
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_mha.forward) defined within the public class called public.The function start at line 1572 and ends at 1574. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1572.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_mha
def test_autoquant_mha(self, device, dtype):if device != "cuda" or not torch.cuda.is_available():self.skipTest(f"autoquant currently does not support {device}")class MHAModel(torch.nn.Module):def __init__(self):super().__init__()self.mha = torch.nn.MultiheadAttention(4096, 32)self.lin = torch.nn.Linear(4096, 4096)def f...
3
15
3
141
0
1,562
1,586
1,562
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_mha) defined within the public class called public.The function start at line 1562 and ends at 1586. It contains 15 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [1562.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_manual
def test_autoquant_manual(self, device, dtype):undo_recommended_configs()if device != "cuda" or not torch.cuda.is_available():self.skipTest(f"autoquant currently does not support {device}")if torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0):if dtype == torch.bfloat16:self.skipTest("bfloat16 req...
6
36
3
281
0
1,589
1,626
1,589
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_manual) defined within the public class called public.The function start at line 1589 and ends at 1626. It contains 36 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [1589.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_kwargs.__init__
def __init__(self):super().__init__()self.rel = torch.nn.ReLU()self.lin = torch.nn.Linear(k, n)
1
4
1
37
0
1,670
1,673
1,670
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_kwargs.__init__) defined within the public class called public.The function start at line 1670 and ends at 1673. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_kwargs.forward
def forward(self, x, y):x = self.rel(x)z = self.lin(x + y)return z
1
4
3
29
0
1,675
1,678
1,675
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_kwargs.forward) defined within the public class called public.The function start at line 1675 and ends at 1678. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1675.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_kwargs
def test_autoquant_kwargs(self, device, dtype, m1, m2, k, n):undo_recommended_configs()if device != "cuda" or not torch.cuda.is_available():self.skipTest(f"autoquant currently does not support {device}")if torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0):if dtype == torch.bfloat16:self.skipTest...
9
25
7
228
0
1,638
1,692
1,638
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_kwargs) defined within the public class called public.The function start at line 1638 and ends at 1692. It contains 25 lines of code and it has a cyclomatic complexity of 9. It takes 7 parameters, represented as [1638.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_double_access.__init__
def __init__(self):super().__init__()self.lin1 = torch.nn.Linear(k, n)self.lin2 = torch.nn.Linear(n, k)self.lin3 = torch.nn.Linear(k, n)self.lin3.weight = self.lin1.weight
1
6
1
65
0
1,711
1,716
1,711
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_double_access.__init__) defined within the public class called public.The function start at line 1711 and ends at 1716. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_double_access.forward
def forward(self, x):x = self.lin1(x)x = self.lin2(x)x = self.lin3(x)return x
1
5
2
33
0
1,718
1,722
1,718
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_double_access.forward) defined within the public class called public.The function start at line 1718 and ends at 1722. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1718.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_double_access
def test_autoquant_double_access(self, device, dtype, m, k, n):undo_recommended_configs()if device != "cuda" or not torch.cuda.is_available():self.skipTest(f"autoquant currently does not support {device}")if torch.cuda.is_available() and torch.cuda.get_device_capability() < (8, 0):if dtype == torch.bfloat16:self.skipTe...
6
16
6
154
0
1,702
1,729
1,702
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_double_access) defined within the public class called public.The function start at line 1702 and ends at 1729. It contains 16 lines of code and it has a cyclomatic complexity of 6. It takes 6 parameters, represented as [1702.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_min_sqnr
def test_autoquant_min_sqnr(self, device, dtype):m, k, n = 128, 128, 128example_input = torch.randn(m, k, device=device, dtype=dtype)model = (torch.nn.Sequential(torch.nn.ReLU(),torch.nn.Linear(k, n),torch.nn.ReLU(),).to(device).to(dtype))out = model(example_input)torchao.autoquant(model, min_sqnr=60)out2 = model(examp...
1
17
3
127
0
1,733
1,751
1,733
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_min_sqnr) defined within the public class called public.The function start at line 1733 and ends at 1751. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1733.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_hp_float
def test_autoquant_hp_float(self):device = "cuda"dtype = torch.float32m, k, n = 128, 128, 128example_input = torch.randn(m, k, device=device, dtype=dtype)for qclass in torchao.quantization.DEFAULT_FLOAT_AUTOQUANT_CLASS_LIST:model = (torch.nn.Sequential(torch.nn.ReLU(),torch.nn.Linear(k, n, bias=True),torch.nn.ReLU(),)....
2
27
1
161
0
1,754
1,780
1,754
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_hp_float) defined within the public class called public.The function start at line 1754 and ends at 1780. It contains 27 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_int4wo
def test_autoquant_int4wo(self, device, dtype):if device == "cpu":self.skipTest(f"int4wo is for cuda, not {device}")m, k, n = 128, 128, 128example_input = torch.randn(m, k, device=device, dtype=dtype)for qclass in [AQGemliteInt4G64WeightOnlyQuantizedLinearWeight,AQInt4G32WeightOnlyQuantizedLinearWeight,AQInt4G128Weight...
3
28
3
171
0
1,785
1,815
1,785
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_int4wo) defined within the public class called public.The function start at line 1785 and ends at 1815. It contains 28 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [1785.0] and does not return any value..
pytorch_ao
public
public
0
0
test_autoquant_float8
def test_autoquant_float8(self, device, dtype):if device == "cpu":self.skipTest(f"float8 is for cuda, not {device}")# note: marlin sparse layout failed when scale_t has a dimension of 1dm, k, n = 128, 128, 128example_input = torch.randn(m, k, device=device, dtype=dtype)for qclass in [AQFloat8PerRowScalingDynamicallyQua...
5
30
3
190
0
1,822
1,855
1,822
null
[]
None
null
0
0
0
null
0
null
The function (test_autoquant_float8) defined within the public class called public.The function start at line 1822 and ends at 1855. It contains 30 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [1822.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aoti.__init__
def __init__(self):super().__init__()self.lin1 = nn.Linear(k, n)self.relu = nn.ReLU()self.lin2 = nn.Linear(n, n)
1
5
1
45
0
1,881
1,885
1,881
null
[]
None
null
0
0
0
null
0
null
The function (test_aoti.__init__) defined within the public class called public.The function start at line 1881 and ends at 1885. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_aoti.forward
def forward(self, x):x = self.lin1(x)x = self.relu(x)x = self.lin2(x)return x
1
5
2
33
0
1,887
1,891
1,887
null
[]
None
null
0
0
0
null
0
null
The function (test_aoti.forward) defined within the public class called public.The function start at line 1887 and ends at 1891. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1887.0] and does not return any value..
pytorch_ao
public
public
0
0
test_aoti
def test_aoti(self, api, test_device, test_dtype):if (test_device == "cuda"and torch.cuda.is_available()and test_dtype == torch.bfloat16and torch.cuda.get_device_capability() < (8, 0)):self.skipTest("Need CUDA and SM80+ available.")logger.info(f"TestAOTI: {api}, {test_device}, {test_dtype}")m, k, n = 32, 64, 32class te...
6
25
4
179
0
1,867
1,912
1,867
null
[]
None
null
0
0
0
null
0
null
The function (test_aoti) defined within the public class called public.The function start at line 1867 and ends at 1912. It contains 25 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [1867.0] and does not return any value..
pytorch_ao
public
public
0
0
test_export.__init__
def __init__(self):super().__init__()self.lin1 = nn.Linear(k, n)self.relu = nn.ReLU()self.lin2 = nn.Linear(n, n)
1
5
1
45
0
1,940
1,944
1,940
null
[]
None
null
0
0
0
null
0
null
The function (test_export.__init__) defined within the public class called public.The function start at line 1940 and ends at 1944. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_export.forward
def forward(self, x):x = self.lin1(x)x = self.relu(x)x = self.lin2(x)return x
1
5
2
33
0
1,946
1,950
1,946
null
[]
None
null
0
0
0
null
0
null
The function (test_export.forward) defined within the public class called public.The function start at line 1946 and ends at 1950. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1946.0] and does not return any value..
pytorch_ao
public
public
0
0
test_export
def test_export(self, api, test_device, test_dtype):if (test_device == "cuda"and torch.cuda.is_available()and test_dtype == torch.bfloat16and torch.cuda.get_device_capability() < (8, 0)):self.skipTest("Need CUDA and SM80+ available.")logger.info(f"TestExport: {api}, {test_device}, {test_dtype}")m, k, n = 32, 64, 32clas...
8
29
4
258
0
1,926
1,977
1,926
null
[]
None
null
0
0
0
null
0
null
The function (test_export) defined within the public class called public.The function start at line 1926 and ends at 1977. It contains 29 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [1926.0] and does not return any value..
pytorch_ao
public
public
0
0
test_export_float8.__init__
def __init__(self):super(SimpleNetwork, self).__init__()self.linear = torch.nn.Linear(in_features=32, out_features=16, bias=False)
1
5
1
37
0
1,984
1,988
1,984
null
[]
None
null
0
0
0
null
0
null
The function (test_export_float8.__init__) defined within the public class called public.The function start at line 1984 and ends at 1988. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_export_float8.forward
def forward(self, x):return self.linear(x)
1
2
2
14
0
1,990
1,991
1,990
null
[]
None
null
0
0
0
null
0
null
The function (test_export_float8.forward) defined within the public class called public.The function start at line 1990 and ends at 1991. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1990.0] and does not return any value..
pytorch_ao
public
public
0
0
test_export_float8
def test_export_float8(self):class SimpleNetwork(torch.nn.Module):def __init__(self):super(SimpleNetwork, self).__init__()self.linear = torch.nn.Linear(in_features=32, out_features=16, bias=False)def forward(self, x):return self.linear(x)model = SimpleNetwork().eval().cuda()inp = torch.randn(2, 32).cuda()config = Float...
1
13
1
100
0
1,982
2,002
1,982
null
[]
None
null
0
0
0
null
0
null
The function (test_export_float8) defined within the public class called public.The function start at line 1982 and ends at 2002. It contains 13 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_get_model_size_aqt
def test_get_model_size_aqt(self, api, test_device, test_dtype):if test_dtype != torch.bfloat16:self.skipTest(f"{api} in {test_dtype} is not supported yet")if test_device != "cuda" or not torch.cuda.is_available():self.skipTest(f"{api} currently does not support {test_device}")k, n = 1024, 1024model = (torch.nn.Sequent...
4
19
4
133
0
2,009
2,027
2,009
null
[]
None
null
0
0
0
null
0
null
The function (test_get_model_size_aqt) defined within the public class called public.The function start at line 2009 and ends at 2027. It contains 19 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [2009.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, m=64, n=32, k=64):super().__init__()self.linear1 = torch.nn.Linear(m, n, bias=False)self.linear2 = torch.nn.Linear(n, k, bias=False)
1
4
4
60
0
2,032
2,035
2,032
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 2032 and ends at 2035. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [2032.0] and does not return any value..
pytorch_ao
public
public
0
0
example_inputs
def example_inputs(self, batch_size=1, dtype=torch.float32, device="cpu"):return (torch.randn(batch_size, self.linear1.in_features, dtype=dtype, device=device),)
1
6
4
43
0
2,037
2,042
2,037
null
[]
None
null
0
0
0
null
0
null
The function (example_inputs) defined within the public class called public.The function start at line 2037 and ends at 2042. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [2037.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):x = self.linear1(x)x = self.linear2(x)return x
1
4
2
25
0
2,044
2,047
2,044
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 2044 and ends at 2047. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [2044.0] and does not return any value..
pytorch_ao
public
public
0
0
run_benchmark_model
def run_benchmark_model(self, device):# paramsdtype = torch.bfloat16m = self.ToyLinearModel(1024, 1024, 1024).eval().to(dtype).to(device)m_bf16 = copy.deepcopy(m)example_inputs = m.example_inputs(dtype=dtype, device=device)m_bf16 = torch.compile(m_bf16, mode="max-autotune")num_runs = 1return benchmark_model(m_bf16, num...
1
8
2
84
0
2,049
2,057
2,049
null
[]
None
null
0
0
0
null
0
null
The function (run_benchmark_model) defined within the public class called public.The function start at line 2049 and ends at 2057. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [2049.0] and does not return any value..
pytorch_ao
public
public
0
0
test_benchmark_model_cuda
def test_benchmark_model_cuda(self):assert self.run_benchmark_model("cuda") is not None
1
2
1
15
0
2,060
2,061
2,060
null
[]
None
null
0
0
0
null
0
null
The function (test_benchmark_model_cuda) defined within the public class called public.The function start at line 2060 and ends at 2061. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_benchmark_model_cpu
def test_benchmark_model_cpu(self):assert self.run_benchmark_model("cpu") is not None
1
2
1
15
0
2,063
2,064
2,063
null
[]
None
null
0
0
0
null
0
null
The function (test_benchmark_model_cpu) defined within the public class called public.The function start at line 2063 and ends at 2064. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_test_single_linear_helper
def _test_single_linear_helper(self, model_name, version, config_name, is_deprecated):from huggingface_hub import hf_hub_downloaddownloaded_model = hf_hub_download(model_name, filename="model.pt")# Load model weights, example inputs and reference output,# run the loaded model and make sure the result matches reference ...
3
31
5
211
0
126
166
126
null
[]
None
null
0
0
0
null
0
null
The function (_test_single_linear_helper) defined within the public class called public.The function start at line 126 and ends at 166. It contains 31 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [126.0] and does not return any value..
pytorch_ao
public
public
0
0
test_deprecated_single_linear
def test_deprecated_single_linear(self, model_info):model_name, version, config_name = model_infoself._test_single_linear_helper(model_name, version, config_name, is_deprecated=True)
1
5
2
28
0
169
173
169
null
[]
None
null
0
0
0
null
0
null
The function (test_deprecated_single_linear) defined within the public class called public.The function start at line 169 and ends at 173. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [169.0] and does not return any value..
pytorch_ao
public
public
0
0
test_single_linear
def test_single_linear(self, model_info):"""Test that we can load and run the quantized linear checkpoint with saved sample inputand match the saved output, to make sure there is no BC breaking changeswhen we make changes to tensor subclass implementations"""model_name, version, config_name = model_infoself._test_singl...
1
5
2
29
0
176
184
176
null
[]
None
null
0
0
0
null
0
null
The function (test_single_linear) defined within the public class called public.The function start at line 176 and ends at 184. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [176.0] and does not return any value..
pytorch_ao
public
public
0
0
test_deprecated_hf_models
def test_deprecated_hf_models(self, model_info):"""Test that we print correct warning message when loading a deprecated checkpointand making sure the deprecated checkpoints can still be loaded"""# Load and quantize modelmodel_name, version, config_name = model_infowith warnings.catch_warnings(record=True) as caught_war...
4
61
2
309
0
187
264
187
null
[]
None
null
0
0
0
null
0
null
The function (test_deprecated_hf_models) defined within the public class called public.The function start at line 187 and ends at 264. It contains 61 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [187.0] and does not return any value..
pytorch_ao
public
public
0
0
get_tests
def get_tests() -> List[TorchAoConfig]:"""Get all the tests based off of device info"""# Helper objects for granularityper_tensor = PerTensor()per_row = PerRow()BASE_TESTS = [TorchAoConfig(Int8WeightOnlyConfig())]SM89_TESTS = [TorchAoConfig(Float8DynamicActivationFloat8WeightConfig(granularity=per_tensor)),TorchAoConfi...
7
28
0
158
7
54
99
54
null
['SM100_TESTS', 'per_row', 'SM90_ONLY_TESTS', 'all_tests', 'per_tensor', 'SM89_TESTS', 'BASE_TESTS']
None
null
0
0
0
null
0
null
The function (get_tests) defined within the public class called public.The function start at line 54 and ends at 99. It contains 28 lines of code and it has a cyclomatic complexity of 7. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
setup_class
def setup_class(cls):"""Set up test environment."""# Set seeds for reproducibilitycls.set_seed(42)# See https://github.com/pytorch/ao/issues/2239 for detailsos.environ["VLLM_TEST_STANDALONE_COMPILE"] = "1"# For Small testing this makes it fasteros.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0"
1
4
1
28
0
106
114
106
null
[]
None
null
0
0
0
null
0
null
The function (setup_class) defined within the public class called public.The function start at line 106 and ends at 114. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
teardown_class
def teardown_class(cls):"""Clean up after all tests."""torch.cuda.empty_cache()import gcgc.collect()
1
4
1
20
0
117
122
117
null
[]
None
null
0
0
0
null
0
null
The function (teardown_class) defined within the public class called public.The function start at line 117 and ends at 122. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
setup_method
def setup_method(self, method):"""Clean up before each test method."""torch.cuda.empty_cache()import gcgc.collect()
1
4
2
22
0
124
129
124
null
[]
None
null
0
0
0
null
0
null
The function (setup_method) defined within the public class called public.The function start at line 124 and ends at 129. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [124.0] and does not return any value..