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_triton_nvfp4_quantize_equivalence
def test_triton_nvfp4_quantize_equivalence(M, N, use_per_tensor_scale, dtype):"""Test that Triton and PyTorch NVFP4 quantization produce equivalent results."""torch.manual_seed(42)x = torch.randn(M, N, dtype=dtype, device="cuda")per_tensor_scale = Noneif use_per_tensor_scale:per_tensor_scale = per_tensor_amax_to_scale(...
2
37
4
205
10
366
411
366
null
['x_pt_dequant', 'triton_unpacked', 'x_triton_dequant', 'x', 'sqnr', 'nvfp4_pt', 'per_tensor_scale', 'nvfp4_triton', 'pt_unpacked', 'SQNR_THRESHOLD']
None
null
0
0
0
null
0
null
The function (test_triton_nvfp4_quantize_equivalence) defined within the public class called public.The function start at line 366 and ends at 411. It contains 37 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [366.0] and does not return any value..
pytorch_ao
public
public
0
0
test_nvfp4_matmul_with_amax
def test_nvfp4_matmul_with_amax(use_gelu: bool,mm_config: NVFP4MMConfig,compile: bool,bias: bool,inpt_dtype: torch.dtype,use_triton_kernel: bool,shapes: tuple,):# DYNAMIC mode requires SM100+, but WEIGHT_ONLY works on older GPUsif mm_config == NVFP4MMConfig.DYNAMIC and not is_sm_at_least_100():pytest.skip("CUDA capabil...
11
52
7
348
14
444
508
444
null
['C_nvfp4', 'act_quant_kwargs', 'B_nvfp4', 'B', 'a_scale', 'A_nvfp4', 'x', 'C_ref', 'sqnr', 'func', 'bias_tensor', 'A', 'b_scale', 'SQNR_THRESHOLD']
None
null
0
0
0
null
0
null
The function (test_nvfp4_matmul_with_amax) defined within the public class called public.The function start at line 444 and ends at 508. It contains 52 lines of code and it has a cyclomatic complexity of 11. It takes 7 parameters, represented as [444.0] and does not return any value..
pytorch_ao
public
public
0
0
test_nvfp4_to_copy
def test_nvfp4_to_copy():x = NVFP4Tensor.to_nvfp4(torch.randn((32, 128))).cuda()y = torch.ops.aten._to_copy(x, dtype=torch.bfloat16)assert torch.equal(x.qdata, y.qdata)assert torch.equal(x._scale_e4m3, y._scale_e4m3)assert x._per_tensor_scale is Noneassert y._per_tensor_scale is Noneassert x._act_per_tensor_scale is No...
1
14
0
133
2
515
528
515
null
['x', 'y']
None
null
0
0
0
null
0
null
The function (test_nvfp4_to_copy) defined within the public class called public.The function start at line 515 and ends at 528. 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_scale_shape_matches_qdata
def test_scale_shape_matches_qdata(transpose, use_triton_kernel, is_swizzled_scales, mk):if use_triton_kernel and not is_sm_at_least_100():pytest.skip("CUDA capability >= 10.0 required for nvfp4 triton kernel")if use_triton_kernel and not is_swizzled_scales:pytest.skip("triton kernel requires swizzled scales")M, K = mk...
8
34
4
189
9
547
589
547
null
['expected_padded_m', 'actual_padded_m', 'block_size', 'actual_padded_k', 'x', 'orig_k', 'x_hp', 'expected_padded_k', 'orig_m']
None
null
0
0
0
null
0
null
The function (test_scale_shape_matches_qdata) defined within the public class called public.The function start at line 547 and ends at 589. It contains 34 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [547.0] and does not return any value..
pytorch_ao
public
public
0
0
load_data
def load_data(file_path: str, device: str):loaded_tensors = load_file(file_path, device)with open(file_path, "rb") as f:import structheader_size = struct.unpack("<Q", f.read(8))[0]header_bytes = f.read(header_size)header = json.loads(header_bytes)metadata = header.get("__metadata__", {})return loaded_tensors, metadata
1
9
2
80
5
29
38
29
null
['header', 'header_size', 'loaded_tensors', 'header_bytes', 'metadata']
None
null
0
0
0
null
0
null
The function (load_data) defined within the public class called public.The function start at line 29 and ends at 38. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [29.0] and does not return any value..
pytorch_ao
public
public
0
0
test_safetensors
def test_safetensors(self, config, act_pre_scale=False):model = torch.nn.Sequential(torch.nn.Linear(128, 256, dtype=torch.bfloat16, device="cuda"))quantize_(model, config)if act_pre_scale:model[0].weight.act_pre_scale = torch.ones((1), dtype=torch.bfloat16, device="cuda")example_inputs = (torch.randn(2, 128, dtype=torc...
2
24
3
218
0
55
80
55
null
[]
None
null
0
0
0
null
0
null
The function (test_safetensors) defined within the public class called public.The function start at line 55 and ends at 80. It contains 24 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [55.0] and does not return any value..
pytorch_ao
public
public
0
0
test_not_metadata_torchao
def test_not_metadata_torchao(self, metadata):assert not is_metadata_torchao(metadata)
1
2
2
13
0
55
56
55
null
[]
None
null
0
0
0
null
0
null
The function (test_not_metadata_torchao) defined within the public class called public.The function start at line 55 and ends at 56. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [55.0] and does not return any value..
pytorch_ao
public
public
0
0
test_metadata_torchao
def test_metadata_torchao(self):config = Float8DynamicActivationFloat8WeightConfig(granularity=PerRow())model = torch.nn.Sequential(torch.nn.Linear(32, 256, dtype=torch.bfloat16, device="cuda"))quantize_(model, config)_, metadata = flatten_tensor_state_dict(model.state_dict())assert is_metadata_torchao(metadata)
1
8
1
67
0
58
65
58
null
[]
None
null
0
0
0
null
0
null
The function (test_metadata_torchao) defined within the public class called public.The function start at line 58 and ends at 65. 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
__init__
def __init__(self, m=64, n=32, k=64, bias=False):super().__init__()self.linear1 = torch.nn.Linear(m, n, bias=bias).to(torch.float)self.linear2 = torch.nn.Linear(n, k, bias=bias).to(torch.float)
1
4
5
78
0
31
34
31
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 31 and ends at 34. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [31.0] and does not return any value..
pytorch_ao
public
public
0
0
example_inputs
def example_inputs(self, batch_size=1, dtype=torch.float, device="cpu"):return (torch.randn(batch_size, self.linear1.in_features, dtype=dtype, device=device),)
1
6
4
43
0
36
41
36
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 36 and ends at 41. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [36.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):x = self.linear1(x)x = self.linear2(x)return x
1
4
2
25
0
43
46
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 46. It contains 4 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_8da4w_cpu
def test_8da4w_cpu(self, dtype, x_dim, bias, bs, sym_quant_a):if sym_quant_a and not torch_version_at_least("2.8.0"):# not supported until PT 2.8returndevice = "cpu"m = ToyLinearModel(bias=bias).eval().to(dtype).to(device)m2 = copy.deepcopy(m)example_inputs = m.example_inputs(batch_size=bs, dtype=dtype, device=device)i...
8
49
6
363
0
60
114
60
null
[]
None
null
0
0
0
null
0
null
The function (test_8da4w_cpu) defined within the public class called public.The function start at line 60 and ends at 114. It contains 49 lines of code and it has a cyclomatic complexity of 8. It takes 6 parameters, represented as [60.0] and does not return any value..
pytorch_ao
public
public
0
0
test_8da4w_concat_linear_cpu.__init__
def __init__(self, bias):super().__init__()self.linear1 = torch.nn.Linear(K, N, bias=bias)self.linear2 = torch.nn.Linear(K, N, bias=bias)self.linear3 = torch.nn.Linear(K, N, bias=bias)
1
5
2
68
0
127
131
127
null
[]
None
null
0
0
0
null
0
null
The function (test_8da4w_concat_linear_cpu.__init__) defined within the public class called public.The function start at line 127 and ends at 131. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [127.0] and does not return any value..
pytorch_ao
public
public
0
0
test_8da4w_concat_linear_cpu.forward
def forward(self, x):a = self.linear1(x)b = self.linear2(x)c = self.linear3(x)return a + b + c
1
5
2
37
0
133
137
133
null
[]
None
null
0
0
0
null
0
null
The function (test_8da4w_concat_linear_cpu.forward) defined within the public class called public.The function start at line 133 and ends at 137. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [133.0] and does not return any value..
pytorch_ao
public
public
0
0
test_8da4w_concat_linear_cpu
def test_8da4w_concat_linear_cpu(self, x_dim, bias):N, K = 64, 128class Mod(torch.nn.Module):def __init__(self, bias):super().__init__()self.linear1 = torch.nn.Linear(K, N, bias=bias)self.linear2 = torch.nn.Linear(K, N, bias=bias)self.linear3 = torch.nn.Linear(K, N, bias=bias)def forward(self, x):a = self.linear1(x)b =...
1
40
3
267
0
123
186
123
null
[]
None
null
0
0
0
null
0
null
The function (test_8da4w_concat_linear_cpu) defined within the public class called public.The function start at line 123 and ends at 186. It contains 40 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [123.0] and does not return any value..
pytorch_ao
public
public
0
0
test_gptq_quantizer_int4_weight_only
def test_gptq_quantizer_int4_weight_only(self):from torchao._models._eval import (LMEvalInputRecorder,TransformerEvalWrapper,)from torchao.quantization.GPTQ import Int4WeightOnlyGPTQQuantizerprecision = torch.bfloat16device = "cuda"checkpoint_path = Path("../../checkpoints/meta-llama/Llama-2-7b-chat-hf/model.pth")model...
1
69
1
312
0
28
103
28
null
[]
None
null
0
0
0
null
0
null
The function (test_gptq_quantizer_int4_weight_only) defined within the public class called public.The function start at line 28 and ends at 103. It contains 69 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_multitensor_add_tensors
def test_multitensor_add_tensors(self):from torchao.quantization.GPTQ import MultiTensortensor1 = torch.randn(3, 3)tensor2 = torch.randn(3, 3)mt = MultiTensor(tensor1)mt.add_tensors(tensor2)self.assertEqual(mt.count, 2)self.assertTrue(torch.equal(mt.values[0], tensor1))self.assertTrue(torch.equal(mt.values[1], tensor2)...
1
9
1
91
0
108
117
108
null
[]
None
null
0
0
0
null
0
null
The function (test_multitensor_add_tensors) defined within the public class called public.The function start at line 108 and ends at 117. 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_multitensor_pad_unpad
def test_multitensor_pad_unpad(self):from torchao.quantization.GPTQ import MultiTensortensor1 = torch.randn(3, 3)mt = MultiTensor(tensor1)mt.pad_to_length(3)self.assertEqual(mt.count, 3)mt.unpad()self.assertEqual(mt.count, 1)
1
8
1
60
0
120
128
120
null
[]
None
null
0
0
0
null
0
null
The function (test_multitensor_pad_unpad) defined within the public class called public.The function start at line 120 and ends at 128. 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_multitensor_inplace_operation
def test_multitensor_inplace_operation(self):from torchao.quantization.GPTQ import MultiTensortensor1 = torch.ones(3, 3)mt = MultiTensor(tensor1)mt += 1# In-place additionself.assertTrue(torch.equal(mt.values[0], torch.full((3, 3), 2)))
1
6
1
61
0
131
137
131
null
[]
None
null
0
0
0
null
0
null
The function (test_multitensor_inplace_operation) defined within the public class called public.The function start at line 131 and ends at 137. 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_multitensor_input_recorder
def test_multitensor_input_recorder(self):from torchao.quantization.GPTQ import MultiTensor, MultiTensorInputRecorderinput_recorder = MultiTensorInputRecorder()in1 = ([1], torch.randn(3, 3), (1, "dog", torch.randn(3, 3)), torch.float)in2 = ([1], torch.randn(3, 3), (1, "dog", torch.randn(3, 3)), torch.float)input_record...
1
15
1
206
0
142
160
142
null
[]
None
null
0
0
0
null
0
null
The function (test_multitensor_input_recorder) defined within the public class called public.The function start at line 142 and ends at 160. 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_gptq_with_input_recorder
def test_gptq_with_input_recorder(self):from torchao.quantization.GPTQ import (Int4WeightOnlyGPTQQuantizer,MultiTensorInputRecorder,)torch.set_default_dtype(torch.bfloat16)config = ModelArgs(n_layer=2)with torch.device("cuda"):model = Transformer(config)model.setup_caches(max_batch_size=2, max_seq_length=100)idx = torc...
2
29
1
225
0
163
202
163
null
[]
None
null
0
0
0
null
0
null
The function (test_gptq_with_input_recorder) defined within the public class called public.The function start at line 163 and ends at 202. 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_accuracy
def test_accuracy(self, layout, weight_dtype, weight_mapping_type, weight_granularity):"""Checks the accuracy of packed layouts"""if (weight_dtype == torch.int1and weight_mapping_type == MappingType.SYMMETRIC_NO_CLIPPING_ERR):returnm = 3n = 1071k = 2048activations = torch.randn(m, k)model = torch.nn.Sequential(*[torch....
3
45
5
225
0
71
125
71
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 71 and ends at 125. It contains 45 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [71.0] and does not return any value..
pytorch_ao
public
public
0
0
test_accuracy_kleidiai
def test_accuracy_kleidiai(self):n = 1071k = 2048model = torch.nn.Sequential(*[torch.nn.Linear(k, k, bias=False), torch.nn.Linear(k, n, bias=True)])weight_dtype = torch.int4weight_granularity = PerGroup(128)weight_mapping_type = MappingType.SYMMETRIC# KleidiAI kernels round scales to bf16 internallymodel = model.to(tor...
2
45
1
249
0
127
179
127
null
[]
None
null
0
0
0
null
0
null
The function (test_accuracy_kleidiai) defined within the public class called public.The function start at line 127 and ends at 179. It contains 45 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_accuracy_aten
def test_accuracy_aten(self):m = 3n = 1024k = 2048activations = torch.randn(m, k)model = torch.nn.Sequential(*[torch.nn.Linear(k, k, bias=False), torch.nn.Linear(k, n, bias=True)])weight_dtype = torch.int4weight_granularity = PerGroup(128)weight_mapping_type = MappingType.SYMMETRIC# We set round_weight_scale_to_bf16 to...
1
41
1
221
0
181
228
181
null
[]
None
null
0
0
0
null
0
null
The function (test_accuracy_aten) defined within the public class called public.The function start at line 181 and ends at 228. 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
_assert_close
def _assert_close(self, result, expected_result, mse_tol=1e-5, atol=5e-2, rtol=5e-5):mse_loss = torch.nn.functional.mse_loss(result, expected_result)self.assertTrue(mse_loss <= mse_tol,f"Got mse_loss={mse_loss}, above mse tolerance {mse_tol}",)n_rand_idxs = 5rand_idxs = torch.randint(0, result.numel(), (n_rand_idxs,))s...
1
14
6
100
0
230
244
230
null
[]
None
null
0
0
0
null
0
null
The function (_assert_close) defined within the public class called public.The function start at line 230 and ends at 244. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [230.0] and does not return any value..
pytorch_ao
public
public
0
0
_reference_layout
def _reference_layout(self):return QDQLayout()
1
2
1
9
0
246
247
246
null
[]
None
null
0
0
0
null
0
null
The function (_reference_layout) defined within the public class called public.The function start at line 246 and ends at 247. 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_export_compile_aoti_PackedLinearInt8DynamicActivationIntxWeightLayout
def test_export_compile_aoti_PackedLinearInt8DynamicActivationIntxWeightLayout(self,):"""Checks that models quantized with PackedLinearInt8DynamicActivationIntxWeightLayout() work withtorch.export.export, torch.compile, and AOTI."""m = 3k0 = 512k1 = 256k2 = 128k3 = 1024weight_dtype = torch.int4weight_granularity = PerA...
1
45
1
285
0
249
304
249
null
[]
None
null
0
0
0
null
0
null
The function (test_export_compile_aoti_PackedLinearInt8DynamicActivationIntxWeightLayout) defined within the public class called public.The function start at line 249 and ends at 304. It contains 45 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any ...
pytorch_ao
public
public
0
0
test_export_dynamic_shape_PackedLinearInt8DynamicActivationIntxWeightLayout
def test_export_dynamic_shape_PackedLinearInt8DynamicActivationIntxWeightLayout(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.Linea...
1
43
1
244
0
306
352
306
null
[]
None
null
0
0
0
null
0
null
The function (test_export_dynamic_shape_PackedLinearInt8DynamicActivationIntxWeightLayout) defined within the public class called public.The function start at line 306 and ends at 352. It contains 43 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any...
pytorch_ao
public
public
0
0
test_export_QDQLayout
def test_export_QDQLayout(self):"""Checks that models quantized with TestQDQLayout() export as expected"""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.in...
3
34
1
191
0
354
394
354
null
[]
None
null
0
0
0
null
0
null
The function (test_export_QDQLayout) defined within the public class called public.The function start at line 354 and ends at 394. It contains 34 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_serialization
def test_serialization(self, layout):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),layout=la...
1
25
2
164
0
403
431
403
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 403 and ends at 431. It contains 25 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [403.0] and does not return any value..
pytorch_ao
public
public
0
0
test_identical_to_Int8DynamicActivationInt4WeightConfig
def test_identical_to_Int8DynamicActivationInt4WeightConfig(self, group_size, mapping_type, act_mapping_type):"""Checks that Int8DynamicActivationIntxWeightConfig with weight_dtype=torch.int4 is identical to Int8DynamicActivationInt4WeightConfig"""k0 = 512k1 = 256layers = [torch.nn.Linear(k0, k1),]model = torch.nn.Sequ...
1
33
4
159
0
444
481
444
null
[]
None
null
0
0
0
null
0
null
The function (test_identical_to_Int8DynamicActivationInt4WeightConfig) defined within the public class called public.The function start at line 444 and ends at 481. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [444.0] and does not return any value..
pytorch_ao
public
public
0
0
test_identical_to_IntXQuantizationAwareTrainingConfig
def test_identical_to_IntXQuantizationAwareTrainingConfig(self,weight_dtype,group_size,mapping_type,act_mapping_type,scale_dtype,model_dtype,):# TODO: the QAT logic for asymmetric mapping is very different from PTQ, so we don't test that case here# Unify the two?if mapping_type == MappingType.ASYMMETRIC:returnassert ma...
4
62
7
263
0
502
573
502
null
[]
None
null
0
0
0
null
0
null
The function (test_identical_to_IntXQuantizationAwareTrainingConfig) defined within the public class called public.The function start at line 502 and ends at 573. It contains 62 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [502.0] and does not return any value..
pytorch_ao
public
public
0
0
test_identical_to_Int8DynActInt4WeightQATQuantizer
def test_identical_to_Int8DynActInt4WeightQATQuantizer(self, group_size, 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)qat_quantizer = Int8DynActInt4Weig...
1
39
4
220
0
584
629
584
null
[]
None
null
0
0
0
null
0
null
The function (test_identical_to_Int8DynActInt4WeightQATQuantizer) defined within the public class called public.The function start at line 584 and ends at 629. It contains 39 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [584.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
228
0
631
676
631
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 631 and ends at 676. 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):super().setUp()torch.manual_seed(0)self.input = torch.randn((64, 32, 8192), dtype=torch.float16, device="cuda")self.model = (nn.Sequential(nn.Linear(8192, 21504),nn.Linear(21504, 8192),nn.ReLU(),nn.Linear(8192, 21504),nn.Linear(21504, 8192),).half().cuda())
1
15
1
105
0
31
46
31
null
[]
None
null
0
0
0
null
0
null
The function (setUp) defined within the public class called public.The function start at line 31 and ends at 46. 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_marlin_qqq
def test_marlin_qqq(self):output_ref = self.model(self.input)for group_size in [-1, 128]:modelq = copy.deepcopy(self.model)quantize_(modelq,Int8DynamicActivationInt4WeightConfig(group_size=group_size,mapping_type=MappingType.SYMMETRIC,act_mapping_type=MappingType.SYMMETRIC,layout=MarlinQQQLayout(),),)output = modelq(se...
2
17
1
93
0
50
67
50
null
[]
None
null
0
0
0
null
0
null
The function (test_marlin_qqq) defined within the public class called public.The function start at line 50 and ends at 67. It contains 17 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_marlin_qqq_compile
def test_marlin_qqq_compile(self):model_copy = copy.deepcopy(self.model)model_copy.forward = torch.compile(model_copy.forward, fullgraph=True)output_ref = model_copy(self.input)for group_size in [-1, 128]:modelq = copy.deepcopy(self.model)quantize_(modelq,Int8DynamicActivationInt4WeightConfig(group_size=group_size,mapp...
2
20
1
133
0
71
92
71
null
[]
None
null
0
0
0
null
0
null
The function (test_marlin_qqq_compile) defined within the public class called public.The function start at line 71 and ends at 92. It contains 20 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_pack_unpack_equivalence
def test_pack_unpack_equivalence(self):num_bits = 4shape = (11008, 4096)w = torch.rand(shape, dtype=torch.float16, device="cuda")for group_size in [-1, 128]:# Quantize weightsq_w, s_group, s_channel, _ = _choose_qparams_and_quantize_affine_qqq(w, num_bits, group_size)q_w = q_w.t()s_group = s_group.t()s_channel = s_chan...
2
31
1
160
0
95
132
95
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 95 and ends at 132. 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_impl_moe_quant
def _test_impl_moe_quant(self,config,num_tokens=1,model_params=None,base_class=AffineQuantizedTensor,tensor_impl_class=None,dtype=torch.bfloat16,device="cuda",fullgraph=False,):"""Tests moe quant for techniques using fake extra dim"""if model_params is None:model_params = self.DEFAULT_PARAMSinput_shape = (num_tokens, m...
9
50
9
340
0
49
110
49
null
[]
None
null
0
0
0
null
0
null
The function (_test_impl_moe_quant) defined within the public class called public.The function start at line 49 and ends at 110. It contains 50 lines of code and it has a cyclomatic complexity of 9. It takes 9 parameters, represented as [49.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4wo_fake_dim
def test_int4wo_fake_dim(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")config = MoEQuantConfig(Int4WeightOnlyConfig(version=1),use_fake_extra_dim_tensor=UseFakeExtraDimTensor.TRUE,)tensor_impl_class = TensorCoreTiledAQTTensorImplself._test_impl_moe_quant(config=...
2
14
4
69
0
118
133
118
null
[]
None
null
0
0
0
null
0
null
The function (test_int4wo_fake_dim) defined within the public class called public.The function start at line 118 and ends at 133. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [118.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int4wo_base
def test_int4wo_base(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")if not is_sm_at_least_90():self.skipTest("Requires CUDA capability >= 9.0")config = MoEQuantConfig(Int4WeightOnlyConfig(version=1))tensor_impl_class = TensorCoreTiledAQTTensorImplself._test_impl_...
3
13
4
74
0
141
155
141
null
[]
None
null
0
0
0
null
0
null
The function (test_int4wo_base) defined within the public class called public.The function start at line 141 and ends at 155. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [141.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8wo_fake_dim
def test_int8wo_fake_dim(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")config = MoEQuantConfig(Int8WeightOnlyConfig(), use_fake_extra_dim_tensor=UseFakeExtraDimTensor.TRUE)tensor_impl_class = PlainAQTTensorImplself._test_impl_moe_quant(config=config,num_tokens=n...
2
13
4
65
0
163
177
163
null
[]
None
null
0
0
0
null
0
null
The function (test_int8wo_fake_dim) defined within the public class called public.The function start at line 163 and ends at 177. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [163.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8wo_base
def test_int8wo_base(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")config = MoEQuantConfig(Int8WeightOnlyConfig())tensor_impl_class = PlainAQTTensorImplself._test_impl_moe_quant(config=config,num_tokens=num_tokens,tensor_impl_class=tensor_impl_class,fullgraph=fu...
2
11
4
59
0
185
197
185
null
[]
None
null
0
0
0
null
0
null
The function (test_int8wo_base) defined within the public class called public.The function start at line 185 and ends at 197. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [185.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8wo_base_cpu
def test_int8wo_base_cpu(self, name, num_tokens, fullgraph):config = MoEQuantConfig(Int8WeightOnlyConfig())tensor_impl_class = PlainAQTTensorImplself._test_impl_moe_quant(config=config,num_tokens=num_tokens,tensor_impl_class=tensor_impl_class,fullgraph=fullgraph,device="cpu",)
1
10
4
47
0
205
215
205
null
[]
None
null
0
0
0
null
0
null
The function (test_int8wo_base_cpu) defined within the public class called public.The function start at line 205 and ends at 215. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [205.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8dq_fake_dim
def test_int8dq_fake_dim(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")config = MoEQuantConfig(Int8DynamicActivationInt8WeightConfig(),use_fake_extra_dim_tensor=UseFakeExtraDimTensor.TRUE,)base_class = LinearActivationQuantizedTensorself._test_impl_moe_quant(mod...
2
15
4
78
0
222
238
222
null
[]
None
null
0
0
0
null
0
null
The function (test_int8dq_fake_dim) defined within the public class called public.The function start at line 222 and ends at 238. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [222.0] and does not return any value..
pytorch_ao
public
public
0
0
test_int8dq_base
def test_int8dq_base(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")config = MoEQuantConfig(Int8DynamicActivationInt8WeightConfig())base_class = LinearActivationQuantizedTensorself._test_impl_moe_quant(model_params=(512, 256, 2, 2),config=config,num_tokens=num_to...
2
12
4
71
0
245
258
245
null
[]
None
null
0
0
0
null
0
null
The function (test_int8dq_base) defined within the public class called public.The function start at line 245 and ends at 258. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [245.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8wo_fake_dim
def test_fp8wo_fake_dim(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")if not is_sm_at_least_90():self.skipTest("Requires CUDA capability >= 9.0")config = MoEQuantConfig(Float8WeightOnlyConfig(),use_fake_extra_dim_tensor=UseFakeExtraDimTensor.TRUE,)tensor_impl_cl...
3
16
4
78
0
266
283
266
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8wo_fake_dim) defined within the public class called public.The function start at line 266 and ends at 283. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [266.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8wo_base
def test_fp8wo_base(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")if not is_sm_at_least_90():self.skipTest("Requires CUDA capability >= 9.0")config = MoEQuantConfig(Float8WeightOnlyConfig())tensor_impl_class = Float8AQTTensorImplself._test_impl_moe_quant(config=...
3
13
4
71
0
291
305
291
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8wo_base) defined within the public class called public.The function start at line 291 and ends at 305. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [291.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8dq_fake_dim
def test_fp8dq_fake_dim(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")if not is_sm_at_least_90():self.skipTest("Requires CUDA capability >= 9.0")config = MoEQuantConfig(Float8DynamicActivationFloat8WeightConfig(),use_fake_extra_dim_tensor=UseFakeExtraDimTensor.T...
3
16
4
78
0
313
330
313
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8dq_fake_dim) defined within the public class called public.The function start at line 313 and ends at 330. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [313.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fp8dq_base
def test_fp8dq_base(self, name, num_tokens, fullgraph):if not torch.cuda.is_available():self.skipTest("Need CUDA available")if not is_sm_at_least_90():self.skipTest("Requires CUDA capability >= 9.0")config = MoEQuantConfig(Float8DynamicActivationFloat8WeightConfig())base_class = LinearActivationQuantizedTensorself._tes...
3
13
4
71
0
338
352
338
null
[]
None
null
0
0
0
null
0
null
The function (test_fp8dq_base) defined within the public class called public.The function start at line 338 and ends at 352. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [338.0] and does not return any value..
pytorch_ao
public
public
0
0
_test_obs_helper
def _test_obs_helper(self, obs1, obs2):example_inputs = [torch.randn(10, 2048),torch.randn(10, 2048),torch.randn(10, 2048),]for example_input in example_inputs:obs1(example_input)obs2(example_input)scale1, zero_point1 = obs1.calculate_qparams()scale2, zero_point2 = obs2.calculate_qparams()self.assertTrue(torch.allclose...
2
13
3
97
0
28
41
28
null
[]
None
null
0
0
0
null
0
null
The function (_test_obs_helper) defined within the public class called public.The function start at line 28 and ends at 41. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [28.0] and does not return any value..
pytorch_ao
public
public
0
0
test_min_max_per_tensor_affine
def test_min_max_per_tensor_affine(self):obs = AffineQuantizedMinMaxObserver(MappingType.ASYMMETRIC,torch.uint8,granularity=PerTensor(),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,)ref_obs = MinMaxObserver(dtype=torch.uint8, qscheme=torch.per_tensor_affine)self._test_obs_helper...
1
11
1
73
0
43
53
43
null
[]
None
null
0
0
0
null
0
null
The function (test_min_max_per_tensor_affine) defined within the public class called public.The function start at line 43 and ends at 53. 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_min_max_per_channel_affine
def test_min_max_per_channel_affine(self):obs = AffineQuantizedMinMaxObserver(MappingType.ASYMMETRIC,torch.uint8,granularity=PerAxis(axis=0),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,)ref_obs = PerChannelMinMaxObserver(dtype=torch.uint8, qscheme=torch.per_channel_affine)self....
1
13
1
76
0
55
67
55
null
[]
None
null
0
0
0
null
0
null
The function (test_min_max_per_channel_affine) defined within the public class called public.The function start at line 55 and ends at 67. 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_block_size_calc_success
def test_block_size_calc_success(self):obs = AffineQuantizedMinMaxObserver(MappingType.SYMMETRIC,torch.float8_e4m3fn,granularity=PerTensor(),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,zero_point_domain=ZeroPointDomain.NONE,)example_inputs = [torch.randn(10, 2048),torch.randn(9...
3
30
1
165
0
69
101
69
null
[]
None
null
0
0
0
null
0
null
The function (test_block_size_calc_success) defined within the public class called public.The function start at line 69 and ends at 101. It contains 30 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_block_size_row_errors
def test_block_size_row_errors(self):obs = AffineQuantizedMinMaxObserver(MappingType.SYMMETRIC,torch.float8_e4m3fn,granularity=PerAxis(0),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,zero_point_domain=ZeroPointDomain.NONE,)example_inputs = [torch.randn(10, 2048),torch.randn(9, 2...
3
37
1
211
0
103
140
103
null
[]
None
null
0
0
0
null
0
null
The function (test_block_size_row_errors) defined within the public class called public.The function start at line 103 and ends at 140. It contains 37 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_mse_observer
def test_mse_observer(self):obs = AffineQuantizedMSEObserver(MappingType.SYMMETRIC,torch.int8,granularity=PerAxis(0),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,zero_point_domain=ZeroPointDomain.NONE,steps=100,run_once=True,)example_input = torch.randn(10, 2048)obs(example_inpu...
1
31
1
192
0
142
174
142
null
[]
None
null
0
0
0
null
0
null
The function (test_mse_observer) defined within the public class called public.The function start at line 142 and ends at 174. 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_fixed_qparams_observer
def test_fixed_qparams_observer(self):obs = AffineQuantizedFixedQParamObserver(MappingType.SYMMETRIC,torch.float8_e4m3fn,granularity=PerAxis(0),eps=torch.finfo(torch.float32).eps,scale_dtype=torch.float,zero_point_dtype=torch.int,zero_point_domain=ZeroPointDomain.NONE,)example_input = torch.randn(10, 2048)obs(example_i...
1
15
1
108
0
176
190
176
null
[]
None
null
0
0
0
null
0
null
The function (test_fixed_qparams_observer) defined within the public class called public.The function start at line 176 and ends at 190. 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_linear_observer_tensor
def test_linear_observer_tensor(self, observe_weight: bool):# Create a simple linear layerin_features, out_features = 10, 5linear = nn.Linear(in_features, out_features)# Create observersinput_observer = AffineQuantizedMinMaxObserver(MappingType.SYMMETRIC,torch.float8_e4m3fn,granularity=PerTensor(),eps=torch.finfo(torch...
5
55
2
353
0
195
265
195
null
[]
None
null
0
0
0
null
0
null
The function (test_linear_observer_tensor) defined within the public class called public.The function start at line 195 and ends at 265. It contains 55 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [195.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.linear = torch.nn.Linear(256, 256, bias=False).to(torch.float)
1
3
1
37
0
110
112
110
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 110 and ends at 112. 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
example_inputs
def example_inputs(self):return (torch.randn(1, 256).to(torch.float),)
1
2
1
24
0
114
115
114
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 114 and ends at 115. 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
forward
def forward(self, x):return self.linear(x)
1
2
2
14
0
117
118
117
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 117 and ends at 118. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [117.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.linear1 = torch.nn.Linear(512, 256, bias=False).to(torch.float)self.sub = Sub()self.linear2 = torch.nn.Linear(256, 512, bias=False).to(torch.float)
1
5
1
69
0
122
126
122
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 122 and ends at 126. 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
example_inputs
def example_inputs(self, device: torch.device = None):return (torch.randn((1, 512), device=device).to(torch.float),)
1
2
2
38
0
128
129
128
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 128 and ends at 129. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [128.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_all_weight_scales
def _get_all_weight_scales(self) -> List[torch.Tensor]:return [self.linear1.weight_fake_quantizer.scale,self.sub.linear.weight_fake_quantizer.scale,self.linear2.weight_fake_quantizer.scale,]
1
6
1
41
0
131
136
131
null
[]
None
null
0
0
0
null
0
null
The function (_get_all_weight_scales) defined within the public class called public.The function start at line 131 and ends at 136. 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
_get_all_weight_zero_points
def _get_all_weight_zero_points(self) -> List[torch.Tensor]:return [self.linear1.weight_fake_quantizer.zero_point,self.sub.linear.weight_fake_quantizer.zero_point,self.linear2.weight_fake_quantizer.zero_point,]
1
6
1
41
0
138
143
138
null
[]
None
null
0
0
0
null
0
null
The function (_get_all_weight_zero_points) defined within the public class called public.The function start at line 138 and ends at 143. 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
_get_all_weight_qparams
def _get_all_weight_qparams(self) -> List[torch.Tensor]:return self._get_all_weight_scales() + self._get_all_weight_zero_points()
1
2
1
24
0
145
146
145
null
[]
None
null
0
0
0
null
0
null
The function (_get_all_weight_qparams) defined within the public class called public.The function start at line 145 and ends at 146. 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
forward
def forward(self, x):x = self.linear1(x)x = self.sub(x)x = self.linear2(x)return x
1
5
2
33
0
148
152
148
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 148 and ends at 152. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [148.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.embedding = torch.nn.Embedding(10, 512)
1
3
1
26
0
156
158
156
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 156 and ends at 158. 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
example_inputs
def example_inputs(self):return (torch.randint(1, 10, (1, 512)),)
1
2
1
23
0
160
161
160
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 160 and ends at 161. 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
forward
def forward(self, x):return self.linear(x)
1
2
2
14
0
163
164
117
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 163 and ends at 164. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [117.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.embedding = torch.nn.Embedding(10, 512)self.linear1 = torch.nn.Linear(512, 256, bias=False).to(torch.float)self.linear2 = torch.nn.Linear(256, 512, bias=False).to(torch.float)self.relu = torch.nn.ReLU()
1
6
1
87
0
168
173
168
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 168 and ends at 173. 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
example_inputs
def example_inputs(self):return (torch.randint(1, 10, (1, 512)),)
1
2
1
23
0
175
176
160
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 175 and ends at 176. 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
forward
def forward(self, x):x = self.embedding(x)x = self.linear1(x)x = self.linear2(x)x = self.relu(x)return x
1
6
2
41
0
178
183
178
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 178 and ends at 183. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [178.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, dtype: torch.dtype = torch.float32):super().__init__()self.dtype = dtypeself.linear = torch.nn.Linear(512, 256, bias=False).to(dtype)
1
4
2
50
0
187
190
187
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 187 and ends at 190. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [187.0] and does not return any value..
pytorch_ao
public
public
0
0
example_inputs
def example_inputs(self):return (torch.randn(1, 256).to(torch.float),)
1
2
1
24
0
192
193
114
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 192 and ends at 193. 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
forward
def forward(self, x):return self.linear(x)
1
2
2
14
0
195
196
117
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 195 and ends at 196. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [117.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self):super().__init__()self.linear1 = torch.nn.Linear(512, 256, bias=True)self.linear2 = torch.nn.Linear(256, 512, bias=True)
1
4
1
48
0
200
203
200
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 200 and ends at 203. 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
example_inputs
def example_inputs(self):return (torch.randn(1, 512),)
1
2
1
17
0
205
206
205
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 205 and ends at 206. 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
forward
def forward(self, x):x = self.linear1(x)x = self.linear2(x)return x
1
4
2
25
0
208
211
208
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 208 and ends at 211. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [208.0] and does not return any value..
pytorch_ao
public
public
0
0
test_fake_quantize_per_channel_group
def test_fake_quantize_per_channel_group(self):n_bit = 4(qmin, qmax) = _get_qmin_qmax(n_bit)group_size = 128torch.manual_seed(self.SEED)x = torch.randn(100, 256).requires_grad_()(s, zp) = get_group_qparams_symmetric(x, n_bit, group_size)zp = zp.to(torch.int32)x2 = copy.deepcopy(x)# fake quant opout = _fake_quantize_per...
1
38
1
177
0
217
259
217
null
[]
None
null
0
0
0
null
0
null
The function (test_fake_quantize_per_channel_group) defined within the public class called public.The function start at line 217 and ends at 259. It contains 38 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_fake_quantize_per_token
def test_fake_quantize_per_token(self):(qmin, qmax) = _get_qmin_qmax(8)torch.manual_seed(self.SEED)x = torch.randn(100, 256).requires_grad_()x2 = copy.deepcopy(x)block_size = _get_per_token_block_size(x)(s, zp) = choose_qparams_affine(x,mapping_type=MappingType.ASYMMETRIC,block_size=block_size,target_dtype=torch.int8,q...
1
38
1
188
0
261
303
261
null
[]
None
null
0
0
0
null
0
null
The function (test_fake_quantize_per_token) defined within the public class called public.The function start at line 261 and ends at 303. It contains 38 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
_set_ptq_weight
def _set_ptq_weight(self,ptq_linear: torch.nn.Module,qat_linear: torch.nn.Module,):"""Set the weight to the quantized version of the given fp32 weights,for making linear outputs comparable with QAT."""from torchao.quantization.GPTQ import (Int8DynActInt4WeightLinear,WeightOnlyInt4Linear,)from torchao.quantization.qat.l...
3
47
3
225
0
305
356
305
null
[]
None
null
0
0
0
null
0
null
The function (_set_ptq_weight) defined within the public class called public.The function start at line 305 and ends at 356. It contains 47 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [305.0] and does not return any value..
pytorch_ao
public
public
0
0
test_qat_8da4w_linear
def test_qat_8da4w_linear(self):from torchao.quantization.GPTQ import Int8DynActInt4WeightLinearfrom torchao.quantization.qat.linear import Int8DynActInt4WeightQATLineargroup_size = 128torch.manual_seed(self.SEED)qat_linear = Int8DynActInt4WeightQATLinear(256,688,bias=False,groupsize=group_size,)ptq_linear = Int8DynAct...
1
24
1
132
0
358
386
358
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_linear) defined within the public class called public.The function start at line 358 and ends at 386. 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_qat_8da4w_quantizer
def test_qat_8da4w_quantizer(self):from torchao.quantization.GPTQ import Int8DynActInt4WeightQuantizerfrom torchao.quantization.qat import Int8DynActInt4WeightQATQuantizergroup_size = 16torch.manual_seed(self.SEED)m = M()m2 = copy.deepcopy(m)qat_quantizer = Int8DynActInt4WeightQATQuantizer(groupsize=group_size)ptq_quan...
2
27
1
228
0
388
421
388
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_quantizer) defined within the public class called public.The function start at line 388 and ends at 421. It contains 27 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_qat_8da4w_quantizer_meta_weights
def test_qat_8da4w_quantizer_meta_weights(self):from torchao.quantization.qat import Int8DynActInt4WeightQATQuantizerwith torch.device("meta"):m = M()self.assertTrue(all(v.is_meta for v in m.state_dict().values()))group_size = 16qat_quantizer = Int8DynActInt4WeightQATQuantizer(groupsize=group_size)qat_model = qat_quant...
3
9
1
91
0
423
432
423
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_quantizer_meta_weights) defined within the public class called public.The function start at line 423 and ends at 432. It contains 9 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
test_qat_8da4w_quantizer_disable_fake_quant
def test_qat_8da4w_quantizer_disable_fake_quant(self):"""Test that 8da4w QAT with disabled fake quant matches nn.Linear in forward."""from torchao.quantization.qat.linear import (Int8DynActInt4WeightQATQuantizer,disable_8da4w_fake_quant,enable_8da4w_fake_quant,)group_size = 16torch.manual_seed(self.SEED)m = M()m2 = cop...
1
47
1
456
0
434
490
434
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_quantizer_disable_fake_quant) defined within the public class called public.The function start at line 434 and ends at 490. 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_qat_8da4w_quantizer_disable_fake_quant_backward
def test_qat_8da4w_quantizer_disable_fake_quant_backward(self):"""Test that 8da4w QAT with disabled fake quant matches nn.Linear in backward."""from torchao.quantization.qat.linear import (Int8DynActInt4WeightQATQuantizer,disable_8da4w_fake_quant,)group_size = 16torch.manual_seed(self.SEED)m = M()nn_model = copy.deepco...
1
45
1
388
0
492
544
492
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_quantizer_disable_fake_quant_backward) defined within the public class called public.The function start at line 492 and ends at 544. It contains 45 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_quantized_gradients
def _test_qat_quantized_gradients(self, quantizer):"""Test that QAT produces gradients in the backward pass."""num_steps = 10torch.manual_seed(self.SEED)m = M()model = quantizer.prepare(m)optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9, weight_decay=1e-5)loss_fn = torch.nn.CrossEntropyLoss()# Sim...
3
35
2
244
0
546
586
546
null
[]
None
null
0
0
0
null
0
null
The function (_test_qat_quantized_gradients) defined within the public class called public.The function start at line 546 and ends at 586. It contains 35 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [546.0] and does not return any value..
pytorch_ao
public
public
0
0
test_qat_8da4w_quantizer_gradients
def test_qat_8da4w_quantizer_gradients(self):from torchao.quantization.qat import Int8DynActInt4WeightQATQuantizerquantizer = Int8DynActInt4WeightQATQuantizer(groupsize=16)self._test_qat_quantized_gradients(quantizer)
1
4
1
27
0
588
592
588
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_8da4w_quantizer_gradients) defined within the public class called public.The function start at line 588 and ends at 592. 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
_assert_close_4w
def _assert_close_4w(self, val, ref):# Note: for int4 weight-only quantization, we do not expect exact match# because torch._weight_int4pack_mm and torch.mm do not match exactly.# Here we use the same error bar as PyTorch core to determine closeness:# https://github.com/pytorch/pytorch/blob/6079c5091091d872b8dafbaa4e31...
1
4
3
42
0
594
601
594
null
[]
None
null
0
0
0
null
0
null
The function (_assert_close_4w) defined within the public class called public.The function start at line 594 and ends at 601. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [594.0] and does not return any value..
pytorch_ao
public
public
0
0
test_qat_4w_primitives
def test_qat_4w_primitives(self):n_bit = 4group_size = 32inner_k_tiles = 8scales_precision = torch.bfloat16device = torch.device("cuda")dtype = torch.bfloat16torch.manual_seed(self.SEED)x = torch.randn(100, 256, dtype=dtype, device=device)weight = torch.randn(512, 256, dtype=dtype, device=device)# PTQ(q_weight, scales_...
1
44
1
212
0
604
652
604
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_4w_primitives) defined within the public class called public.The function start at line 604 and ends at 652. It contains 44 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_4w_linear
def test_qat_4w_linear(self):from torchao.quantization.GPTQ import WeightOnlyInt4Linearfrom torchao.quantization.qat.linear import Int4WeightOnlyQATLineargroup_size = 128device = torch.device("cuda")dtype = torch.bfloat16torch.manual_seed(self.SEED)qat_linear = Int4WeightOnlyQATLinear(256,688,bias=False,groupsize=group...
1
28
1
151
0
655
687
655
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_4w_linear) defined within the public class called public.The function start at line 655 and ends at 687. 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_qat_4w_quantizer_gradients
def test_qat_4w_quantizer_gradients(self):from torchao.quantization.qat import Int4WeightOnlyQATQuantizerquantizer = Int4WeightOnlyQATQuantizer(groupsize=32, inner_k_tiles=8)self._test_qat_quantized_gradients(quantizer)
1
4
1
31
0
689
693
689
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_4w_quantizer_gradients) defined within the public class called public.The function start at line 689 and ends at 693. 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_qat_4w_quantizer
def test_qat_4w_quantizer(self):from torchao.quantization.GPTQ import Int4WeightOnlyQuantizerfrom torchao.quantization.qat import Int4WeightOnlyQATQuantizergroup_size = 32inner_k_tiles = 8device = torch.device("cuda")dtype = torch.bfloat16torch.manual_seed(self.SEED)m = M().to(device).to(dtype)m2 = copy.deepcopy(m)qat_...
3
36
1
270
0
696
738
696
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_4w_quantizer) defined within the public class called public.The function start at line 696 and ends at 738. It contains 36 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, value: str):self.value = value
1
2
2
14
0
748
749
748
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 748 and ends at 749. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [748.0] and does not return any value..
pytorch_ao
public
public
0
0
_attach_value
def _attach_value(self, module: torch.nn.Module):if isinstance(module, torch.nn.Linear):if not hasattr(module, self.ATTR_NAME):setattr(module, self.ATTR_NAME, [])getattr(module, self.ATTR_NAME).append(self.value)
3
5
2
62
0
751
755
751
null
[]
None
null
0
0
0
null
0
null
The function (_attach_value) defined within the public class called public.The function start at line 751 and ends at 755. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [751.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare
def prepare(self, model: torch.nn.Module):model.apply(self._attach_value)return model
1
3
2
23
0
757
759
757
null
[]
None
null
0
0
0
null
0
null
The function (prepare) defined within the public class called public.The function start at line 757 and ends at 759. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [757.0] and does not return any value..
pytorch_ao
public
public
0
0
convert
def convert(self, model: torch.nn.Module):model.apply(self._attach_value)return model
1
3
2
23
0
761
763
761
null
[]
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 761 and ends at 763. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [761.0] and does not return any value..
pytorch_ao
public
public
0
0
test_composable_qat_quantizer
def test_composable_qat_quantizer(self):quantizer1 = self._MyQATQuantizer("quantizer1")quantizer2 = self._MyQATQuantizer("quantizer2")composable_quantizer = ComposableQATQuantizer([quantizer1, quantizer2])model = M()model = composable_quantizer.prepare(model)self.assertTrue(hasattr(model.linear1, self._MyQATQuantizer.A...
1
14
1
123
0
765
778
765
null
[]
None
null
0
0
0
null
0
null
The function (test_composable_qat_quantizer) defined within the public class called public.The function start at line 765 and ends at 778. 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_qat_4w_embedding
def test_qat_4w_embedding(self):from torchao._executorch_ops import (_quantized_decomposed_quantize_per_channel_group_wrapper,)from torchao.quantization.qat import Int4WeightOnlyEmbeddingQATQuantizergroup_size = 256model = M2()x = model.example_inputs()model(*x)quantizer = Int4WeightOnlyEmbeddingQATQuantizer(group_size...
1
34
1
182
0
780
816
780
null
[]
None
null
0
0
0
null
0
null
The function (test_qat_4w_embedding) defined within the public class called public.The function start at line 780 and ends at 816. It contains 34 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..