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_bmm.__init__
def __init__(self, weight):super().__init__()self.weight = weight
1
3
2
19
0
304
306
304
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.__init__) defined within the public class called public.The function start at line 304 and ends at 306. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [304.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm.forward
def forward(self, x):return torch.bmm(x, self.weight)
1
2
2
18
0
308
309
308
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.forward) defined within the public class called public.The function start at line 308 and ends at 309. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [308.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm
def test_bmm(self):# only support per row quantizationconfig = Float8DynamicActivationFloat8WeightConfig(granularity=PerRow())class M(torch.nn.Module):def __init__(self, weight):super().__init__()self.weight = weightdef forward(self, x):return torch.bmm(x, self.weight)dtype = torch.bfloat16device = "cuda"input = torch....
1
15
1
152
0
299
321
299
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm) defined within the public class called public.The function start at line 299 and ends at 321. It contains 15 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_to_device
def test_to_device(self, granularity, sizes):config = Float8DynamicActivationFloat8WeightConfig(granularity=granularity)M, N, K = sizesdtype = torch.bfloat16for device in self.GPU_DEVICES:input_tensor = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype)quantize_(linear, config)lin...
2
18
3
153
0
332
351
332
null
[]
None
null
0
0
0
null
0
null
The function (test_to_device) defined within the public class called public.The function start at line 332 and ends at 351. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [332.0] and does not return any value..
pytorch_ao
public
public
0
0
test_cat
def test_cat(self, granularity, sizes):config = Float8DynamicActivationFloat8WeightConfig(granularity=granularity)dtype = torch.bfloat16device = "cuda"M, N, K = sizeslinear1 = torch.nn.Linear(K, N, dtype=dtype, device=device)linear2 = torch.nn.Linear(K, N, dtype=dtype, device=device)input_cat1 = torch.randn(*M, K, dtyp...
1
39
3
351
0
362
408
362
null
[]
None
null
0
0
0
null
0
null
The function (test_cat) defined within the public class called public.The function start at line 362 and ends at 408. It contains 39 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [362.0] and does not return any value..
pytorch_ao
public
public
0
0
test_moe_weight_reshape_ops
def test_moe_weight_reshape_ops(self):# only per row quantization is supported for bmmgranularity = PerRow()config = Float8DynamicActivationFloat8WeightConfig(granularity=granularity)self._test_moe_weight_reshape_ops(config)
1
4
1
24
0
411
415
411
null
[]
None
null
0
0
0
null
0
null
The function (test_moe_weight_reshape_ops) defined within the public class called public.The function start at line 411 and ends at 415. 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_expected_gpu_kernel_fbgemm
def test_expected_gpu_kernel_fbgemm(self):"""Making sure KernelPreference.FBGEMM calls correct quantize and gemm kernelsand the bias add happens in the gemm kernel for per row quantization"""torch.compiler.reset()M, K, N = 128, 256, 512m = torch.nn.Sequential(torch.nn.Linear(K, N, device="cuda", dtype=torch.bfloat16))c...
1
19
1
144
0
421
448
421
null
[]
None
null
0
0
0
null
0
null
The function (test_expected_gpu_kernel_fbgemm) defined within the public class called public.The function start at line 421 and ends at 448. It contains 19 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_index_select
def test_index_select(self):"""test that `x_0 = x[0]` works when `x` is a 3D `Float8Tensor`. This isuseful when stitching checkpoints of `num_experts` 2D parameters intoa single 3D parameter when converting between model definitions thatuse 2D and 3D parameters for their expert weights."""E, K, N = 128, 256, 512x = tor...
1
8
1
82
0
451
465
451
null
[]
None
null
0
0
0
null
0
null
The function (test_index_select) defined within the public class called public.The function start at line 451 and ends at 465. It contains 8 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
def setUp(self):self.GPU_DEVICES = ["cuda"] if torch.cuda.is_available() else []
2
2
1
23
0
36
37
36
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 36 and ends at 37. It contains 2 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_linear
def test_linear(self, config, sizes):dtype = torch.float16device = "cuda"M, N, K = sizesinput = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype, device=device)apply_fake_sparsity(linear)original = linear(input)quantize_(linear, config)quantized = linear(input)self.assertTrue(com...
1
14
3
125
0
49
65
49
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 49 and ends at 65. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [49.0] and does not return any value..
pytorch_ao
public
public
0
0
test_to_device
def test_to_device(self, config):for device in self.GPU_DEVICES:linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear, config)linear.to(device)linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear, config)linear.to(device=device)linear = torch.nn.Linear(128, 256, dtype=torch.bfloat...
2
11
2
106
0
70
82
70
null
[]
None
null
0
0
0
null
0
null
The function (test_to_device) defined within the public class called public.The function start at line 70 and ends at 82. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [70.0] and does not return any value..
pytorch_ao
public
public
0
0
test_module_path
def test_module_path(self, config):linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear.cuda(), config)self.assertEqual(str(type(linear.weight)),"<class 'torchao.quantization.Int4MarlinSparseTensor'>",)with tempfile.NamedTemporaryFile() as f:torch.save(linear.state_dict(), f)f.seek(0)state_dict = to...
1
15
2
105
0
86
101
86
null
[]
None
null
0
0
0
null
0
null
The function (test_module_path) defined within the public class called public.The function start at line 86 and ends at 101. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [86.0] and does not return any value..
pytorch_ao
public
public
0
0
get_config
def get_config(group_size, use_hqq):return Int4WeightOnlyConfig(group_size=group_size,int4_packing_format="opaque",int4_choose_qparams_algorithm="hqq" if use_hqq else "tinygemm",)
2
6
2
27
0
29
34
29
null
[]
None
null
0
0
0
null
0
null
The function (get_config) defined within the public class called public.The function start at line 29 and ends at 34. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [29.0] and does not return any value..
pytorch_ao
public
public
0
0
test_linear
def test_linear(self, sizes, dtype, group_size, use_hqq):device = "cpu"M, N, K = sizesinput = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype, device=device)original = linear(input)quantize_(linear, get_config(group_size, use_hqq))quantized = linear(input)self.assertTrue(compute...
1
12
5
125
0
50
62
50
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 50 and ends at 62. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [50.0] and does not return any value..
pytorch_ao
public
public
0
0
test_module_path
def test_module_path(self, dtype, use_hqq):linear = torch.nn.Linear(128, 256, dtype=dtype)quantize_(linear, get_config(group_size=128, use_hqq=use_hqq))self.assertEqual(str(type(linear.weight)),"<class 'torchao.quantization.Int4OpaqueTensor'>",)with tempfile.NamedTemporaryFile() as f:torch.save(linear.state_dict(), f)f...
1
15
3
110
0
66
81
66
null
[]
None
null
0
0
0
null
0
null
The function (test_module_path) defined within the public class called public.The function start at line 66 and ends at 81. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [66.0] and does not return any value..
pytorch_ao
public
public
0
0
test_activation_prescaling
def test_activation_prescaling(self, use_hqq):dtype = torch.bfloat16input = torch.randn(1, 128, dtype=dtype)linear = torch.nn.Linear(128, 256, bias=False, dtype=dtype)original_output = linear(input)quantize_(linear, get_config(group_size=128, use_hqq=use_hqq))qw = linear.weightassert isinstance(qw, SupportsActivationPr...
1
19
2
136
0
84
107
84
null
[]
None
null
0
0
0
null
0
null
The function (test_activation_prescaling) defined within the public class called public.The function start at line 84 and ends at 107. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [84.0] and does not return any value..
pytorch_ao
public
public
0
0
get_config
def get_config(group_size):return Int4WeightOnlyConfig(group_size=group_size,int4_packing_format="plain_int32",)
1
5
1
17
0
29
33
29
null
[]
None
null
0
0
0
null
0
null
The function (get_config) defined within the public class called public.The function start at line 29 and ends at 33. 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_linear
def test_linear(self, sizes, dtype, group_size):device = "xpu"M, N, K = sizesinput = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype, device=device)original = linear(input)quantize_(linear, get_config(group_size))quantized = linear(input)self.assertTrue(compute_error(original, q...
1
12
4
121
0
49
61
49
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 49 and ends at 61. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [49.0] and does not return any value..
pytorch_ao
public
public
0
0
test_module_path
def test_module_path(self, dtype):linear = torch.nn.Linear(128, 256, dtype=dtype, device="xpu")quantize_(linear, get_config(group_size=128))self.assertEqual(str(type(linear.weight)),"<class 'torchao.quantization.Int4PlainInt32Tensor'>",)with tempfile.NamedTemporaryFile() as f:torch.save(linear.state_dict(), f)f.seek(0)...
1
15
2
108
0
64
79
64
null
[]
None
null
0
0
0
null
0
null
The function (test_module_path) defined within the public class called public.The function start at line 64 and ends at 79. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [64.0] and does not return any value..
pytorch_ao
public
public
0
0
test_activation_prescaling
def test_activation_prescaling(self):dtype = torch.bfloat16device = "xpu"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, bias=False, dtype=dtype, device=device)original = linear(input)quantize_(linear, get_config(128))qw = linear.weightassert isinstance(qw, SupportsActivationPr...
1
16
1
123
0
81
98
81
null
[]
None
null
0
0
0
null
0
null
The function (test_activation_prescaling) defined within the public class called public.The function start at line 81 and ends at 98. It contains 16 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
def setUp(self):self.GPU_DEVICES = ["cuda"] if torch.cuda.is_available() else []
2
2
1
23
0
50
51
50
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 50 and ends at 51. It contains 2 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_linear
def test_linear(self, config):dtype = torch.bfloat16device = "cuda"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, dtype=dtype, device=device)original = linear(input)quantize_(linear, config)quantized = linear(input)self.assertTrue(compute_error(original, quantized) > 20)
1
9
2
84
0
54
62
54
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 54 and ends at 62. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm.__init__
def __init__(self, weight):super().__init__()self.weight = weight
1
3
2
19
0
69
71
69
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.__init__) defined within the public class called public.The function start at line 69 and ends at 71. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [69.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm.forward
def forward(self, x):return torch.bmm(x, self.weight)
1
2
2
18
0
73
74
73
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.forward) defined within the public class called public.The function start at line 73 and ends at 74. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [73.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm
def test_bmm(self, bmm_config):class M(torch.nn.Module):def __init__(self, weight):super().__init__()self.weight = weightdef forward(self, x):return torch.bmm(x, self.weight)dtype = torch.bfloat16device = "cuda"input = torch.randn(10, 32, 128, dtype=dtype, device=device)weight = torch.randn(10, 128, 256, dtype=dtype, d...
1
14
2
144
0
67
85
67
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm) defined within the public class called public.The function start at line 67 and ends at 85. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [67.0] and does not return any value..
pytorch_ao
public
public
0
0
test_from_int4_tensor
def test_from_int4_tensor(self):"""Test that constructing Int4PreshuffledTensor from Int4Tensoris the same as quantizing the original weight to Int4PreshuffledTensor"""int4_config = Int4WeightOnlyConfig(group_size=128,int4_packing_format="plain",)int4_preshuffled_config = Int4WeightOnlyConfig(group_size=128,int4_packin...
1
19
1
145
0
87
113
87
null
[]
None
null
0
0
0
null
0
null
The function (test_from_int4_tensor) defined within the public class called public.The function start at line 87 and ends at 113. It contains 19 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_to_device
def test_to_device(self, config):for device in self.GPU_DEVICES:linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear, config)linear.to(device)linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear, config)linear.to(device=device)linear = torch.nn.Linear(128, 256, dtype=torch.bfloat...
2
11
2
106
0
116
128
116
null
[]
None
null
0
0
0
null
0
null
The function (test_to_device) defined within the public class called public.The function start at line 116 and ends at 128. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [116.0] and does not return any value..
pytorch_ao
public
public
0
0
test_module_path
def test_module_path(self, config):linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear, config)self.assertEqual(str(type(linear.weight)),"<class 'torchao.quantization.Int4PreshuffledTensor'>",)with tempfile.NamedTemporaryFile() as f:torch.save(linear.state_dict(), f)f.seek(0)state_dict = torch.load...
1
15
2
101
0
131
146
131
null
[]
None
null
0
0
0
null
0
null
The function (test_module_path) defined within the public class called public.The function start at line 131 and ends at 146. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [131.0] and does not return any value..
pytorch_ao
public
public
0
0
setUp
def setUp(self):self.config = Int4WeightOnlyConfig(group_size=128,int4_packing_format="plain",)self.GPU_DEVICES = ["cuda"] if torch.cuda.is_available() else []
2
6
1
38
0
34
39
34
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 34 and ends at 39. It contains 6 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_linear
def test_linear(self):dtype = torch.bfloat16device = "cuda"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, dtype=dtype, device=device)original = linear(input)quantize_(linear, self.config)quantized = linear(input)self.assertTrue(compute_error(original, quantized) > 20)
1
9
1
84
0
41
49
41
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 41 and ends at 49. 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_slice
def test_slice(self):dtype = torch.bfloat16device = "cuda"dummy = torch.nn.Linear(256, 256, bias=False, dtype=dtype, device=device)dummy1 = torch.nn.Linear(256, 64, bias=False, dtype=dtype, device=device)dummy1.weight = torch.nn.Parameter(dummy.weight.narrow(0, 0, 64), requires_grad=False)dummy2 = torch.nn.Linear(128, ...
1
31
1
427
0
51
86
51
null
[]
None
null
0
0
0
null
0
null
The function (test_slice) defined within the public class called public.The function start at line 51 and ends at 86. It contains 31 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_slice_preserves_aliasing
def test_slice_preserves_aliasing(self):config = self.configl = torch.nn.Linear(1024, 1024).to("cuda").to(torch.bfloat16)l.weight = torch.nn.Parameter(torch.zeros(1024, 1024, dtype=torch.bfloat16, device="cuda"))quantize_(l, config)param = l.weightparam_data = param.dataparam_data = param_data.narrow(0, 0, 512)# Making...
1
13
1
145
0
88
101
88
null
[]
None
null
0
0
0
null
0
null
The function (test_slice_preserves_aliasing) defined within the public class called public.The function start at line 88 and ends at 101. 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_slice_and_copy_similar_to_vllm
def test_slice_and_copy_similar_to_vllm(self):self._test_slice_and_copy_similar_to_vllm(self.config)
1
2
1
13
0
103
104
103
null
[]
None
null
0
0
0
null
0
null
The function (test_slice_and_copy_similar_to_vllm) defined within the public class called public.The function start at line 103 and ends at 104. 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_bmm.__init__
def __init__(self, weight):super().__init__()self.weight = weight
1
3
2
19
0
109
111
109
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.__init__) defined within the public class called public.The function start at line 109 and ends at 111. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [109.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm.forward
def forward(self, x):return torch.bmm(x, self.weight)
1
2
2
18
0
113
114
113
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm.forward) defined within the public class called public.The function start at line 113 and ends at 114. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [113.0] and does not return any value..
pytorch_ao
public
public
0
0
test_bmm
def test_bmm(self):class M(torch.nn.Module):def __init__(self, weight):super().__init__()self.weight = weightdef forward(self, x):return torch.bmm(x, self.weight)dtype = torch.bfloat16device = "cuda"input = torch.randn(10, 32, 128, dtype=dtype, device=device)weight = torch.randn(10, 128, 256, dtype=dtype, device=device...
1
14
1
144
0
107
126
107
null
[]
None
null
0
0
0
null
0
null
The function (test_bmm) defined within the public class called public.The function start at line 107 and ends at 126. It contains 14 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_to_device
def test_to_device(self, sizes):config = self.configM, N, K = sizesdtype = torch.bfloat16for device in self.GPU_DEVICES:input_tensor = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype)quantize_(linear, config)linear.to(device)linear(input_tensor)linear = torch.nn.Linear(K, N, dty...
2
18
2
148
0
136
155
136
null
[]
None
null
0
0
0
null
0
null
The function (test_to_device) defined within the public class called public.The function start at line 136 and ends at 155. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [136.0] and does not return any value..
pytorch_ao
public
public
0
0
test_cat
def test_cat(self, sizes):config = self.configdtype = torch.bfloat16device = "cuda"M, N, K = sizeslinear1 = torch.nn.Linear(K, N, dtype=dtype, device=device)linear2 = torch.nn.Linear(K, N, dtype=dtype, device=device)input_cat1 = torch.randn(*M, K, dtype=dtype, device=device)cat_weight1 = torch.cat([linear1.weight, line...
1
46
2
389
0
165
218
165
null
[]
None
null
0
0
0
null
0
null
The function (test_cat) defined within the public class called public.The function start at line 165 and ends at 218. It contains 46 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [165.0] and does not return any value..
pytorch_ao
public
public
0
0
test_moe_weight_reshape_ops
def test_moe_weight_reshape_ops(self):self._test_moe_weight_reshape_ops(self.config)
1
2
1
13
0
220
221
220
null
[]
None
null
0
0
0
null
0
null
The function (test_moe_weight_reshape_ops) defined within the public class called public.The function start at line 220 and ends at 221. 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_activation_prescaling
def test_activation_prescaling(self):dtype = torch.bfloat16device = "cuda"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, bias=False, dtype=dtype, device=device)original = linear(input)quantize_(linear, self.config)qw = linear.weightassert isinstance(qw, SupportsActivationPreSc...
1
16
1
122
0
223
240
223
null
[]
None
null
0
0
0
null
0
null
The function (test_activation_prescaling) defined within the public class called public.The function start at line 223 and ends at 240. It contains 16 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
def setUp(self):self.GPU_DEVICES = ["cuda"] if torch.cuda.is_available() else []
2
2
1
23
0
42
43
42
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 42 and ends at 43. It contains 2 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_linear
def test_linear(self, sizes, config):dtype = torch.bfloat16device = "cuda"M, N, K = sizesinput = torch.randn(*M, K, dtype=dtype, device=device)linear = torch.nn.Linear(K, N, dtype=dtype, device=device)original = linear(input)quantize_(linear, config)quantized = linear(input)self.assertTrue(compute_error(original, quant...
1
13
3
121
0
54
69
54
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 54 and ends at 69. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
test_module_path
def test_module_path(self, config):linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)quantize_(linear.cuda(), config)self.assertEqual(str(type(linear.weight)),"<class 'torchao.quantization.Int4TilePackedTo4dTensor'>",)with tempfile.NamedTemporaryFile() as f:torch.save(linear.state_dict(), f)f.seek(0)state_dict = ...
1
15
2
105
0
72
87
72
null
[]
None
null
0
0
0
null
0
null
The function (test_module_path) defined within the public class called public.The function start at line 72 and ends at 87. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [72.0] and does not return any value..
pytorch_ao
public
public
0
0
test_slice
def test_slice(self, config):"""Note: we use multiples of 1024 for both in_features and out_featuresso that padding does not affect the weight after slicing"""dtype = torch.bfloat16device = "cuda"# Create a 2048x2048 linear layer for testingdummy = torch.nn.Linear(2048, 2048, bias=False, dtype=dtype, device=device)# Cr...
1
43
2
450
0
90
176
90
null
[]
None
null
0
0
0
null
0
null
The function (test_slice) defined within the public class called public.The function start at line 90 and ends at 176. It contains 43 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [90.0] and does not return any value..
pytorch_ao
public
public
0
0
test_slice_preserves_aliasing
def test_slice_preserves_aliasing(self, config):l = torch.nn.Linear(1024, 1024).to("cuda").to(torch.bfloat16)l.weight = torch.nn.Parameter(torch.zeros(1024, 1024, dtype=torch.bfloat16, device="cuda"))quantize_(l, config)param = l.weightparam_data = param.dataparam_data = param_data.narrow(0, 0, 512)# Making sure the al...
1
13
2
126
0
179
192
179
null
[]
None
null
0
0
0
null
0
null
The function (test_slice_preserves_aliasing) defined within the public class called public.The function start at line 179 and ends at 192. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [179.0] and does not return any value..
pytorch_ao
public
public
0
0
test_cant_initialize_in_cpu
def test_cant_initialize_in_cpu(self):config = INT4_CONFIGlinear = torch.nn.Linear(128, 256, dtype=torch.bfloat16)# make sure there is no cpu implementation of the packing op currentlywith self.assertRaisesRegex(NotImplementedError,"Could not run 'aten::_convert_weight_to_int4pack' with arguments from the 'CPU' backend...
1
8
1
43
0
194
202
194
null
[]
None
null
0
0
0
null
0
null
The function (test_cant_initialize_in_cpu) defined within the public class called public.The function start at line 194 and ends at 202. It contains 8 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_to_device
def test_to_device(self):# test calling to on the tensor that's already on the same device worksconfig = INT4_CONFIGfor device in self.GPU_DEVICES:linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16, device=device)quantize_(linear, config)linear.to(device)linear = torch.nn.Linear(128, 256, dtype=torch.bfloat16, dev...
2
12
1
119
0
204
219
204
null
[]
None
null
0
0
0
null
0
null
The function (test_to_device) defined within the public class called public.The function start at line 204 and ends at 219. 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_slice_and_copy_similar_to_vllm
def test_slice_and_copy_similar_to_vllm(self, config):self._test_slice_and_copy_similar_to_vllm(config)
1
2
2
13
0
222
223
222
null
[]
None
null
0
0
0
null
0
null
The function (test_slice_and_copy_similar_to_vllm) defined within the public class called public.The function start at line 222 and ends at 223. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [222.0] and does not return any value..
pytorch_ao
public
public
0
0
test_mm_int4wo
def test_mm_int4wo(self, device, dtype):weight = torch.randn(512, 1024).to(device).to(dtype)weight = weight.t()l = torch.nn.Linear(512, 1024).to(device).to(dtype)l.weight = torch.nn.Parameter(weight)quantize_(l, INT4_CONFIG)# weight shape: 1024 x 512weight = l.weightinput = torch.randn(1, 512, device=device, dtype=dtyp...
1
9
3
111
0
227
239
227
null
[]
None
null
0
0
0
null
0
null
The function (test_mm_int4wo) defined within the public class called public.The function start at line 227 and ends at 239. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [227.0] and does not return any value..
pytorch_ao
public
public
0
0
test_activation_prescaling
def test_activation_prescaling(self, config):dtype = torch.bfloat16device = "cuda"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, bias=False, dtype=dtype, device=device)original = linear(input)quantize_(linear, config)qw = linear.weightassert isinstance(qw, SupportsActivationPr...
1
16
2
122
0
242
259
242
null
[]
None
null
0
0
0
null
0
null
The function (test_activation_prescaling) defined within the public class called public.The function start at line 242 and ends at 259. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [242.0] and does not return any value..
pytorch_ao
public
public
0
0
test_different_group_sizes
def test_different_group_sizes(self, group_size):"""Test with different group sizes"""dtype = torch.bfloat16device = "cuda"hp_tensor = torch.randn(256, 512, dtype=dtype, device=device)block_size = (1, group_size)tensor = Int4TilePackedTo4dTensor.from_hp(hp_tensor, block_size)self.assertEqual(tensor.shape, hp_tensor.sha...
1
8
2
73
0
262
272
262
null
[]
None
null
0
0
0
null
0
null
The function (test_different_group_sizes) defined within the public class called public.The function start at line 262 and ends at 272. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [262.0] and does not return any value..
pytorch_ao
public
public
0
0
test_error_conditions
def test_error_conditions(self):"""Test various error conditions"""dtype = torch.bfloat16device = "cuda"hp_tensor = torch.randn(128, 256, dtype=dtype, device=device)# Test invalid block_size lengthwith self.assertRaises(AssertionError):Int4TilePackedTo4dTensor.from_hp(hp_tensor, (64,))# block_size length mismatch# Test...
1
12
1
71
0
274
290
274
null
[]
None
null
0
0
0
null
0
null
The function (test_error_conditions) defined within the public class called public.The function start at line 274 and ends at 290. It contains 12 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
_get_accuracy_test_cases._is_valid_test_combination
def _is_valid_test_combination(model_dtype,packing_format,weight_dtype,weight_mapping_type,weight_granularity,):# ATEN restrictionsif packing_format == IntxPackingFormat.OPAQUE_ATEN_KLEIDIAI:if weight_dtype != torch.int4:return Falseif weight_mapping_type == MappingType.ASYMMETRIC:return Falseif model_dtype != torch.fl...
10
25
5
92
0
64
94
64
null
[]
None
null
0
0
0
null
0
null
The function (_get_accuracy_test_cases._is_valid_test_combination) defined within the public class called public.The function start at line 64 and ends at 94. It contains 25 lines of code and it has a cyclomatic complexity of 10. It takes 5 parameters, represented as [64.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_accuracy_test_cases
def _get_accuracy_test_cases():MODEL_DTYPES = [torch.float32,torch.bfloat16,]PACKING_FORMATS = [IntxPackingFormat.UNPACKED_TO_INT8,IntxPackingFormat.OPAQUE_ATEN_KLEIDIAI,IntxPackingFormat.OPAQUE_TORCHAO_AUTO,IntxPackingFormat.OPAQUE_TORCHAO_KLEIDIAI,IntxPackingFormat.OPAQUE_TORCHAO_LOWBIT,]WEIGHT_DTYPES = [torch.int1,t...
7
45
0
169
6
31
112
31
null
['MAPPING_TYPES', 'MODEL_DTYPES', 'test_cases', 'WEIGHT_DTYPES', 'GRANULARITIES', 'PACKING_FORMATS']
None
null
0
0
0
null
0
null
The function (_get_accuracy_test_cases) defined within the public class called public.The function start at line 31 and ends at 112. It contains 45 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
test_accuracy
def test_accuracy(self,model_dtype,packing_format,weight_dtype,weight_mapping_type,weight_granularity,):"""Checks the accuracy of packed layouts"""m = 3n = 1071k = 2048activations = torch.randn(m, k).to(model_dtype)model = torch.nn.Sequential(*[torch.nn.Linear(k, k, bias=False), torch.nn.Linear(k, n, bias=True)]).to(mo...
1
42
6
201
0
121
169
121
null
[]
None
null
0
0
0
null
0
null
The function (test_accuracy) defined within the public class called public.The function start at line 121 and ends at 169. It contains 42 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
test_export_compile_aoti
def test_export_compile_aoti(self,):m = 3k0 = 512k1 = 256k2 = 128k3 = 1024weight_dtype = torch.int4weight_granularity = PerAxis(0)weight_mapping_type = MappingType.ASYMMETRIClayers = [torch.nn.Linear(k0, k1, bias=False),torch.nn.Linear(k1, k2, bias=True),torch.nn.Linear(k2, k3, bias=False),]model = torch.nn.Sequential(...
1
54
1
336
0
171
232
171
null
[]
None
null
0
0
0
null
0
null
The function (test_export_compile_aoti) defined within the public class called public.The function start at line 171 and ends at 232. It contains 54 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_serialization
def test_serialization(self, packing_format):layers = [torch.nn.Linear(512, 256),]model = torch.nn.Sequential(*layers)model2 = torch.nn.Sequential(*layers)activations = torch.randn(1, 512, dtype=torch.float32)quantize_(model,Int8DynamicActivationIntxWeightConfig(weight_dtype=torch.int4,weight_granularity=PerGroup(64),i...
1
25
2
164
0
244
272
244
null
[]
None
null
0
0
0
null
0
null
The function (test_serialization) defined within the public class called public.The function start at line 244 and ends at 272. It contains 25 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [244.0] and does not return any value..
pytorch_ao
public
public
0
0
test_moe_quant_intx
def test_moe_quant_intx(self):from torchao.prototype.moe_quant.quantizable_moe_modules import (MOEFeedForwardAOQuantizable,)from torchao.prototype.moe_quant.utils import (FakeExtraDimTensor,MoEQuantConfig,UseFakeExtraDimTensor,cond_ffn_filter,)from torchao.quantization.quant_api import (Int8DynamicActivationIntxWeightC...
1
37
1
227
0
274
319
274
null
[]
None
null
0
0
0
null
0
null
The function (test_moe_quant_intx) defined within the public class called public.The function start at line 274 and ends at 319. It contains 37 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
def setUp(self):self.config = IntxWeightOnlyConfig(weight_dtype=torch.int4,granularity=PerGroup(32),version=2,)
1
6
1
29
0
35
40
35
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 35 and ends at 40. 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_embedding
def test_embedding(self):dtype = torch.bfloat16device = "cpu"input = torch.randint(low=0, high=128, size=(10,), device=device)embedding = torch.nn.Embedding(128, 256, dtype=dtype, device=device)original = embedding(input)quantize_(embedding, self.config)quantized = embedding(input)error = compute_error(original, quanti...
1
10
1
94
0
42
51
42
null
[]
None
null
0
0
0
null
0
null
The function (test_embedding) defined within the public class called public.The function start at line 42 and ends at 51. 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_linear
def test_linear(self):dtype = torch.bfloat16device = "cpu"input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, dtype=dtype, device=device)original = linear(input)quantize_(linear, self.config)quantized = linear(input)error = compute_error(original, quantized)self.assertTrue(error > ...
1
10
1
87
0
53
62
53
null
[]
None
null
0
0
0
null
0
null
The function (test_linear) defined within the public class called public.The function start at line 53 and ends at 62. 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_hqq_intx_weight_only_config
def test_hqq_intx_weight_only_config(self):dtype = torch.bfloat16device = "cpu"config = IntxWeightOnlyConfig(weight_dtype=torch.int4,granularity=PerGroup(32),intx_choose_qparams_algorithm="hqq_scale_only",)input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(128, 256, dtype=dtype, device=devi...
1
15
1
110
0
64
78
64
null
[]
None
null
0
0
0
null
0
null
The function (test_hqq_intx_weight_only_config) defined within the public class called public.The function start at line 64 and ends at 78. It contains 15 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_hqq_int8_dyn_act_intx_weight_config
def test_hqq_int8_dyn_act_intx_weight_config(self):dtype = torch.bfloat16device = "cpu"config = Int8DynamicActivationIntxWeightConfig(weight_dtype=torch.int4,weight_granularity=PerGroup(32),intx_choose_qparams_algorithm="hqq_scale_only",)input = torch.randn(1, 128, dtype=dtype, device=device)linear = torch.nn.Linear(12...
1
15
1
110
0
80
94
80
null
[]
None
null
0
0
0
null
0
null
The function (test_hqq_int8_dyn_act_intx_weight_config) defined within the public class called public.The function start at line 80 and ends at 94. It contains 15 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_slice
def test_slice(self):dtype = torch.bfloat16device = "cpu"dummy = torch.nn.Linear(256, 256, bias=False, dtype=dtype, device=device)dummy1 = torch.nn.Linear(256, 64, bias=False, dtype=dtype, device=device)dummy1.weight = torch.nn.Parameter(dummy.weight.narrow(0, 0, 64), requires_grad=False)dummy2 = torch.nn.Linear(128, 2...
1
29
1
373
0
96
133
96
null
[]
None
null
0
0
0
null
0
null
The function (test_slice) defined within the public class called public.The function start at line 96 and ends at 133. It contains 29 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_slice_and_copy_
def test_slice_and_copy_(self):device = "cpu"l = torch.nn.Linear(1024, 1024).to(device).to(torch.bfloat16)quantize_(l, self.config)param = l.weightparam_data = param.dataparam_data = param_data.narrow(0, 0, 512)assert param.data.qdata.data_ptr() == param_data.qdata.data_ptr()assert param.data.scale.data_ptr() == param_...
1
16
1
193
0
135
155
135
null
[]
None
null
0
0
0
null
0
null
The function (test_slice_and_copy_) defined within the public class called public.The function start at line 135 and ends at 155. It contains 16 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_to_dtype
def test_to_dtype(self):activations_bf16 = torch.randn(1, 128, dtype=torch.bfloat16)activations_fp32 = torch.randn(1, 128, dtype=torch.float32)activations_fp16 = torch.randn(1, 128, dtype=torch.float16)linear = torch.nn.Linear(128, 256)quantize_(linear, self.config)linear.to(dtype=torch.float16)linear(activations_fp16)...
1
12
1
115
0
157
172
157
null
[]
None
null
0
0
0
null
0
null
The function (test_to_dtype) defined within the public class called public.The function start at line 157 and ends at 172. It contains 12 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_intx_weight_only_config
def test_export_intx_weight_only_config(self):linear = torch.nn.Linear(128, 256)quantize_(linear, self.config)ep = torch.export.export(linear, (torch.randn(1, 128),))assert "torch.ops.torchao.dequantize_affine.default" in ep.graph_module.code
1
5
1
55
0
174
178
174
null
[]
None
null
0
0
0
null
0
null
The function (test_export_intx_weight_only_config) defined within the public class called public.The function start at line 174 and ends at 178. 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_int8_dyn_act_intx_weight_config
def test_export_int8_dyn_act_intx_weight_config(self):layers = [torch.nn.Linear(512, 256, bias=False),]model = torch.nn.Sequential(*layers)activations = torch.randn(1, 512, dtype=torch.float32)quantize_(model,Int8DynamicActivationIntxWeightConfig(weight_dtype=torch.int4,weight_granularity=PerAxis(0),weight_mapping_type...
2
31
1
191
0
180
214
180
null
[]
None
null
0
0
0
null
0
null
The function (test_export_int8_dyn_act_intx_weight_config) defined within the public class called public.The function start at line 180 and ends at 214. It contains 31 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_export_int8_dyn_act_intx_weight_config_with_unwrap
def test_export_int8_dyn_act_intx_weight_config_with_unwrap(self):layers = [torch.nn.Linear(512, 256, bias=False),]model = torch.nn.Sequential(*layers)activations = torch.randn(1, 512, dtype=torch.float32)quantize_(model,Int8DynamicActivationIntxWeightConfig(weight_dtype=torch.int4,weight_granularity=PerGroup(64),weigh...
2
32
1
195
0
216
252
216
null
[]
None
null
0
0
0
null
0
null
The function (test_export_int8_dyn_act_intx_weight_config_with_unwrap) defined within the public class called public.The function start at line 216 and ends at 252. It contains 32 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_serialization_int8_dyn_act_intx_weight_config
def test_serialization_int8_dyn_act_intx_weight_config(self):layers = [torch.nn.Linear(512, 256),]model = torch.nn.Sequential(*layers)model2 = torch.nn.Sequential(*layers)activations = torch.randn(1, 512, dtype=torch.float32)quantize_(model,Int8DynamicActivationIntxWeightConfig(weight_dtype=torch.int4,weight_granularit...
1
25
1
164
0
254
282
254
null
[]
None
null
0
0
0
null
0
null
The function (test_serialization_int8_dyn_act_intx_weight_config) defined within the public class called public.The function start at line 254 and ends at 282. It contains 25 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_serialization_intx_weight_only_config
def test_serialization_intx_weight_only_config(self):layers = [torch.nn.Linear(512, 256),]model = torch.nn.Sequential(*layers)model2 = torch.nn.Sequential(*layers)activations = torch.randn(1, 512, dtype=torch.float32)quantize_(model,IntxWeightOnlyConfig(weight_dtype=torch.int4,granularity=PerGroup(64),intx_packing_form...
1
25
1
164
0
284
312
284
null
[]
None
null
0
0
0
null
0
null
The function (test_serialization_intx_weight_only_config) defined within the public class called public.The function start at line 284 and ends at 312. It contains 25 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_qat_int8_dyn_act_intx_weight_config
def test_qat_int8_dyn_act_intx_weight_config(self, weight_dtype, group_size, mapping_type, scale_dtype, model_dtype):activation_config = IntxFakeQuantizeConfig(torch.int8, "per_token", is_symmetric=False, scale_precision=scale_dtype)weight_config = IntxFakeQuantizeConfig(weight_dtype,group_size=group_size,mapping_type=...
2
60
6
276
0
331
398
331
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_int8_dyn_act_intx_weight_config) defined within the public class called public.The function start at line 331 and ends at 398. It contains 60 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [331.0] and does not return any value..
pytorch_ao
public
public
0
0
test_intx_unpacked_v2_is_close_to_qdq_v1
def test_intx_unpacked_v2_is_close_to_qdq_v1(self,weight_dtype,group_size,mapping_type,act_mapping_type,scale_dtype,model_dtype,):k0 = 512k1 = 256layers = [torch.nn.Linear(k0, k1),]model = torch.nn.Sequential(*layers)activations = torch.randn(k0,)model = model.to(model_dtype)activations = activations.to(model_dtype)mod...
3
52
7
231
0
419
476
419
null
[]
None
null
0
0
0
null
0
null
The function (test_intx_unpacked_v2_is_close_to_qdq_v1) defined within the public class called public.The function start at line 419 and ends at 476. It contains 52 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [419.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse24_sm90_sparsify_identity
def test_sparse24_sm90_sparsify_identity(M=512, K=1024, fp8=torch.float8_e4m3fn) -> None:torch.manual_seed(0)A_sp_ref = create_semi_structured_tensor(M, K, dtype=torch.bfloat16).cuda()# Test with act="identity"A_packed_ref, A_mdata_ref = to_sparse_semi_structured_cutlass_sm9x_f8(A_sp_ref.to(fp8))A_packed, A_mdata = tor...
1
18
3
154
1
27
50
27
null
['A_sp_ref']
None
null
0
0
0
null
0
null
The function (test_sparse24_sm90_sparsify_identity) defined within the public class called public.The function start at line 27 and ends at 50. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [27.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse24_sm90_sparsify_identity_scaled
def test_sparse24_sm90_sparsify_identity_scaled(M=512, K=1024, fp8=torch.float8_e4m3fn) -> None:torch.manual_seed(0)A_dense = create_semi_structured_tensor(M, K, dtype=torch.bfloat16).cuda()A_scale = torch.randn([M, 1], device="cuda", dtype=torch.float32).abs() + 0.1A_sp_ref = (A_dense / A_scale).bfloat16()A_packed_ref...
1
23
3
205
3
54
77
54
null
['A_dense', 'A_scale', 'A_sp_ref']
None
null
0
0
0
null
0
null
The function (test_sparse24_sm90_sparsify_identity_scaled) defined within the public class called public.The function start at line 54 and ends at 77. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse24_sm90_sparsify_srelu
def test_sparse24_sm90_sparsify_srelu(M=512, K=1024, fp8=torch.float8_e4m3fn) -> None:torch.manual_seed(0)A_dense = create_semi_structured_tensor(M, K, dtype=torch.bfloat16).cuda()A_sp_ref = (A_dense.float().relu() ** 2).bfloat16()# Test with act="srelu"# NOTE: Due to different rounding strategies, and way more zeros, ...
1
18
3
157
2
81
102
81
null
['A_dense', 'A_sp_ref']
None
null
0
0
0
null
0
null
The function (test_sparse24_sm90_sparsify_srelu) defined within the public class called public.The function start at line 81 and ends at 102. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [81.0] and does not return any value..
pytorch_ao
public
public
0
0
test_srelu_fp8_semi_sparse_activation_linear.srelu_linear
def srelu_linear(x):x = F.relu(x) ** 2return reference_linear(x)
1
3
1
20
0
124
126
124
null
[]
None
null
0
0
0
null
0
null
The function (test_srelu_fp8_semi_sparse_activation_linear.srelu_linear) defined within the public class called public.The function start at line 124 and ends at 126. It contains 3 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_srelu_fp8_semi_sparse_activation_linear
def test_srelu_fp8_semi_sparse_activation_linear(M=512, K=2048, N=1024):with torch.no_grad():torch.manual_seed(0)input_tensor = create_semi_structured_tensor(M, K, dtype=torch.bfloat16).cuda()# we have to wrap in a sequential block for quantize_ to work properlyreference_linear = torch.nn.Sequential(torch.nn.Linear(K, ...
1
26
3
184
7
106
144
106
null
['x', 'custom_output', 'input_tensor', 'reference_linear', 'reference_srelu', 'reference_linear_copy', 'reference_output']
None
null
0
0
0
null
0
null
The function (test_srelu_fp8_semi_sparse_activation_linear) defined within the public class called public.The function start at line 106 and ends at 144. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [106.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse24_fp8_sm90_cutlass_gemm_eye
def test_sparse24_fp8_sm90_cutlass_gemm_eye(M=512, K=256, dtype=torch.float8_e4m3fn) -> None:torch.manual_seed(0)A_dense = create_semi_structured_tensor(M, K, dtype=torch.bfloat16).cuda()A_aqt = _float8_cutlass_quant(A_dense, dtype)A = A_aqt.tensor_impl.float8_data# NOTE: CUTLASS compression kernel expects the input to...
1
24
3
260
7
148
179
148
null
['eye', 'A_reconstructed', 'a_scale', 'A_dense', 'A_aqt', 'b_scale', 'A']
None
null
0
0
0
null
0
null
The function (test_sparse24_fp8_sm90_cutlass_gemm_eye) defined within the public class called public.The function start at line 148 and ends at 179. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [148.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse24_fp8_sm90_cutlass_gemm_random_tensor._to_fp8_rowwise
def _to_fp8_rowwise(x: torch.Tensor, dtype):max_v = torch.finfo(dtype).maxx_scale = (x.abs().max(1, keepdim=True)[0] / max_v).float()x = (x / x_scale).to(dtype)return x, x_scale
1
5
2
64
0
186
190
186
null
[]
None
null
0
0
0
null
0
null
The function (test_sparse24_fp8_sm90_cutlass_gemm_random_tensor._to_fp8_rowwise) defined within the public class called public.The function start at line 186 and ends at 190. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [186.0] and does not return any value....
pytorch_ao
public
public
0
0
test_sparse24_fp8_sm90_cutlass_gemm_random_tensor
def test_sparse24_fp8_sm90_cutlass_gemm_random_tensor(M=512, N=1024, K=256, dtype=torch.float8_e4m3fn) -> None:def _to_fp8_rowwise(x: torch.Tensor, dtype):max_v = torch.finfo(dtype).maxx_scale = (x.abs().max(1, keepdim=True)[0] / max_v).float()x = (x / x_scale).to(dtype)return x, x_scaletorch.manual_seed(0)A_dense = cr...
1
19
4
178
9
183
209
183
null
['max_v', 'B', 'out_sparse', 'x', 'A_dense', 'x_scale', 'b_scale', 'out_ref', 'B_dense']
None
null
0
0
0
null
0
null
The function (test_sparse24_fp8_sm90_cutlass_gemm_random_tensor) defined within the public class called public.The function start at line 183 and ends at 209. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [183.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.linear1 = nn.Linear(128, 256, bias=False)self.linear2 = nn.Linear(256, 128, bias=False)
1
4
1
44
0
22
25
22
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 22 and ends at 25. 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
forward
def forward(self, x):x = self.linear1(x)x = torch.nn.functional.relu(x)x = self.linear2(x)return x
1
5
2
37
0
27
31
27
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 27 and ends at 31. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [27.0] and does not return any value..
pytorch_ao
public
public
0
0
test_runtime_weight_sparsification
def test_runtime_weight_sparsification(self):# need this import inside to not break 2.2 testsfrom torch.sparse import SparseSemiStructuredTensorCUSPARSELTinput = torch.rand((128, 128)).half().cuda()grad = torch.rand((128, 128)).half().cuda()model = ToyModel().half().cuda()model_c = copy.deepcopy(model)for name, mod in ...
4
31
1
275
0
38
81
38
null
[]
None
null
0
0
0
null
0
null
The function (test_runtime_weight_sparsification) defined within the public class called public.The function start at line 38 and ends at 81. It contains 31 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_runtime_weight_sparsification_compile
def test_runtime_weight_sparsification_compile(self):# need this import inside to not break 2.2 testsfrom torch.sparse import SparseSemiStructuredTensorCUSPARSELTinput = torch.rand((128, 128)).half().cuda()grad = torch.rand((128, 128)).half().cuda()model = ToyModel().half().cuda()model_c = copy.deepcopy(model)for name,...
4
33
1
299
0
86
131
86
null
[]
None
null
0
0
0
null
0
null
The function (test_runtime_weight_sparsification_compile) defined within the public class called public.The function start at line 86 and ends at 131. It contains 33 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
setUp
def setUp(self):super().setUp()torch.manual_seed(0)self.input = torch.randn((32, 16, 4096), dtype=torch.float16, device="cuda")self.model = (nn.Sequential(nn.Linear(4096, 21504),nn.Linear(21504, 4096),nn.ReLU(),nn.Linear(4096, 21504),nn.Linear(21504, 4096),).half().cuda())
1
15
1
105
0
26
41
26
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 26 and ends at 41. It contains 15 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_quant_sparse_marlin_layout_eager
def test_quant_sparse_marlin_layout_eager(self):apply_fake_sparsity(self.model)model_copy = copy.deepcopy(self.model)# Quantizedquantize_(model_copy.bfloat16(), Int4WeightOnlyConfig(version=1))dense_result = model_copy(self.input.bfloat16()).half()# Sparse + quantizedquantize_(self.model, Int4WeightOnlyConfig(layout=Ma...
1
12
1
100
0
45
60
45
null
[]
None
null
0
0
0
null
0
null
The function (test_quant_sparse_marlin_layout_eager) defined within the public class called public.The function start at line 45 and ends at 60. It contains 12 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_quant_sparse_marlin_layout_compile
def test_quant_sparse_marlin_layout_compile(self):apply_fake_sparsity(self.model)model_copy = copy.deepcopy(self.model)# Quantizedquantize_(model_copy.bfloat16(), Int4WeightOnlyConfig(version=1))model_copy.foward = torch.compile(model_copy.forward, fullgraph=True)dense_result = model_copy(self.input.bfloat16()).half()#...
1
14
1
136
0
64
82
64
null
[]
None
null
0
0
0
null
0
null
The function (test_quant_sparse_marlin_layout_compile) defined within the public class called public.The function start at line 64 and ends at 82. It contains 14 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_pack_unpack_equivalence
def test_pack_unpack_equivalence(self):num_bits = 4group_size = 128shape = (11008, 4096)block_size = (1, group_size)target_dtype = torch.int32quant_min = 0quant_max = 15eps = 1e-6zero_point_dtype = torch.bfloat16mapping_type = MappingType.SYMMETRICscale_dtype = Nonew = torch.rand(shape, dtype=torch.float16, device="cud...
1
47
1
205
0
85
139
85
null
[]
None
null
0
0
0
null
0
null
The function (test_pack_unpack_equivalence) defined within the public class called public.The function start at line 85 and ends at 139. It contains 47 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_sparse
def test_sparse(self):input = torch.rand((128, 128)).half().cuda()model = (nn.Sequential(nn.Linear(128, 256),nn.Linear(256, 128),).half().cuda().eval())apply_fake_sparsity(model)dense_result = model(input)sparsify_(model, semi_sparse_weight())sparse_result = model(input)if compile:model = torch.compile(model)torch.test...
2
18
1
121
0
35
56
35
null
[]
None
null
0
0
0
null
0
null
The function (test_sparse) defined within the public class called public.The function start at line 35 and ends at 56. It contains 18 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_quant_semi_sparse
def test_quant_semi_sparse(self, compile):if not torch.backends.cusparselt.is_available():self.skipTest("Need cuSPARSELt")# compile True failed with CUDA error: operation not supported when calling `cusparseLtMatmulDescriptorInit(...# https://github.com/pytorch/ao/actions/runs/11978863581/job/33402892517?pr=1330torch.s...
3
26
2
172
0
63
95
63
null
[]
None
null
0
0
0
null
0
null
The function (test_quant_semi_sparse) defined within the public class called public.The function start at line 63 and ends at 95. It contains 26 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [63.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse_marlin
def test_sparse_marlin(self, compile):if not torch.backends.cusparselt.is_available():self.skipTest("Need cuSPARSELt")input = torch.rand((256, 256)).half().cuda()model = (nn.Sequential(nn.Linear(256, 1024),nn.Linear(1024, 256),).half().cuda().eval())apply_fake_sparsity(model)model_copy = copy.deepcopy(model)# Quantized...
3
22
2
181
0
99
127
99
null
[]
None
null
0
0
0
null
0
null
The function (test_sparse_marlin) defined within the public class called public.The function start at line 99 and ends at 127. It contains 22 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [99.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8_cutlass_sparse
def test_fp8_cutlass_sparse(self, compile):input = torch.rand((256, 256)).half().cuda()model = (nn.Sequential(nn.Linear(256, 1024),nn.Linear(1024, 256),).half().cuda().eval())apply_fake_sparsity(model)model_copy = copy.deepcopy(model)# Quantizedquantize_(model_copy.bfloat16(), Float8DynamicActivationFloat8WeightConfig(...
2
20
2
151
0
132
157
132
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8_cutlass_sparse) defined within the public class called public.The function start at line 132 and ends at 157. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [132.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8_cutlass_sparse_lowering_op_clone
def test_fp8_cutlass_sparse_lowering_op_clone(self):with torch.inference_mode():model = nn.Linear(256, 1024).half().cuda().eval()apply_fake_sparsity(model)quantize_(model, Float8DynamicActivationFloat8SemiSparseWeightConfig())original = model.weight.original_weight_tensor.tensor_impl.get_plain()cloned = model.weight.or...
2
9
1
110
0
161
171
161
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8_cutlass_sparse_lowering_op_clone) defined within the public class called public.The function start at line 161 and ends at 171. 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_fp8_cutlass_sparse_lowering_op_to
def test_fp8_cutlass_sparse_lowering_op_to(self):# Need to run with inference mode to avoid dispatching to `aten.to_copy`with torch.inference_mode():model = nn.Linear(256, 1024).half().cuda().eval()apply_fake_sparsity(model)model_copy = copy.deepcopy(model)expected = model_copy.weight.to(dtype=torch.float)quantize_(mod...
1
13
1
123
0
175
190
175
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8_cutlass_sparse_lowering_op_to) defined within the public class called public.The function start at line 175 and ends at 190. 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_sparse
def test_sparse(self, compile, input_shape):input = torch.rand((input_shape, 1024)).half().cuda()model = (nn.Sequential(nn.Linear(1024, 2048),nn.Linear(2048, 1024),).half().cuda().eval())from torchao.sparsity.utils import create_block_sparse_tensorM, N = model[0].weight.shapemodel[0].weight.data = create_block_sparse_t...
1
21
3
201
0
197
224
197
null
[]
None
null
0
0
0
null
0
null
The function (test_sparse) defined within the public class called public.The function start at line 197 and ends at 224. It contains 21 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [197.0] and does not return any value..
pytorch_ao
public
public
0
0
test_sparse
def test_sparse(self, compile):input = torch.rand((256, 128)).to(torch.bfloat16).cuda()model = (nn.Sequential(nn.Linear(128, 256),nn.Linear(256, 128),).to(torch.bfloat16).cuda().eval())from torchao.sparsity.utils import create_block_sparse_tensorM, N = model[0].weight.shapemodel[0].weight.data = (create_block_sparse_te...
2
33
2
259
0
230
268
230
null
[]
None
null
0
0
0
null
0
null
The function (test_sparse) defined within the public class called public.The function start at line 230 and ends at 268. It contains 33 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [230.0] and does not return any value..
pytorch_ao
public
public
0
0
test_supermask
def test_supermask(self, sparsity_level, blocksize):model = (nn.Sequential(nn.Linear(16, 16, bias=False),).half().cuda().eval())from torchao.sparsity import SupermaskLinearM, N = model[0].weight.shapemodel[0] = SupermaskLinear.from_linear(model[0], sparsity_level=sparsity_level, blocksize=blocksize)model[0] = Supermask...
1
19
3
133
0
23
45
23
null
[]
None
null
0
0
0
null
0
null
The function (test_supermask) defined within the public class called public.The function start at line 23 and ends at 45. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [23.0] and does not return any value..
pytorch_ao
public
public
0
0
test_from_linear
def test_from_linear(self):from torchao.sparsity import SupermaskLinearlinear = nn.Linear(128, 128)supermask_linear = SupermaskLinear.from_linear(linear, sparsity_level=0.5, blocksize=4)assert supermask_linear.weight.shape == linear.weight.shape
1
7
1
51
0
48
55
48
null
[]
None
null
0
0
0
null
0
null
The function (test_from_linear) defined within the public class called public.The function start at line 48 and ends at 55. 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_prepare
def test_prepare(self):model = SimpleLinear()sparsifier = WandaSparsifier()sparsifier.prepare(model, config=None)for g in sparsifier.groups:module = g["module"]# Check mask existsassert hasattr(module.parametrizations["weight"][0], "mask")# Check parametrization exists and is correctassert is_parametrized(module, "weig...
2
12
1
85
0
28
42
28
null
[]
None
null
0
0
0
null
0
null
The function (test_prepare) defined within the public class called public.The function start at line 28 and ends at 42. 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..