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_prune_lstm_linear_single_layer
def test_prune_lstm_linear_single_layer(self):"""Test fusion support for LSTM (single-layer) -> Linear"""model = LSTMLinearModel(input_dim=8,hidden_dim=8,output_dim=8,num_layers=1,)config = [{"tensor_fqn": "lstm.weight_ih_l0"},{"tensor_fqn": "lstm.weight_hh_l0"},]lstm_input = torch.ones((1, 8))fx_pruner = BottomHalfLST...
1
26
1
152
0
789
827
789
null
[]
None
null
0
0
0
null
0
null
The function (test_prune_lstm_linear_single_layer) defined within the public class called public.The function start at line 789 and ends at 827. It contains 26 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_prune_lstm_layernorm_linear_multiple_layer
def test_prune_lstm_layernorm_linear_multiple_layer(self):"""Test fusion support for LSTM(multi-layer) -> Linear"""model = LSTMLayerNormLinearModel(input_dim=8,output_dim=8,hidden_dim=8,num_layers=2,)config = [{"tensor_fqn": "lstm.weight_ih_l0"},{"tensor_fqn": "lstm.weight_hh_l0"},{"tensor_fqn": "lstm.weight_ih_l1"},{"...
2
29
1
177
0
829
870
829
null
[]
None
null
0
0
0
null
0
null
The function (test_prune_lstm_layernorm_linear_multiple_layer) defined within the public class called public.The function start at line 829 and ends at 870. It contains 29 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_prune_lstm_layernorm_linear_single_layer
def test_prune_lstm_layernorm_linear_single_layer(self):"""Test fusion support for LSTM (single-layer) -> Linear"""model = LSTMLinearModel(input_dim=8,hidden_dim=8,output_dim=8,num_layers=1,)config = [{"tensor_fqn": "lstm.weight_ih_l0"},{"tensor_fqn": "lstm.weight_hh_l0"},]lstm_input = torch.ones((1, 8))fx_pruner = Bot...
1
26
1
152
0
872
910
872
null
[]
None
null
0
0
0
null
0
null
The function (test_prune_lstm_layernorm_linear_single_layer) defined within the public class called public.The function start at line 872 and ends at 910. It contains 26 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
__init__
def __init__(self):super().__init__()self.conv2d1 = nn.Conv2d(in_channels=1, out_channels=3, kernel_size=3, padding=1, bias=False)# Manually set the filter weights for demonstration purposes"""Three filters' weight are manually set to values 3.0, 2.0, and 0.1.Different from the norm-based decision that prunes filter wi...
1
18
1
187
0
920
945
920
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 920 and ends at 945. It contains 18 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.conv2d1(x)x = self.conv2d2(x)return x
1
4
2
25
0
947
950
947
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 947 and ends at 950. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [947.0] and does not return any value..
pytorch_ao
public
public
0
0
test_compute_distance
def test_compute_distance(self, device="cpu"):"""Test the distance computation function"""model = TestFPGMPruner.SimpleConvFPGM().to(device)pruner = FPGMPruner(0.3)dist_conv1 = pruner._compute_distance(model.conv2d1.weight)# compute the distance matrix using torch.cdistflattened_filters = torch.Tensor([[3.0000,3.0000,3...
1
48
2
223
0
952
1,011
952
null
[]
None
null
0
0
0
null
0
null
The function (test_compute_distance) defined within the public class called public.The function start at line 952 and ends at 1011. It contains 48 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [952.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_update_mask_on_single_layer
def _test_update_mask_on_single_layer(self, expected_conv1, device):"""Test that pruning is conducted based on the pair-wise distance measurement instead of absolute norm value"""# test pruning with one layer of conv2dmodel = TestFPGMPruner.SimpleConvFPGM().to(device)x = torch.ones((1, 1, 32, 32), device=device)pruner ...
1
26
3
208
0
1,013
1,045
1,013
null
[]
None
null
0
0
0
null
0
null
The function (_test_update_mask_on_single_layer) defined within the public class called public.The function start at line 1013 and ends at 1045. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1013.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_update_mask_on_multiple_layer
def _test_update_mask_on_multiple_layer(self, expected_conv1, expected_conv2, device):# the second settingmodel = TestFPGMPruner.SimpleConvFPGM().to(device)x = torch.ones((1, 1, 32, 32), device=device)pruner = FPGMPruner(0.3)config = [{"tensor_fqn": "conv2d1.weight"},{"tensor_fqn": "conv2d2.weight", "sparsity_level": 0...
2
31
4
286
0
1,047
1,084
1,047
null
[]
None
null
0
0
0
null
0
null
The function (_test_update_mask_on_multiple_layer) defined within the public class called public.The function start at line 1047 and ends at 1084. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [1047.0] and does not return any value..
pytorch_ao
public
public
0
0
test_update_mask
def test_update_mask(self):weights = torch.tensor([3.0, 0.1])expected_conv1 = torch.ones((2, 1, 3, 3)) * weights[:, None, None, None]weights = torch.tensor([7.0, 0.4])expected_conv2 = torch.ones((2, 2, 3, 3)) * weights[:, None, None, None]for device in DEVICES:self._test_update_mask_on_single_layer(expected_conv1, devi...
2
10
1
114
0
1,086
1,097
1,086
null
[]
None
null
0
0
0
null
0
null
The function (test_update_mask) defined within the public class called public.The function start at line 1086 and ends at 1097. It contains 10 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
__init__
def __init__(self, d0=512, d1=512, d2=256, d3=128, d4=32):super().__init__()self.embedding1 = torch.nn.Embedding(d0, d1)self.embedding2 = torch.nn.Embedding(d0, d1)self.embedding3 = torch.nn.Embedding(d0, d1)self.linear1 = torch.nn.Linear(d1, d2, bias=False)self.linear2 = torch.nn.Linear(d2, d3, bias=True)self.linear3 ...
1
16
6
244
0
41
63
41
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 41 and ends at 63. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [41.0] and does not return any value..
pytorch_ao
public
public
0
0
example_inputs
def example_inputs(self,lead_dim=(1,),dtype=torch.bfloat16,):return (torch.randint(0,self.embedding1.num_embeddings,size=lead_dim,dtype=torch.int64,device="cpu",),)
1
14
2
50
0
65
78
65
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 65 and ends at 78. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [65.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):x = self.embedding1(x) + self.embedding2(x) + self.embedding3(x)x = self.linear1(x)x = self.linear2(x)x = self.linear3(x)x = self.linear4(x)x = self.lm_head1(x) + self.lm_head2(x) + self.lm_head3(x)return x
1
8
2
85
0
80
87
80
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 80 and ends at 87. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [80.0] and does not return any value..
pytorch_ao
public
public
0
0
run_before_and_after_tests
def run_before_and_after_tests():yieldtorch._dynamo.reset()# reset cache between tests
1
3
0
12
0
91
93
91
null
[]
None
null
0
0
0
null
0
null
The function (run_before_and_after_tests) defined within the public class called public.The function start at line 91 and ends at 93. 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_aarch64_conversion
def test_aarch64_conversion(dtype, granularity, bit_width, lead_dim):torch.manual_seed(0)model = ToyLinearModelWithTiedEmbedding()model = model.to(dtype)example_inputs = model.example_inputs(lead_dim, dtype)# Quantize linear 2 and 3 with PARQquantizer = StretchedUnifTorchaoQuantizer(bit_width)config = StretchedIntxWeig...
2
62
4
403
11
110
189
110
null
['config', 'quantizer', 'sqnr_threshold', 'example_inputs', 'model', 'model_out', 'sqnr', 'converted_out', 'tied_group1_id', 'ep', 'expected_counts']
None
null
0
0
0
null
0
null
The function (test_aarch64_conversion) defined within the public class called public.The function start at line 110 and ends at 189. It contains 62 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [110.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4_tensor_conversion
def test_int4_tensor_conversion():m = torch.nn.Sequential(torch.nn.Linear(256, 512, dtype=torch.bfloat16, device="cuda"))quantize_(m, Int4WeightOnlyConfig(group_size=128))weight = m[0].weightassert isinstance(weight, Int4Tensor)example_inputs = (torch.randn(32, 256, dtype=torch.bfloat16, device="cuda"),)before_conversi...
1
15
0
139
5
196
210
196
null
['m', 'after_conversion', 'example_inputs', 'before_conversion', 'weight']
None
null
0
0
0
null
0
null
The function (test_int4_tensor_conversion) defined within the public class called public.The function start at line 196 and ends at 210. 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_triton_fp8_gemm_1x128_128x128
def test_triton_fp8_gemm_1x128_128x128(M, N, K, dtype):# Simulate output = input @ weight.TA = torch.randn(M, K, dtype=torch.bfloat16, device="cuda")B = torch.randn(N, K, dtype=torch.bfloat16, device="cuda")C = A @ B.TA_q, A_s = triton_fp8_blockwise_act_quant_lhs(A, dtype=dtype)B_t_q, B_t_s = triton_fp8_blockwise_weigh...
1
13
4
133
6
49
63
49
null
['min_sqnr', 'B', 'sqnr', 'C', 'C_q', 'A']
None
null
0
0
0
null
0
null
The function (test_triton_fp8_gemm_1x128_128x128) defined within the public class called public.The function start at line 49 and ends at 63. It contains 13 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_triton_fp8_gemm_1x128_128x1
def test_triton_fp8_gemm_1x128_128x1(M, N, K, dtype):# Simulate grad_weight = grad_output_t @ inputA = torch.randn(K, M, dtype=torch.bfloat16, device="cuda")B = torch.randn(K, N, dtype=torch.bfloat16, device="cuda")C = A.T @ BA_t_q, A_t_s = triton_fp8_blockwise_act_quant_transposed_lhs(A, dtype=dtype)B_q, B_s = triton_...
1
13
4
149
6
74
89
74
null
['min_sqnr', 'B', 'sqnr', 'C', 'C_q', 'A']
None
null
0
0
0
null
0
null
The function (test_triton_fp8_gemm_1x128_128x1) defined within the public class called public.The function start at line 74 and ends at 89. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [74.0] and does not return any value..
pytorch_ao
public
public
0
0
test_triton_quantize_fp8_act_quant_lhs
def test_triton_quantize_fp8_act_quant_lhs(block_size):device = "cuda"M, K = 4096, 1024x = torch.randn(M, K, device=device)# Set one scaling block to 0s, so if nan guards/EPS are not applied, the# quantized tensor will have NaNs due to division by 0x[0, :block_size] = 0.0# Get the quantized tensor and reciprocal scales...
1
28
1
159
4
95
136
95
null
['x', 'triton_fp32', 'device', 'ref_fp32']
None
null
0
0
0
null
0
null
The function (test_triton_quantize_fp8_act_quant_lhs) defined within the public class called public.The function start at line 95 and ends at 136. It contains 28 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_triton_quantize_fp8_act_quant_rhs
def test_triton_quantize_fp8_act_quant_rhs(block_size: int):device = "cuda"M, K = 4096, 1024x = torch.randn(M, K, device=device)# Set one block to 0s, so if nan guards/EPS are not applied, the# quantized tensor will have NaNs due to division by 0x[:block_size, :block_size] = 0.0# Get the quantized tensor and reciprocal...
1
28
1
162
4
142
183
142
null
['x', 'triton_fp32', 'device', 'ref_fp32']
None
null
0
0
0
null
0
null
The function (test_triton_quantize_fp8_act_quant_rhs) defined within the public class called public.The function start at line 142 and ends at 183. It contains 28 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_triton_quantize_fp8_act_quant_transposed_lhs
def test_triton_quantize_fp8_act_quant_transposed_lhs(M, K, block_size: int):device = "cuda"x = torch.randn(M, K, device=device)# Set one scaling block to 0s, so if nan guards/EPS are not applied, the# quantized tensor will have NaNs due to division by 0x[0, :block_size] = 0.0# Get the quantized tensor and reciprocal s...
1
29
3
166
4
190
232
190
null
['x', 'triton_fp32', 'device', 'ref_fp32']
None
null
0
0
0
null
0
null
The function (test_triton_quantize_fp8_act_quant_transposed_lhs) defined within the public class called public.The function start at line 190 and ends at 232. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [190.0] and does not return any value..
pytorch_ao
public
public
0
0
test_triton_quantize_fp8_weight_quant_rhs
def test_triton_quantize_fp8_weight_quant_rhs(M, K, block_size: int):device = "cuda"x = torch.randn(M, K, device=device)# Set one scaling block to 0s, so if nan guards/EPS are not applied, the# quantized tensor will have NaNs due to division by 0x[:block_size, :block_size] = 0.0# Get the quantized tensor and reciprocal...
1
27
3
159
4
239
278
239
null
['x', 'triton_fp32', 'device', 'ref_fp32']
None
null
0
0
0
null
0
null
The function (test_triton_quantize_fp8_weight_quant_rhs) defined within the public class called public.The function start at line 239 and ends at 278. It contains 27 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [239.0] and does not return any value..
pytorch_ao
public
public
0
0
test_triton_quantize_fp8_weight_quant_transposed_rhs
def test_triton_quantize_fp8_weight_quant_transposed_rhs(block_size: int):device = "cuda"M = 512K = 2048x = torch.randn(M, K, device=device)# Set one scaling block to 0s, so if nan guards/EPS are not applied, the# quantized tensor will have NaNs due to division by 0x[:block_size, :block_size] = 0.0# Get the quantized t...
1
31
1
169
6
284
327
284
null
['ref_fp32', 'device', 'x', 'M', 'triton_fp32', 'K']
None
null
0
0
0
null
0
null
The function (test_triton_quantize_fp8_weight_quant_transposed_rhs) defined within the public class called public.The function start at line 284 and ends at 327. 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_blockwise_quant_linear_fwd_bwd
def test_blockwise_quant_linear_fwd_bwd(in_features,out_features,batch_size,block_size,):if in_features % block_size != 0 or out_features % block_size != 0:pytest.skip(f"Dimensions must be divisible by block_size={block_size}")layer_ref = torch.nn.Linear(in_features=in_features,out_features=out_features,bias=False,).cu...
3
30
4
254
7
30
73
30
null
['y_test', 'x_test', 'sqnr', 'layer_ref', 'layer_test', 'y_ref', 'x_ref']
None
null
0
0
0
null
0
null
The function (test_blockwise_quant_linear_fwd_bwd) defined within the public class called public.The function start at line 30 and ends at 73. It contains 30 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [30.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,input_dim,has_mask,num_attention_heads=None,attention_head_size=None,) -> None:super().__init__()self.input_dim = input_dimself.q_proj = torch.nn.Linear(input_dim, input_dim, bias=False)self.k_proj = torch.nn.Linear(input_dim, input_dim, bias=False)self.v_proj = torch.nn.Linear(input_dim, input_dim, b...
1
21
5
167
0
22
42
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 42. It contains 21 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [22.0] and does not return any value..
pytorch_ao
public
public
0
0
transpose_for_scores
def transpose_for_scores(self, x: torch.Tensor) -> torch.Tensor:new_x_shape = x.size()[:-1] + (self.num_attention_heads,self.attention_head_size,)x = x.view(new_x_shape)return x.permute([0, 2, 1, 3])
1
7
2
61
0
44
50
44
null
[]
None
null
0
0
0
null
0
null
The function (transpose_for_scores) defined within the public class called public.The function start at line 44 and ends at 50. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [44.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x, mask):q = self.q_proj(x)k = self.k_proj(x)v = self.v_proj(x)q = self.transpose_for_scores(q)k = self.transpose_for_scores(k)v = self.transpose_for_scores(v)scores = torch.matmul(q, k.transpose(-1, -2)) / (self.input_dim**0.5)if self.has_mask and mask.dtype != scores.dtype:scores = scores + maskatte...
3
18
3
179
0
52
69
52
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 52 and ends at 69. It contains 18 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [52.0] and does not return any value..
pytorch_ao
public
public
0
0
_clone_inputs.clone
def clone(x):if not isinstance(x, torch.Tensor):return xreturn x.clone()
2
4
1
24
0
74
77
74
null
[]
None
null
0
0
0
null
0
null
The function (_clone_inputs.clone) defined within the public class called public.The function start at line 74 and ends at 77. 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
_clone_inputs
def _clone_inputs(self, inputs):def clone(x):if not isinstance(x, torch.Tensor):return xreturn x.clone()return [clone(x) for x in inputs]
2
3
2
20
0
73
79
73
null
[]
None
null
0
0
0
null
0
null
The function (_clone_inputs) defined within the public class called public.The function start at line 73 and ends at 79. It contains 3 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [73.0] and does not return any value..
pytorch_ao
public
public
0
0
_check_common
def _check_common(self,dot_prod_attention,args1=None,contains=True,atol=1e-5,has_fuse_pattern=True,has_dropout=False,check_train=True,override_check_equal=False,dtype=torch.float,rtol=1.3e-6,):if args1 is None:tensor_shape = (4, 2, 16, 32)args1 = [torch.randn(tensor_shape, device=self.device, dtype=dtype),torch.randn(t...
19
63
11
413
0
81
149
81
null
[]
None
null
0
0
0
null
0
null
The function (_check_common) defined within the public class called public.The function start at line 81 and ends at 149. It contains 63 lines of code and it has a cyclomatic complexity of 19. It takes 11 parameters, represented as [81.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_qsdpa_rewriter
def _test_qsdpa_rewriter(self):import torchao.quantization.pt2e.quantizer.x86_inductor_quantizer as xiqfrom torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2efrom torchao.quantization.pt2e.quantizer.x86_inductor_quantizer import (X86InductorQuantizer,)# pattern is different for bs=1torch.manual_s...
3
47
1
324
0
161
209
161
null
[]
None
null
0
0
0
null
0
null
The function (_test_qsdpa_rewriter) defined within the public class called public.The function start at line 161 and ends at 209. It contains 47 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
__init__
def __init__(self, weight_group_size: Union[int, str] = "per_channel") -> None:super().__init__()if weight_group_size == "per_channel":weight_group_size = 8assert isinstance(weight_group_size, int)weight_quantizer = CodeBookQuantizer(n_bits=2,features=16,codebook_dim=2,)self.linear = QuantizedLinear(in_features=16,out_...
2
21
2
100
0
16
37
16
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 16 and ends at 37. It contains 21 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [16.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x: torch.Tensor) -> torch.Tensor:return self.linear(x)
1
2
2
22
0
39
40
39
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 39 and ends at 40. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [39.0] and does not return any value..
pytorch_ao
public
public
0
0
test_kmeans_codebook
def test_kmeans_codebook(self) -> None:model = SimpleTestNetwork()codebook_before = copy.deepcopy(model.linear.weight_quantizer.codebook)kmeans_codebook(model)assert not torch.allclose(codebook_before,model.linear.weight_quantizer.codebook,)
1
8
1
47
0
45
52
45
null
[]
None
null
0
0
0
null
0
null
The function (test_kmeans_codebook) defined within the public class called public.The function start at line 45 and ends at 52. 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
get_test_llama_model_data
def get_test_llama_model_data() -> Tuple[LlamaForCausalLM, torch.Tensor]:model = LlamaForCausalLM(test_config)input_ids = torch.randint(0, test_config.vocab_size, (1, 10))return model, input_ids
1
4
0
41
2
18
21
18
null
['input_ids', 'model']
None
null
0
0
0
null
0
null
The function (get_test_llama_model_data) defined within the public class called public.The function start at line 18 and ends at 21. 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_data_getter
def test_data_getter(self) -> None:model, data = get_test_llama_model_data()data_getter = LLMPTQDataGetter(model, data, 1)for name, module in model.named_modules():if isinstance(module, torch.nn.Linear):data = data_getter.pop(model, name)
3
6
1
57
0
26
31
26
null
[]
None
null
0
0
0
null
0
null
The function (test_data_getter) defined within the public class called public.The function start at line 26 and ends at 31. It contains 6 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
__init__
def __init__(self) -> None:super().__init__()self.embedding = nn.Embedding(10, 64)
1
3
1
26
0
13
15
13
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 13 and ends at 15. 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
forward
def forward(self, x: torch.Tensor) -> torch.Tensor:return self.embedding(x)
1
2
2
22
0
17
18
17
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 17 and ends at 18. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [17.0] and does not return any value..
pytorch_ao
public
public
0
0
test_embedding_swap
def test_embedding_swap(self) -> None:model = SimpleEmbeddingTestNetwork()recipe = QuantizationRecipe()recipe.embedding_bits = 4recipe.embedding_quantization = Truemodel = quantize_module_swap(model, recipe)x = torch.randint(0, 10, (10, 64))model(x)assert model.embedding.weight_quantizer.num_bits == 4assert model.embed...
1
10
1
75
0
22
31
22
null
[]
None
null
0
0
0
null
0
null
The function (test_embedding_swap) defined within the public class called public.The function start at line 22 and ends at 31. 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
get_test_llama_model_data
def get_test_llama_model_data() -> tuple[LlamaForCausalLM, torch.Tensor]:model = LlamaForCausalLM(test_config)input_ids = torch.randint(0, test_config.vocab_size, (1, 10))return model, input_ids
1
4
0
41
2
37
40
37
null
['input_ids', 'model']
None
null
0
0
0
null
0
null
The function (get_test_llama_model_data) defined within the public class called public.The function start at line 37 and ends at 40. 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_set_bit_widths_by_name
def test_set_bit_widths_by_name(self) -> None:model, _ = get_test_llama_model_data()replace_all_linear_with_quantized_linear(model, base_recipe)bit_width_dict = {}for name, module in model.named_modules():if isinstance(module, QuantizedLinear):bit_width_dict[name] = {"weight": 7, "activation": 9}set_bit_widths_by_name(...
5
15
1
120
0
44
61
44
null
[]
None
null
0
0
0
null
0
null
The function (test_set_bit_widths_by_name) defined within the public class called public.The function start at line 44 and ends at 61. It contains 15 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_quantized_linear_init
def test_quantized_linear_init(self) -> None:in_features = 16out_features = 8weight_bits = 8weight_group_size = "per_channel"activation_bits = 8activation_group_size = "per_token"input_quantization = Trueoutput_quantization = Falseweight_quantization = Trueactivation_quantization = Truedynamic_weights = Falserange_lear...
1
33
1
116
0
14
46
14
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_linear_init) defined within the public class called public.The function start at line 14 and ends at 46. It contains 33 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_quantized_linear
def test_quantized_linear(self) -> None:for (weight_group_size,activation_group_size,input_quantization,output_quantization,weight_quantization,dynamic_weights,) in product(["per_channel", "per_tensor", 4],["per_token", "per_tensor", 4],[True, False],[True, False],[True, False],[True, False],):for x in [torch.FloatTens...
4
42
1
196
0
48
89
48
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_linear) defined within the public class called public.The function start at line 48 and ends at 89. It contains 42 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_quantized_linear_passes_gradients
def test_quantized_linear_passes_gradients(self) -> None:for (weight_group_size,activation_group_size,input_quantization,output_quantization,weight_quantization,dynamic_weights,) in product(["per_channel", "per_tensor", 4],["per_token", "per_tensor", 4],[True, False],[True, False],[True, False],[True, False],):for x in...
4
46
1
235
0
91
136
91
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_linear_passes_gradients) defined within the public class called public.The function start at line 91 and ends at 136. It contains 46 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_quantized_linear_passes_gradients_to_weight_scale
def test_quantized_linear_passes_gradients_to_weight_scale(self) -> None:in_features = 16out_features = 8weight_bits = 8weight_group_size = "per_channel"activation_bits = 8activation_group_size = "per_token"input_quantization = Trueoutput_quantization = Falseweight_quantization = Trueactivation_quantization = Truescale...
1
40
1
183
0
138
177
138
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_linear_passes_gradients_to_weight_scale) defined within the public class called public.The function start at line 138 and ends at 177. It contains 40 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_quantized_linear_passes_gradients_to_activation_scale
def test_quantized_linear_passes_gradients_to_activation_scale(self) -> None:in_features = 16out_features = 8weight_bits = 8weight_group_size = "per_channel"activation_bits = 8activation_group_size = "per_tensor"input_quantization = Trueoutput_quantization = Falseweight_quantization = Falseactivation_quantization = Tru...
1
49
1
250
0
179
229
179
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_linear_passes_gradients_to_activation_scale) defined within the public class called public.The function start at line 179 and ends at 229. It contains 49 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_set_weight_scale_to_min_max_test_all_options
def test_set_weight_scale_to_min_max_test_all_options(self) -> None:for (x,weight_group_size,) in product([torch.FloatTensor(torch.randn(2, 16)),torch.FloatTensor(torch.randn(2, 2, 16)),],["per_channel", "per_tensor", 4],):x = x.requires_grad_(True)weight_quantizer = IntQuantizer(num_bits=4,group_size=weight_group_size...
2
32
1
153
0
231
262
231
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_scale_to_min_max_test_all_options) defined within the public class called public.The function start at line 231 and ends at 262. 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_set_weight_scale_to_min_max_test_correct
def test_set_weight_scale_to_min_max_test_correct(self) -> None:weight_group_size = "per_channel"weight_quantizer = IntQuantizer(num_bits=4,group_size=weight_group_size,dynamic=False,quantization_mode="symmetric",range_learning=True,)linear = QuantizedLinear(in_features=16,out_features=1,weight_quantizer=weight_quantiz...
1
28
1
170
0
264
294
264
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_scale_to_min_max_test_correct) defined within the public class called public.The function start at line 264 and ends at 294. It contains 28 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_quantize_dynamic
def test_quantize_dynamic(self) -> None:weight_quantizer = IntQuantizer(num_bits=4,group_size="per_channel",dynamic=False,quantization_mode="symmetric",range_learning=True,)linear = QuantizedLinear(in_features=32,out_features=64,weight_quantizer=weight_quantizer,activation_bits=8,activation_group_size="per_token",input...
1
23
1
125
0
296
320
296
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_dynamic) defined within the public class called public.The function start at line 296 and ends at 320. It contains 23 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_quantize_dynamic_vectorized
def test_quantize_dynamic_vectorized(self) -> None:weight_quantizer = IntQuantizer(num_bits=4,group_size="per_channel",dynamic=False,quantization_mode="symmetric",range_learning=True,)linear = QuantizedLinear(# noqain_features=32,out_features=64,weight_quantizer=weight_quantizer,activation_bits=8,activation_group_size=...
1
25
1
159
0
322
348
322
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_dynamic_vectorized) defined within the public class called public.The function start at line 322 and ends at 348. 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_quantized_embedding
def test_quantized_embedding(self) -> None:for weight_group_size in ["per_channel", "per_tensor", 4]:linear = QuantizedEmbedding(num_embeddings=16,embedding_dim=12,num_bits=4,group_size=weight_group_size,quantization_mode="symmetric",)x = torch.Tensor(torch.zeros(2, 16).to(torch.int32))x[0][0] = 1x[1][0] = 1linear.weig...
2
14
1
97
0
352
365
352
null
[]
None
null
0
0
0
null
0
null
The function (test_quantized_embedding) defined within the public class called public.The function start at line 352 and ends at 365. It contains 14 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_get_scale_param_size
def test_get_scale_param_size(self) -> None:x = torch.FloatTensor([0, 5, 10, 15])group_size = 4scale_param_size = IntQuantizer.get_scale_param_size(x, group_size)assert scale_param_size == torch.Size([1])x = torch.FloatTensor([0, 5, 10, 15])group_size = 2scale_param_size = IntQuantizer.get_scale_param_size(x, group_siz...
1
17
1
201
0
9
28
9
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_param_size) defined within the public class called public.The function start at line 9 and ends at 28. It contains 17 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_qmin_qmax
def test_get_qmin_qmax(self) -> None:qmin, qmax = IntQuantizer.get_qmin_qmax(4, signed=False)assert qmin == 0assert qmax == 15qmin, qmax = IntQuantizer.get_qmin_qmax(4, signed=True)assert qmin == -8assert qmax == 7
1
7
1
52
0
30
37
30
null
[]
None
null
0
0
0
null
0
null
The function (test_get_qmin_qmax) defined within the public class called public.The function start at line 30 and ends at 37. 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_get_scale_offset_asymmetric
def test_get_scale_offset_asymmetric(self) -> None:x = torch.FloatTensor([0, 5, 10, 15])group_size = 4quantization_mode = "asymmetric"q_min = 0q_max = 15scale, offset = IntQuantizer.get_scale_offset(x, group_size, quantization_mode, q_min, q_max)assert scale == 1assert offset == 0
1
11
1
61
0
39
49
39
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_offset_asymmetric) defined within the public class called public.The function start at line 39 and ends at 49. It contains 11 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_scale_offset_symmetric
def test_get_scale_offset_symmetric(self) -> None:x = torch.FloatTensor([-8, -5, -3, -1, 0, 1, 3, 5, 7])group_size = 9quantization_mode = "symmetric"q_min = -8q_max = 7scale, offset = IntQuantizer.get_scale_offset(x, group_size, quantization_mode, q_min, q_max)assert scale == 1assert offset is None
1
11
1
76
0
51
61
51
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_offset_symmetric) defined within the public class called public.The function start at line 51 and ends at 61. It contains 11 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_quantize_forward
def test_quantize_forward(self) -> None:x = torch.FloatTensor([0, 5, 10, 15])scale = torch.FloatTensor([1])offset = torch.FloatTensor([0])group_size = 4q_min = 0q_max = 15output = IntQuantizer.quantize_forward(x, scale, offset, q_min, q_max, group_size)torch.testing.assert_close(output, torch.FloatTensor([0, 5, 10, 15]...
1
11
1
93
0
63
74
63
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_forward) defined within the public class called public.The function start at line 63 and ends at 74. It contains 11 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_quantize_forward_asymmetric_clipping
def test_quantize_forward_asymmetric_clipping(self) -> None:x = torch.FloatTensor([0, 5, 10, 100])scale = torch.FloatTensor([1])offset = torch.FloatTensor([0])group_size = 4q_min = 0q_max = 15output = IntQuantizer.quantize_forward(x, scale, offset, q_min, q_max, group_size)torch.testing.assert_close(output, torch.Float...
1
11
1
93
0
76
87
76
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_forward_asymmetric_clipping) defined within the public class called public.The function start at line 76 and ends at 87. It contains 11 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_quantize_forward_symmetric
def test_quantize_forward_symmetric(self) -> None:x = torch.FloatTensor([0, 1, 2, 3])scale = torch.FloatTensor([1.0])group_size = 4q_min = -8q_max = 7output = IntQuantizer.quantize_forward(x, scale, offset=None, group_size=group_size, q_min=q_min, q_max=q_max)torch.testing.assert_close(output, torch.FloatTensor([0, 1, ...
1
10
1
94
0
89
99
89
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_forward_symmetric) defined within the public class called public.The function start at line 89 and ends at 99. 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_quantize_forward_symmetric_clipping
def test_quantize_forward_symmetric_clipping(self) -> None:x = torch.FloatTensor([0, 1, 2, 10])scale = torch.FloatTensor([1.0])group_size = 4q_min = -8q_max = 7output = IntQuantizer.quantize_forward(x, scale, offset=None, group_size=group_size, q_min=q_min, q_max=q_max)torch.testing.assert_close(output, torch.FloatTens...
1
10
1
94
0
101
111
101
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_forward_symmetric_clipping) defined within the public class called public.The function start at line 101 and ends at 111. 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_get_scale_offset_from_min_max
def test_get_scale_offset_from_min_max(self) -> None:x_min = torch.FloatTensor([-8])x_max = torch.FloatTensor([7])q_min = 0q_max = 15scale, offset = IntQuantizer.get_scale_offset_from_min_max(x_min, x_max, q_min, q_max)assert scale == 1assert offset == 8
1
10
1
58
0
113
122
113
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_offset_from_min_max) defined within the public class called public.The function start at line 113 and ends at 122. 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_get_scale_offset_from_min_max_tensorized
def test_get_scale_offset_from_min_max_tensorized(self) -> None:x_min = torch.FloatTensor([-8, 0])x_max = torch.FloatTensor([7, 15])q_min = 0q_max = 15scale, offset = IntQuantizer.get_scale_offset_from_min_max(x_min, x_max, q_min, q_max)assert torch.allclose(scale, torch.FloatTensor([1, 1]))assert torch.allclose(offset...
1
10
1
90
0
124
133
124
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_offset_from_min_max_tensorized) defined within the public class called public.The function start at line 124 and ends at 133. 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_get_scale_from_min_max
def test_get_scale_from_min_max(self) -> None:x_min = torch.FloatTensor([-8])x_max = torch.FloatTensor([7])q_min = -8q_max = 7scale = IntQuantizer.get_scale_from_min_max(x_min, x_max, q_min, q_max)assert scale == 1
1
7
1
53
0
135
142
135
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_from_min_max) defined within the public class called public.The function start at line 135 and ends at 142. 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_get_scale_from_min_max_vectorized
def test_get_scale_from_min_max_vectorized(self) -> None:x_min = torch.FloatTensor([-8, -16])x_max = torch.FloatTensor([7, 14])q_min = -8q_max = 7scale = IntQuantizer.get_scale_from_min_max(x_min, x_max, q_min, q_max)assert torch.allclose(scale, torch.FloatTensor([1, 2]))
1
7
1
72
0
144
151
144
null
[]
None
null
0
0
0
null
0
null
The function (test_get_scale_from_min_max_vectorized) defined within the public class called public.The function start at line 144 and ends at 151. 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_codebook_quantizer
def test_codebook_quantizer(self) -> None:pass
1
2
1
8
0
155
156
155
null
[]
None
null
0
0
0
null
0
null
The function (test_codebook_quantizer) defined within the public class called public.The function start at line 155 and ends at 156. 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_vector_quantizer
def test_vector_quantizer(self) -> None:pass
1
2
1
8
0
158
159
158
null
[]
None
null
0
0
0
null
0
null
The function (test_vector_quantizer) defined within the public class called public.The function start at line 158 and ends at 159. 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
__init__
def __init__(self, weight_group_size: Union[int, str] = "per_channel") -> None:super().__init__()weight_quantizer = IntQuantizer(num_bits=4,group_size=weight_group_size,dynamic=False,quantization_mode="symmetric",range_learning=False,)self.linear = QuantizedLinear(in_features=16,out_features=8,weight_quantizer=weight_q...
1
20
2
93
0
22
41
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 41. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [22.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x: torch.Tensor) -> torch.Tensor:return self.linear(x)
1
2
2
22
0
43
44
43
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 43 and ends at 44. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [43.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, weight_group_size: Union[int, str] = "per_channel") -> None:super().__init__()weight_quantizer = IntQuantizer(num_bits=4,group_size=weight_group_size,dynamic=False,quantization_mode="symmetric",range_learning=False,)self.linear = QuantizedLinear(in_features=16,out_features=8,weight_quantizer=weight_q...
1
22
2
101
0
48
69
48
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 48 and ends at 69. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [48.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x: torch.Tensor) -> torch.Tensor:return self.linear(x)
1
2
2
22
0
71
72
43
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 71 and ends at 72. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [43.0] and does not return any value..
pytorch_ao
public
public
0
0
test_set_weight_min_max
def test_set_weight_min_max(self) -> None:model = SimpleTestNetwork()set_weight_min_max(model)
1
3
1
16
0
76
79
76
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_min_max) defined within the public class called public.The function start at line 76 and ends at 79. 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_set_weight_min_max_grouped
def test_set_weight_min_max_grouped(self) -> None:model = SimpleTestNetwork(weight_group_size=8)set_weight_min_max(model)
1
3
1
19
0
81
84
81
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_min_max_grouped) defined within the public class called public.The function start at line 81 and ends at 84. 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_set_weight_mse
def test_set_weight_mse(self) -> None:model = SimpleTestNetwork()set_weight_mse(model, num_points=5)
1
3
1
20
0
88
90
88
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_mse) defined within the public class called public.The function start at line 88 and ends at 90. 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_set_weight_mse_grouped
def test_set_weight_mse_grouped(self) -> None:model = SimpleTestNetwork(weight_group_size=8)set_weight_mse(model, num_points=5)
1
3
1
23
0
92
94
92
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_mse_grouped) defined within the public class called public.The function start at line 92 and ends at 94. 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_set_weight_range_activation_loss
def test_set_weight_range_activation_loss(self) -> None:model = SimpleTestNetwork()test_data = torch.rand(2, 16)set_weight_range_activation_loss(model,test_data,batch_size=1,num_points=5,progressive=False,)
1
10
1
41
0
98
107
98
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_range_activation_loss) defined within the public class called public.The function start at line 98 and ends at 107. 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_set_weight_range_activation_loss_progressive
def test_set_weight_range_activation_loss_progressive(self) -> None:model = SimpleTestNetwork(weight_group_size=8)test_data = torch.rand(2, 16)set_weight_range_activation_loss(model,test_data,batch_size=1,num_points=5,progressive=True,)
1
10
1
44
0
109
118
109
null
[]
None
null
0
0
0
null
0
null
The function (test_set_weight_range_activation_loss_progressive) defined within the public class called public.The function start at line 109 and ends at 118. 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_static_activation_range_setting
def test_static_activation_range_setting(self) -> None:model = SimpleTestNetworkStaticActivation()test_data = torch.rand(2, 16)set_activation_min_max(model, test_data, batch_size=1)
1
4
1
32
0
122
126
122
null
[]
None
null
0
0
0
null
0
null
The function (test_static_activation_range_setting) defined within the public class called public.The function start at line 122 and ends at 126. 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_static_activation_range_setting_no_input
def test_static_activation_range_setting_no_input(self) -> None:model = SimpleTestNetworkStaticActivation()test_data = torch.rand(2, 16)set_activation_min_max(model, test_data, batch_size=1)
1
4
1
32
0
128
132
128
null
[]
None
null
0
0
0
null
0
null
The function (test_static_activation_range_setting_no_input) defined within the public class called public.The function start at line 128 and ends at 132. 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_quantize_per_group_scales
def test_quantize_per_group_scales(self) -> None:model = SimpleTestNetwork(weight_group_size=8)set_weight_min_max(model)assert model.linear.weight_quantizer.scale is not Nonescale_before = copy.deepcopy(model.linear.weight_quantizer.scale)quantize_per_group_scales(model, bit_width=4)assert model.linear.weight_quantizer...
1
8
1
79
0
136
144
136
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_per_group_scales) defined within the public class called public.The function start at line 136 and ends at 144. 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_quantize_per_group_scales_dont_change_per_channel
def test_quantize_per_group_scales_dont_change_per_channel(self) -> None:model = SimpleTestNetwork(weight_group_size="per_channel")set_weight_min_max(model)assert model.linear.weight_quantizer.scale is not Nonescale_before = copy.deepcopy(model.linear.weight_quantizer.scale)quantize_per_group_scales(model, bit_width=4)...
1
8
1
78
0
146
154
146
null
[]
None
null
0
0
0
null
0
null
The function (test_quantize_per_group_scales_dont_change_per_channel) defined within the public class called public.The function start at line 146 and ends at 154. 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
device_mesh_1d
def device_mesh_1d() -> DeviceMesh:"""Fixture for setting up and tearing down the distributed environmentfor the entire test module."""rank = int(os.environ["RANK"])world_size = int(os.environ["WORLD_SIZE"])if not dist.is_initialized():dist.init_process_group("nccl", rank=rank, world_size=world_size)device_mesh = init_...
2
10
0
83
3
58
74
58
null
['device_mesh', 'world_size', 'rank']
None
null
0
0
0
null
0
null
The function (device_mesh_1d) defined within the public class called public.The function start at line 58 and ends at 74. It contains 10 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_moe_training_fsdp.moe_module_filter_fn
def moe_module_filter_fn(mod: nn.Module, cur_fqn: str) -> bool:for target_fqn in target_fqns:if target_fqn in cur_fqn:return Truereturn False
3
5
2
29
0
165
169
165
null
[]
None
null
0
0
0
null
0
null
The function (test_moe_training_fsdp.moe_module_filter_fn) defined within the public class called public.The function start at line 165 and ends at 169. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [165.0] and does not return any value..
pytorch_ao
public
public
0
0
test_moe_training_fsdp
def test_moe_training_fsdp(target_fqns: list[str],compile: bool,recipe_config: dict,device_mesh_1d: DeviceMesh,):(recipe,group_alignment_size,min_out_sqnr,min_input_grad_sqnr,min_param_grad_sqnr,) = (recipe_config["recipe"],recipe_config["group_alignment_size"],recipe_config["min_out_sqnr"],recipe_config["min_input_gra...
8
84
4
490
16
104
226
104
null
['out', 'config', 'ref_x', 'out_loss', 'ref_loss', 'device', 'init_std', 'model', 'ref_model', 'x', 'ref_out', 'input_grad_sqnr', 'out_sqnr', 'labels', 'param_grad_sqnr', 'model_args']
None
null
0
0
0
null
0
null
The function (test_moe_training_fsdp) defined within the public class called public.The function start at line 104 and ends at 226. It contains 84 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [104.0] and does not return any value..
pytorch_ao
public
public
0
0
device_mesh_2d
def device_mesh_2d() -> DeviceMesh:"""Fixture for setting up and tearing down the distributed environmentfor the entire test module."""rank = int(os.environ["RANK"])world_size = int(os.environ["WORLD_SIZE"])if not dist.is_initialized():dist.init_process_group("nccl", rank=rank, world_size=world_size)device_mesh = init_...
2
14
0
90
3
78
99
78
null
['device_mesh', 'world_size', 'rank']
None
null
0
0
0
null
0
null
The function (device_mesh_2d) defined within the public class called public.The function start at line 78 and ends at 99. It contains 14 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_moe_training_fsdp_tp.moe_module_filter_fn
def moe_module_filter_fn(mod: nn.Module, cur_fqn: str) -> bool:for target_fqn in target_fqns:if target_fqn in cur_fqn:return Truereturn False
3
5
2
29
0
190
194
190
null
[]
None
null
0
0
0
null
0
null
The function (test_moe_training_fsdp_tp.moe_module_filter_fn) defined within the public class called public.The function start at line 190 and ends at 194. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [190.0] and does not return any value..
pytorch_ao
public
public
0
0
test_moe_training_fsdp_tp
def test_moe_training_fsdp_tp(target_fqns: list[str],compile: bool,recipe_config: dict,device_mesh_2d: DeviceMesh,):(recipe,group_alignment_size,min_out_sqnr,min_input_grad_sqnr,min_param_grad_sqnr,) = (recipe_config["recipe"],recipe_config["group_alignment_size"],recipe_config["min_out_sqnr"],recipe_config["min_input_...
8
107
4
648
17
129
278
129
null
['out', 'config', 'ref_x', 'out_loss', 'ref_loss', 'fsdp_config', 'device', 'init_std', 'model', 'ref_model', 'x', 'ref_out', 'input_grad_sqnr', 'out_sqnr', 'labels', 'param_grad_sqnr', 'model_args']
None
null
0
0
0
null
0
null
The function (test_moe_training_fsdp_tp) defined within the public class called public.The function start at line 129 and ends at 278. It contains 107 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [129.0] and does not return any value..
pytorch_ao
public
public
0
0
apply_moe_ep_tp
def apply_moe_ep_tp(model: nn.Module,tp_mesh: DeviceMesh | None,ep_mesh: DeviceMesh | None,ep_tp_mesh: DeviceMesh | None,):# Modified version of moe parallelization from https://github.com/pytorch/torchtitan/pull/1324/# that supports single MoE layer independent of a transformer.if tp_mesh is not None:moe_layer_plan = ...
4
38
4
180
3
281
329
281
null
['moe_layer_plan', 'experts_plan', 'experts_mesh']
None
null
0
0
0
null
0
null
The function (apply_moe_ep_tp) defined within the public class called public.The function start at line 281 and ends at 329. It contains 38 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [281.0] and does not return any value..
pytorch_ao
public
public
0
0
test_row_major_with_jagged_rowwise_scales
def test_row_major_with_jagged_rowwise_scales(round_scales_to_power_of_2: bool):# Tests case where rowwise scales are computed for multiple distinct subtensors,# with end boundary of each group is determine by their end column indexes (offsets).device = "cuda"m, k, n_groups = 256, 256, 4x = torch.randn(k, m * n_groups,...
1
20
1
137
3
49
75
49
null
['x', 'device', 'colwise_offs']
None
null
0
0
0
null
0
null
The function (test_row_major_with_jagged_rowwise_scales) defined within the public class called public.The function start at line 49 and ends at 75. It contains 20 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_row_major_with_jagged_rowwise_scales_transpose_method
def test_row_major_with_jagged_rowwise_scales_transpose_method(round_scales_to_power_of_2: bool,):# tests case where rowwise scales are computed for multiple distinct subtensors,# with end boundary of each group is determine by their end column indexes (offsets).device = "cuda"m, k, n_groups = 256, 256, 4grad_out = tor...
1
25
1
171
6
80
113
80
null
['grad_out', 'kernel_fp8_data', 'device', 'kernel_scales', 'grad_out_t', 'colwise_offs']
None
null
0
0
0
null
0
null
The function (test_row_major_with_jagged_rowwise_scales_transpose_method) defined within the public class called public.The function start at line 80 and ends at 113. 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_column_major_with_jagged_colwise_scales
def test_column_major_with_jagged_colwise_scales(round_scales_to_power_of_2: bool):# tests case where colwise scales are computed for multiple distinct subtensors,# with end boundary of each group is determine by their end row indexes (offsets).device = "cuda"m, k, n_groups = 256, 256, 4x = torch.randn(m * n_groups, k,...
1
20
1
148
3
118
141
118
null
['x', 'device', 'rowwise_offs']
None
null
0
0
0
null
0
null
The function (test_column_major_with_jagged_colwise_scales) defined within the public class called public.The function start at line 118 and ends at 141. It contains 20 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_fp8_rowwise_3d_transpose_rhs_atomic
def test_fp8_rowwise_3d_transpose_rhs_atomic(round_scales_to_power_of_2: bool):device = "cuda"experts, n, k = 8, 4 * 5120, 5120# Example expert weights as it comes into forward transposedtorch.manual_seed(0)x = torch.randn((experts, n, k), dtype=torch.bfloat16, device=device).transpose(-2, -1)# Compute reference with t...
1
24
1
194
3
146
176
146
null
['x', 'ref_scales', 'device']
None
null
0
0
0
null
0
null
The function (test_fp8_rowwise_3d_transpose_rhs_atomic) defined within the public class called public.The function start at line 146 and ends at 176. It contains 24 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_fp8_rowwise_3d_transpose_rhs_reduction
def test_fp8_rowwise_3d_transpose_rhs_reduction(round_scales_to_power_of_2: bool):device = "cuda"experts, n, k = 8, 4 * 5120, 5120# Example expert weights as it comes into forward transposedtorch.manual_seed(0)x = torch.randn((experts, n, k), dtype=torch.bfloat16, device=device).transpose(-2, -1)# Compute reference wit...
1
24
1
194
3
181
211
181
null
['x', 'ref_scales', 'device']
None
null
0
0
0
null
0
null
The function (test_fp8_rowwise_3d_transpose_rhs_reduction) defined within the public class called public.The function start at line 181 and ends at 211. It contains 24 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_triton_mx_block_rearrange_2d_M_groups
def test_triton_mx_block_rearrange_2d_M_groups(m: int,k: int,n_groups: int,):device = "cuda"block_size = 32input_data = torch.randn(m, k, device=device)e8m0_scales, _ = to_mx(input_data, elem_dtype=torch.float8_e4m3fn, block_size=block_size)input_group_offsets = generate_jagged_offs(n_groups, m, multiple_of=block_size,...
1
28
3
126
5
218
249
218
null
['device', 'block_size', 'input_group_offsets', 'triton_out_scales', 'input_data']
None
null
0
0
0
null
0
null
The function (test_triton_mx_block_rearrange_2d_M_groups) defined within the public class called public.The function start at line 218 and ends at 249. It contains 28 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [218.0] and does not return any value..
pytorch_ao
public
public
0
0
test_mxfp8_per_group_blocked_scales_3d
def test_mxfp8_per_group_blocked_scales_3d(e: int,n: int,k: int,):device = "cuda"block_size = 32weights = torch.randn(e, n, k // block_size, device=device)weight_scales, _ = to_mx(weights, elem_dtype=torch.float8_e4m3fn, block_size=block_size)# torch referenceref_out_scales = torch_to_blocked_per_group_3d(weight_scales...
1
16
3
85
5
254
273
254
null
['device', 'block_size', 'triton_out_scales', 'ref_out_scales', 'weights']
None
null
0
0
0
null
0
null
The function (test_mxfp8_per_group_blocked_scales_3d) defined within the public class called public.The function start at line 254 and ends at 273. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [254.0] and does not return any value..
pytorch_ao
public
public
0
0
test_triton_mx_block_rearrange_2d_K_groups
def test_triton_mx_block_rearrange_2d_K_groups(m: int,total_k: int,n_groups: int,):device = "cuda"block_size = 32input_data = torch.randn(m, total_k, device=device)e8m0_scales, _ = to_mx(input_data, elem_dtype=torch.float8_e4m3fn, block_size=block_size)# Generate group end offsets along total_K, then divide by block_si...
1
31
3
128
6
283
320
283
null
['scale_group_offsets', 'device', 'block_size', 'input_group_offsets', 'input_data', 'triton_out_scales']
None
null
0
0
0
null
0
null
The function (test_triton_mx_block_rearrange_2d_K_groups) defined within the public class called public.The function start at line 283 and ends at 320. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [283.0] and does not return any value..
pytorch_ao
public
public
0
0
test_cuda_mx_dim1_3d_numerics
def test_cuda_mx_dim1_3d_numerics(E, N, K, input_dtype, scaling_mode):from torchao.prototype import mxfp8_cudascaling_mode_str = ("floor" if scaling_mode == ScaleCalculationMode.FLOOR else "rceil")block_size = 32# Use disinct incrementing values from 0 to E*M*K-1 to make debugging easier.x = (torch.arange(0, E * N * K,...
2
24
5
196
5
332
369
332
null
['y_d1_ref', 'block_size', 's_d1_ref', 'x', 'scaling_mode_str']
None
null
0
0
0
null
0
null
The function (test_cuda_mx_dim1_3d_numerics) defined within the public class called public.The function start at line 332 and ends at 369. It contains 24 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [332.0] and does not return any value..
pytorch_ao
public
public
0
0
test_valid_scaled_grouped_mm_2d_3d
def test_valid_scaled_grouped_mm_2d_3d():out_dtype = torch.bfloat16device = "cuda"m, n, k, n_groups = 16, 32, 16, 4a = torch.randn(m * n_groups,k,device=device,requires_grad=True,dtype=torch.bfloat16,)b = torch.randn(n_groups,n,k,device=device,dtype=torch.bfloat16,)offs = torch.arange(m, n_groups * m + 1, m, device="cu...
1
41
0
243
10
46
96
46
null
['out', 'b_t', 'device', 'ref_b_t', 'ref_out', 'a', 'b', 'offs', 'ref_a', 'out_dtype']
None
null
0
0
0
null
0
null
The function (test_valid_scaled_grouped_mm_2d_3d) defined within the public class called public.The function start at line 46 and ends at 96. It contains 41 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_K_or_N_dim_not_multiple_of_16
def test_K_or_N_dim_not_multiple_of_16(m, n, k):# - Leading dim of A doesn't have to be divisible by 16, since it will be# divided up into groups based on offset anyway.# - Trailing dim of A must be divisible by 16.# - Leading dim of B (n_groups) doesn't need to be divisible by 16.# - Last 2 dims of B must be divisible...
3
31
3
174
7
103
143
103
null
['b_t', 'n_groups', 'device', 'a', 'b', 'offs', 'out_dtype']
None
null
0
0
0
null
0
null
The function (test_K_or_N_dim_not_multiple_of_16) defined within the public class called public.The function start at line 103 and ends at 143. It contains 31 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [103.0] and does not return any value..
pytorch_ao
public
public
0
0
compute_reference_forward
def compute_reference_forward(result: torch.Tensor,A: torch.Tensor,B_t: torch.Tensor,n_groups: int,out_dtype: torch.dtype,offs: torch.Tensor,):assert result.dtype == out_dtype# Use official rowwise recipe as reference to ensure implementation is correct.float8_config = Float8LinearConfig.from_recipe_name(Float8LinearRe...
3
66
6
425
15
146
225
146
null
['A_fp8', 'offs_cpu', 'float8_config', 'start', 'A_scaled', 'outputs', 'list1', 'ref_group_result1', 'B_t_scales', 'A_scales', 'B_t_scaled', 'list2', 'output_ref', 'B_t_fp8', 'ref_group_result2']
None
null
0
0
0
null
0
null
The function (compute_reference_forward) defined within the public class called public.The function start at line 146 and ends at 225. It contains 66 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [146.0] and does not return any value..
pytorch_ao
public
public
0
0
test_emulate_mxfp8_grouped_gemm_2d_3d
def test_emulate_mxfp8_grouped_gemm_2d_3d(M, K, N, num_experts):x = torch.randn(M, K, dtype=torch.bfloat16, device="cuda")w = torch.randn(num_experts, N, K, dtype=torch.bfloat16, device="cuda")offs = generate_jagged_offs(num_experts, M)x_ref, w_ref, offs_ref = x.clone(), w.clone(), offs.clone()# Quantize inputs to mxpf...
1
21
4
195
8
231
257
231
null
['out', 'block_size', 'ref_out', 'x', 'sqnr', 'offs', 'w', 'min_sqnr']
None
null
0
0
0
null
0
null
The function (test_emulate_mxfp8_grouped_gemm_2d_3d) defined within the public class called public.The function start at line 231 and ends at 257. It contains 21 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [231.0] and does not return any value..
pytorch_ao
public
public
0
0
test_emulate_mxfp8_grouped_gemm_2d_2d
def test_emulate_mxfp8_grouped_gemm_2d_2d(M, N, num_experts):# Simluate 2d-2d grouped gemm grad_weight = grad_output_t @ xblock_size = 32grad_out = torch.randn(M, N, dtype=torch.bfloat16, device="cuda")grad_out_t = grad_out.t().contiguous()x = torch.randn(M, N, dtype=torch.bfloat16, device="cuda")offs = generate_jagged...
1
36
3
218
9
264
305
264
null
['out', 'grad_out', 'block_size', 'ref_out', 'x', 'sqnr', 'offs', 'grad_out_t', 'min_sqnr']
None
null
0
0
0
null
0
null
The function (test_emulate_mxfp8_grouped_gemm_2d_2d) defined within the public class called public.The function start at line 264 and ends at 305. It contains 36 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [264.0] and does not return any value..
pytorch_ao
public
public
0
0
test_mxfp8_grouped_gemm_with_dq_fwd_bwd
def test_mxfp8_grouped_gemm_with_dq_fwd_bwd(M, K, N, num_experts):from torchao.prototype.moe_training.scaled_grouped_mm import (_MXFP8GroupedMM,)block_size = 32x = torch.randn(M, K, dtype=torch.bfloat16, device="cuda", requires_grad=True)w = torch.randn(num_experts,N,K,dtype=torch.bfloat16,device="cuda",)w_t = w.transp...
1
40
4
295
14
313
361
313
null
['out', 'min_input_grad_sqnr', 'out_loss', 'ref_loss', 'block_size', 'ref_out', 'x', 'sqnr', 'offs', 'w', 'labels', 'min_weight_grad_sqnr', 'min_sqnr', 'w_t']
None
null
0
0
0
null
0
null
The function (test_mxfp8_grouped_gemm_with_dq_fwd_bwd) defined within the public class called public.The function start at line 313 and ends at 361. It contains 40 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [313.0] and does not return any value..