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 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 199 | 202 | 192 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 199 and ends at 202. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [192.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_linear_extra_repr_for_lut | def _get_linear_extra_repr_for_lut(self) -> str:"""Custom __repr__ for a linear module quantized with GroupwiseLutQuantizedTensor."""out_features, in_features = self.weight.shape# Access metadata from the custom tensorbit_width = self.weight.bit_widthlut_group_size = self.weight.lut_group_sizescale_group_size = self.we... | 1 | 11 | 1 | 55 | 4 | 22 | 40 | 22 | null | ['bit_width', 'has_bias', 'scale_group_size', 'lut_group_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_linear_extra_repr_for_lut) defined within the public class called public.The function start at line 22 and ends at 40. 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 | __post_init__ | def __post_init__(self):"""Validate the configuration after initialization."""# 1. Validate backend stringif self.backend not in ["auto", "scale", "coreml"]:raise ValueError(f"Invalid backend: {self.backend}")# 2. Validate lut_block_shapeif not (isinstance(self.lut_block_shape, list) and len(self.lut_block_shape) == 2)... | 10 | 23 | 1 | 122 | 0 | 84 | 112 | 84 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__post_init__) defined within the public class called public.The function start at line 84 and ends at 112. It contains 23 lines of code and it has a cyclomatic complexity of 10. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _groupwise_lut_weight_transform | def _groupwise_lut_weight_transform(module: torch.nn.Module, config: GroupwiseLutWeightConfig) -> torch.nn.Module:"""Transforms a linear module by applying groupwise LUT-based weight quantization.Automatically caches results if config.cache_dir is set, using a hash ofthe weight tensor for a unique key."""assert isinsta... | 3 | 22 | 2 | 151 | 4 | 116 | 146 | 116 | null | ['packed_weight', 'dequantized_weight', 'weight', 'quantized_tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_groupwise_lut_weight_transform) defined within the public class called public.The function start at line 116 and ends at 146. It contains 22 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [116.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_pack_op | def get_pack_op(weight_nbit: int):"""Gets the C++ packing function from the 'torchao' namespace."""op_name = f"_pack_groupwise_{weight_nbit}bit_weight_with_lut"if not hasattr(torch.ops.torchao, op_name):raise NotImplementedError(f"Packing op for {weight_nbit}-bit not found.")return getattr(torch.ops.torchao, op_name) | 2 | 5 | 1 | 42 | 1 | 25 | 30 | 25 | null | ['op_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_pack_op) defined within the public class called public.The function start at line 25 and ends at 30. It contains 5 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 | get_linear_op | def get_linear_op(weight_nbit: int):"""Gets the C++ fused linear function from the 'torchao' namespace."""op_name = f"_linear_groupwise_{weight_nbit}bit_weight_with_lut"if not hasattr(torch.ops.torchao, op_name):raise NotImplementedError(f"Linear op for {weight_nbit}-bit not found.")return getattr(torch.ops.torchao, op... | 2 | 5 | 1 | 42 | 1 | 33 | 38 | 33 | null | ['op_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_linear_op) defined within the public class called public.The function start at line 33 and ends at 38. It contains 5 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 | __new__ | def __new__(cls, packed_weight, bit_width, lut_block_size, scale_block_size, shape, dtype):kwargs = {"device": packed_weight.device,"dtype": dtype,"requires_grad": False,}return torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs) | 1 | 9 | 7 | 49 | 0 | 56 | 64 | 56 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 56 and ends at 64. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [56.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,packed_weight: torch.Tensor,bit_width: int,lut_block_size: List[int],scale_block_size: Optional[List[int]],shape: torch.Size,dtype: torch.dtype,):self.packed_weight = packed_weightself.bit_width = bit_widthself.lut_block_size = lut_block_sizeself.scale_block_size = scale_block_size | 1 | 13 | 7 | 65 | 0 | 66 | 78 | 66 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 66 and ends at 78. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [66.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_unpacked | def from_unpacked(cls,int_data: torch.Tensor,luts: torch.Tensor,scales: Optional[torch.Tensor],bit_width: int,lut_block_size: List[int],scale_block_size: Optional[List[int]],original_shape: torch.Size,bias: Optional[torch.Tensor] = None,):lut_group_size = block_shape_to_group_size(lut_block_size, int_data.shape)if scal... | 3 | 32 | 9 | 165 | 0 | 81 | 116 | 81 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_unpacked) defined within the public class called public.The function start at line 81 and ends at 116. It contains 32 lines of code and it has a cyclomatic complexity of 3. It takes 9 parameters, represented as [81.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_codebook_quantized_tensor | def from_codebook_quantized_tensor(cls,tensor: CodebookQuantizedTensor,*,bias: Optional[torch.Tensor] = None,):"""Factory method to create a packed tensor from a CodebookQuantizedTensor.This method takes the general components of a codebook-quantized tensor(codes, codebook, etc.) and uses a specialized 'pack_op' to fus... | 1 | 20 | 3 | 118 | 0 | 119 | 166 | 119 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_codebook_quantized_tensor) defined within the public class called public.The function start at line 119 and ends at 166. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [119.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):"""Override for `torch.nn.functional.linear` specifically for theGroupwiseLutQuantizedTensor. This calls the fused C++ kernel."""input_tensor, weight_tensor, _ = (args[0],args[1],args[2] if len(args) > 2 else None,)linear_op = get_linear_op(weight_tensor.bit_width)lut_group_size = block... | 4 | 22 | 4 | 154 | 8 | 173 | 200 | 173 | null | ['output', 'n', 'k', 'lut_group_size', 'input_tensor', 'output_shape', 'linear_op', 'original_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 173 and ends at 200. It contains 22 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [173.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 204 | 207 | 204 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 204 and ends at 207. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [204.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 211 | 214 | 204 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 211 and ends at 214. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [204.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_shape_to_group_size | def block_shape_to_group_size(block_shape, tensor_shape):"""Calculates the total number of elements in a group from a block_shape."""n_group, k_group = block_shapen_dim, k_dim = tensor_shapeif n_group == -1:n_group = n_dimif k_group == -1:k_group = k_dimreturn n_group * k_group | 3 | 8 | 2 | 40 | 2 | 26 | 36 | 26 | null | ['k_group', 'n_group'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_shape_to_group_size) defined within the public class called public.The function start at line 26 and ends at 36. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [26.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | group_size_to_block_shapes | def group_size_to_block_shapes(lut_group_size: int,tensor_shape: Tuple[int, int],) -> Tuple[List[int], Optional[List[int]]]:"""Translates legacy integer-based group sizes into the new block_shape list format.This function encodes the implicit assumptions of the old system:- LUTs were always grouped by rows.- Scales wer... | 2 | 13 | 2 | 68 | 2 | 39 | 72 | 39 | null | ['rows_per_lut', 'lut_block_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (group_size_to_block_shapes) defined within the public class called public.The function start at line 39 and ends at 72. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [39.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantize_row_wise_group_with_scales | def _quantize_row_wise_group_with_scales(input_tensor: torch.Tensor,rows_per_group: int,scale_block_shape: List[int],code_dtype: torch.dtype,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Quantizes a 2D tensor using row-wise grouping, with a unique LUT andset of scales for each group.Returns a tuple of (codes,... | 2 | 37 | 4 | 230 | 8 | 76 | 130 | 76 | null | ['final_scales', 'final_luts', 'start_row', 'end_row', 'final_codes', 'codes', 'tensor_slice', 'num_groups'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantize_row_wise_group_with_scales) defined within the public class called public.The function start at line 76 and ends at 130. It contains 37 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [76.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _dequantize_row_wise_group_with_scales | def _dequantize_row_wise_group_with_scales(codes: torch.Tensor,luts: torch.Tensor,scales: torch.Tensor,rows_per_group: int,scale_group_size: int,output_dtype: torch.dtype = torch.float32,) -> torch.Tensor:"""Dequantizes a 2D tensor that was quantized with `quantize_per_row_group_with_scales`.Args:codes (torch.Tensor): ... | 2 | 34 | 6 | 205 | 10 | 134 | 214 | 134 | null | ['codes_slice', 'num_scale_blocks', 'current_lut', 'start_row', 'end_row', 'dequantized_tensor', 'dequant_slice', 'reshaped_scales', 'scales_slice', 'num_groups'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_dequantize_row_wise_group_with_scales) defined within the public class called public.The function start at line 134 and ends at 214. It contains 34 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [134.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize_flexible_grouping | def quantize_flexible_grouping(input_tensor: torch.Tensor,lut_block_shape: List[int],code_dtype: torch.dtype,) -> Tuple[torch.Tensor, torch.Tensor, None]:"""Quantizes a tensor using either row-wise or column-wise grouping.Args:input_tensor (torch.Tensor): The 2D tensor to be quantized.Shape: (n_rows, k_cols)lut_block_s... | 6 | 45 | 3 | 260 | 3 | 218 | 289 | 218 | null | ['final_luts', 'tensor_slice', 'final_codes'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize_flexible_grouping) defined within the public class called public.The function start at line 218 and ends at 289. It contains 45 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [218.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dequantize_with_flexible_grouping | def dequantize_with_flexible_grouping(codes: torch.Tensor,luts: torch.Tensor,lut_block_shape: List[int],code_dtype: torch.dtype,output_dtype: torch.dtype = torch.float32,) -> torch.Tensor:assert codes.ndim == 2, "This function expects a 2D codes tensor."n_rows, k_cols = codes.shapen_group, k_group = lut_block_shape# ST... | 5 | 41 | 5 | 225 | 5 | 293 | 346 | 293 | null | ['codes_slice', 'current_lut', 'dequantized_tensor', 'dequant_slice', 'num_groups'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dequantize_with_flexible_grouping) defined within the public class called public.The function start at line 293 and ends at 346. It contains 41 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [293.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize_dispatch | def quantize_dispatch(input_tensor: torch.Tensor,lut_block_shape: List[int],code_dtype: torch.dtype,scale_block_shape: Optional[List[int]] = None,# Make this optionalbackend: str = "auto",) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:"""Single entry point for quantization that dispatches to the correct... | 8 | 35 | 5 | 175 | 3 | 349 | 416 | 349 | null | ['rows_per_lut_group', 'backend', 'luts'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize_dispatch) defined within the public class called public.The function start at line 349 and ends at 416. It contains 35 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [349.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dequantize_dispatch | def dequantize_dispatch(codes: torch.Tensor,luts: torch.Tensor,scales: Optional[torch.Tensor],lut_block_shape: List[int],scale_block_shape: Optional[List[int]] = None,backend: str = "auto",code_dtype: torch.dtype = torch.int4,output_dtype: torch.dtype = torch.float32,) -> torch.Tensor:"""Single entry point for dequanti... | 8 | 48 | 8 | 222 | 6 | 419 | 480 | 419 | null | ['luts_4d', 'backend', 'num_luts', 'lut_size', 'rows_per_lut_group', 'scale_group_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dequantize_dispatch) defined within the public class called public.The function start at line 419 and ends at 480. It contains 48 lines of code and it has a cyclomatic complexity of 8. It takes 8 parameters, represented as [419.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | save_quantized_data | def save_quantized_data(data: Dict[str, Any], filepath: str):"""Saves the dictionary of quantized tensors to a file."""# Create the directory if it doesn't existos.makedirs(os.path.dirname(filepath), exist_ok=True)torch.save(data, filepath)print(f"Saved quantization results to '{filepath}'") | 1 | 4 | 2 | 47 | 0 | 483 | 490 | 483 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (save_quantized_data) defined within the public class called public.The function start at line 483 and ends at 490. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [483.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | load_quantized_data | def load_quantized_data(filepath: str) -> Optional[Dict[str, Any]]:"""Loads the dictionary of quantized tensors from a file if it exists."""if not os.path.exists(filepath):return Nonedata = torch.load(filepath)print(f"Loaded quantization results from cache: '{filepath}'")return data | 2 | 6 | 1 | 46 | 1 | 493 | 501 | 493 | null | ['data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (load_quantized_data) defined within the public class called public.The function start at line 493 and ends at 501. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,bit_width,):super().__init__()self.bit_width = bit_width | 1 | 6 | 2 | 20 | 0 | 39 | 44 | 39 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 39 and ends at 44. It contains 6 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 | quantize_and_pack_weights | def quantize_and_pack_weights(self, weights, group_size, mapping_type):num_embeddings, embedding_dim = weights.shapeembedding = torch.nn.Embedding(num_embeddings, embedding_dim)embedding.weight = weightsquantize_(embedding,IntxWeightOnlyConfig(weight_dtype=getattr(torch, f"int{self.bit_width}"),granularity=PerGroup(gro... | 2 | 29 | 4 | 200 | 0 | 46 | 77 | 46 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize_and_pack_weights) defined within the public class called public.The function start at line 46 and ends at 77. It contains 29 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [46.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):shape = x.shapereturn getattr(torch.ops.torchao, f"_embedding_{self.bit_width}bit")(self.packed_weight_qvals,self.num_embeddings,self.embedding_dim,self.weight_scales,# embedding op requires weight_zeros be passed, even if they are all 0self.weight_zeros,x.reshape(-1),).reshape(*shape, -1) | 1 | 10 | 2 | 63 | 0 | 79 | 89 | 79 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 79 and ends at 89. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [79.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,bit_width,):super().__init__()self.bit_width = bit_width | 1 | 6 | 2 | 20 | 0 | 93 | 98 | 39 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 93 and ends at 98. It contains 6 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 | quantize_and_pack_weights | def quantize_and_pack_weights(self, weights, group_size, mapping_type):self.embedding = torch.nn.Embedding(*weights.shape)self.embedding.weight = weightsquantize_(self.embedding,IntxWeightOnlyConfig(weight_dtype=getattr(torch, f"int{self.bit_width}"),granularity=PerGroup(group_size) if group_size > 0 else PerAxis(0),ma... | 2 | 12 | 4 | 90 | 0 | 100 | 111 | 100 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize_and_pack_weights) defined within the public class called public.The function start at line 100 and ends at 111. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [100.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):return self.embedding(x) | 1 | 2 | 2 | 14 | 0 | 113 | 114 | 113 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 113 and ends at 114. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [113.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, bit_width, unembedding_packed_weights, group_size, n, k):super().__init__()self.bit_width = bit_widthself.register_buffer("unembedding_packed_weights", unembedding_packed_weights)self.n = nself.k = kif group_size == -1:self.group_size = kelse:self.group_size = group_sizeself.shared_embedding_op = get... | 2 | 13 | 6 | 78 | 0 | 118 | 130 | 118 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 118 and ends at 130. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [118.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):shape = x.shapereturn self.shared_embedding_op(self.unembedding_packed_weights,self.group_size,self.n,self.k,x.reshape(-1),).reshape(*shape, -1) | 1 | 9 | 2 | 51 | 0 | 132 | 140 | 132 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 132 and ends at 140. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [132.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _replace_embedding_with_quantized_embedding | def _replace_embedding_with_quantized_embedding(module: nn.Module,kwargs={},fqn: str = "",):group_size = kwargs.get("group_size", None)bit_width = kwargs.get("bit_width", None)use_fallback = kwargs.get("use_fallback", None)mapping_type = kwargs.get("mapping_type", None)assert not isinstance(module, nn.Embedding)for nam... | 5 | 36 | 3 | 217 | 6 | 143 | 181 | 143 | null | ['child_fqn', 'group_size', 'qembedding', 'bit_width', 'mapping_type', 'use_fallback'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_replace_embedding_with_quantized_embedding) defined within the public class called public.The function start at line 143 and ends at 181. It contains 36 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [143.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,weight_dtype: torch.dtype = torch.int4,granularity: Granularity = PerAxis(0),mapping_type: MappingType = MappingType.ASYMMETRIC,use_fallback: bool = False,):assert weight_dtype in [getattr(torch, f"int{i}") for i in range(1, 9)]bit_width = _DTYPE_TO_BIT_WIDTH[weight_dtype]if isinstance(granularity, Pe... | 4 | 20 | 3 | 125 | 0 | 185 | 206 | 185 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 185 and ends at 206. It contains 20 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [185.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize | def quantize(self, model: nn.Module) -> nn.Module:_replace_embedding_with_quantized_embedding(model,kwargs={"group_size": self.group_size,"bit_width": self.bit_width,"use_fallback": self.use_fallback,"mapping_type": self.mapping_type,},)return model | 1 | 11 | 2 | 51 | 0 | 208 | 218 | 208 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize) defined within the public class called public.The function start at line 208 and ends at 218. It contains 11 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 | _get_fqns_with_filter | def _get_fqns_with_filter(module: nn.Module,filter_fn: Callable[Tuple[str, nn.Module], bool],fqn: str,fqns: List[str],):for name, child in module.named_children():child_fqn = f"{fqn}.{name}" if fqn != "" else nameif filter_fn(child, child_fqn):fqns.append(child_fqn)else:_get_fqns_with_filter(child, filter_fn, child_fqn... | 4 | 12 | 4 | 84 | 1 | 221 | 232 | 221 | null | ['child_fqn'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_fqns_with_filter) defined within the public class called public.The function start at line 221 and ends at 232. It contains 12 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [221.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_fqns_with_filter | def get_fqns_with_filter(module: nn.Module, filter_fn: Callable[Tuple[str, nn.Module], bool]) -> List[str]:fqns = []_get_fqns_with_filter(module, filter_fn, "", fqns)return fqns | 1 | 6 | 2 | 46 | 1 | 235 | 240 | 235 | null | ['fqns'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_fqns_with_filter) defined within the public class called public.The function start at line 235 and ends at 240. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [235.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, packed_weight, n, k, group_size, bit_width, bias):super().__init__()self.register_buffer("packed_weight", packed_weight)self.n = nself.k = kself.group_size = group_sizeself.bit_width = bit_widthself.bias = bias | 1 | 8 | 7 | 57 | 0 | 244 | 251 | 244 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 244 and ends at 251. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [244.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _forward_2d | def _forward_2d(self, x):assert x.dim() == 2m, k = x.shapeassert k == self.kreturn getattr(torch.ops.torchao, f"_linear_8bit_act_{self.bit_width}bit_weight")(x, self.packed_weight, self.group_size, self.n, self.k) | 1 | 7 | 2 | 59 | 0 | 253 | 259 | 253 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_forward_2d) defined within the public class called public.The function start at line 253 and ends at 259. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [253.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):if x.dim() == 2:res = self._forward_2d(x)else:assert x.dim() >= 3lead_shape = x.shape[0:-2]m, k = x.shape[-2], x.shape[-1]assert k == self.kres = self._forward_2d(x.reshape(-1, k))res = res.reshape(*lead_shape, m, self.n)if self.bias is not None:res = res + self.biasreturn res | 3 | 13 | 2 | 118 | 0 | 261 | 274 | 261 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 261 and ends at 274. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [261.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_parent_by_fqn | def get_parent_by_fqn(root: nn.Module, fqn: str):parts = fqn.split(".")if len(parts) == 1:# e.g. "fqn" → parent is root, child is "fqn"return root, parts[0]parent_fqn = ".".join(parts[:-1])child_name = parts[-1]parent = dict(root.named_modules()).get(parent_fqn, None)if parent is None:raise KeyError(f"Parent module {pa... | 3 | 10 | 2 | 88 | 4 | 277 | 288 | 277 | null | ['parent_fqn', 'parts', 'parent', 'child_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_parent_by_fqn) defined within the public class called public.The function start at line 277 and ends at 288. It contains 10 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [277.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,weight_dtype: torch.dtype = torch.int4,granularity: Granularity = PerAxis(0),mapping_type: MappingType = MappingType.ASYMMETRIC,):self.weight_dtype = weight_dtypeself.granularity = granularityself.mapping_type = mapping_type | 1 | 9 | 3 | 48 | 0 | 292 | 300 | 292 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 292 and ends at 300. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [292.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize | def quantize(self,model: nn.Module,embedding_to_unembedding: Optional[Mapping[str, str]] = None,):embedding_fqns = get_fqns_with_filter(model, lambda m, fqn: isinstance(m, nn.Embedding))linear_fqns = get_fqns_with_filter(model, lambda m, fqn: isinstance(m, nn.Linear))state_dict = model.state_dict()# If embedding_to_une... | 16 | 104 | 3 | 513 | 0 | 302 | 420 | 302 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize) defined within the public class called public.The function start at line 302 and ends at 420. It contains 104 lines of code and it has a cyclomatic complexity of 16. It takes 3 parameters, represented as [302.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _gguf_weight_only_transform | def _gguf_weight_only_transform(module: torch.nn.Module,config: GGUFWeightOnlyConfig,):"""Applies gguf weight-only quantization to linear layers.Args:dtype: torch.uint1 to torch.uint8, torch.int32 supported.n_blocks_per_superblock: the number of super blocks in a 256 element block for gguf, e.g. when it is 8it means we... | 3 | 14 | 2 | 86 | 2 | 28 | 52 | 28 | null | ['quantized_weight', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_gguf_weight_only_transform) defined within the public class called public.The function start at line 28 and ends at 52. It contains 14 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [28.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,n_blocks_per_superblock,super_block_scale_scale,super_block_min_scale,quantized_block_scale,quantized_block_min,int_data,shape,**kwargs,):kwargs["device"] = kwargs.get("device", super_block_scale_scale.device)kwargs["dtype"] = kwargs.get("dtype", super_block_scale_scale.dtype)kwargs["requires_grad"] = F... | 1 | 15 | 9 | 73 | 0 | 35 | 49 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 35 and ends at 49. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,n_blocks_per_superblock,super_block_scale_scale,super_block_min_scale,quantized_block_scale,quantized_block_min,int_data,shape,**kwargs,):self.n_blocks_per_superblock = n_blocks_per_superblockself.super_block_scale_scale = super_block_scale_scaleself.super_block_min_scale = super_block_min_scaleself.q... | 1 | 17 | 9 | 53 | 0 | 51 | 67 | 51 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 51 and ends at 67. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [51.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_fn_to_data | def _apply_fn_to_data(self, fn):return self.__class__(self.n_blocks_per_superblock,fn(self.super_block_scale_scale),fn(self.super_block_min_sclae),fn(self.quantized_block_scale),fn(self.quantized_block_min),fn(self.int_data),self.shape,dtype=self.dtype,) | 1 | 11 | 2 | 62 | 0 | 69 | 79 | 69 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_fn_to_data) defined within the public class called public.The function start at line 69 and ends at 79. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [69.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_flatten__ | def __tensor_flatten__(self):return ["super_block_scale_scale","super_block_min_scale","quantized_block_scale","quantized_block_min","int_data",], (self.n_blocks_per_superblock,self.dtype,self.shape,) | 1 | 12 | 1 | 33 | 0 | 81 | 92 | 81 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__tensor_flatten__) defined within the public class called public.The function start at line 81 and ends at 92. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_unflatten__ | def __tensor_unflatten__(cls, tensor_data_dict, attributes, outer_size=None, outer_stride=None):(super_block_scale_scale,super_block_min_scale,quantized_block_scale,quantized_block_min,int_data,) = (tensor_data_dict["super_block_scale_scale"],tensor_data_dict["super_block_min_scale"],tensor_data_dict["quantized_block_s... | 2 | 27 | 5 | 92 | 0 | 95 | 121 | 95 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__tensor_unflatten__) defined within the public class called public.The function start at line 95 and ends at 121. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [95.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dequantize | def dequantize(self, output_dtype: Optional[torch.dtype] = None) -> torch.Tensor:if output_dtype is None:output_dtype = self.dtypeblock_size = tuple([1] * (self.int_data.ndim - 1) + [_QK_K // self.n_blocks_per_superblock])return _dequantize_gguf(self.int_data,block_size,self.dtype,self.super_block_scale_scale,self.supe... | 2 | 16 | 2 | 86 | 0 | 123 | 139 | 123 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dequantize) defined within the public class called public.The function start at line 123 and ends at 139. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [123.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to | def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs.pop("device")return self.__class__(self.n_blocks_per_superblock,self.super_block_scale_scale.to(device),self.super_block_min_scale.to(device),self.quantized_block_scale.to(device),self.quantized_block_min.to(device),self.int_data... | 1 | 13 | 3 | 93 | 0 | 141 | 153 | 141 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to) defined within the public class called public.The function start at line 141 and ends at 153. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [141.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_fn_to_data | def _apply_fn_to_data(self, fn):"""Returns a new `CodebookQuantizedTensor`."""return self.__class__(self.n_blocks_per_superblock,fn(self.super_block_scale_scale),fn(self.super_block_min_scale),fn(self.quantized_block_scale),fn(self.quantized_block_min),fn(self.int_data),self.shape,dtype=self.dtype,) | 1 | 11 | 2 | 63 | 0 | 155 | 168 | 155 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_fn_to_data) defined within the public class called public.The function start at line 155 and ends at 168. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [155.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | requires_grad_ | def requires_grad_(self, requires_grad=False):"""Modifies the tensor's `requires_grad` status in-place."""assert not requires_grad, "Only requires_grad == False is supported"return self | 1 | 3 | 2 | 17 | 0 | 170 | 175 | 170 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (requires_grad_) defined within the public class called public.The function start at line 170 and ends at 175. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [170.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, input_float, n_blocks_per_superblock, target_dtype):"""Method used to convert a linear weight tensor to an instance of theGGMLInt4LinearWeight subclass.Example usage::model.lin_mod.weight = (GGMLInt4LinearWeight.from_float(model.lin_mod.weight))"""assert target_dtype == torch.uint4, ("only uint4 qua... | 1 | 29 | 4 | 87 | 0 | 178 | 217 | 178 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float) defined within the public class called public.The function start at line 178 and ends at 217. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [178.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 224 | 227 | 224 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 224 and ends at 227. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [224.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 231 | 234 | 224 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 231 and ends at 234. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [224.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func,args,kwargs,args[0].to(*args[1:], **kwargs)._apply_fn_to_data(torch.clone),) | 1 | 7 | 4 | 46 | 0 | 238 | 244 | 238 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 238 and ends at 244. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [238.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):input_tensor, weight_tensor, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)if not input_tensor.is_floating_point():raise NotImplementedError(f"{func} is not implemented for non floating point input")dtype = input_tensor.dtypeif hasattr(weight_tensor, "dequantize"):weight_t... | 4 | 14 | 4 | 95 | 2 | 248 | 264 | 248 | null | ['weight_tensor', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 248 and ends at 264. It contains 14 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [248.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,packed_weights,bit_width,block_size,shape,dtype,packed_weights_has_bias,):kwargs = {}kwargs["device"] = packed_weights.devicekwargs["dtype"] = dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[attr-defined] | 1 | 14 | 7 | 56 | 0 | 40 | 53 | 40 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 40 and ends at 53. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [40.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,packed_weights,bit_width,block_size,shape,dtype,packed_weights_has_bias,):super().__init__()assert packed_weights.device == torch.device("cpu")self.packed_weights = packed_weightsself.bit_width = bit_widthself.block_size = block_sizeself.packed_weights_has_bias = packed_weights_has_bias | 1 | 15 | 7 | 56 | 0 | 55 | 69 | 55 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 55 and ends at 69. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [55.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantization_type | def _quantization_type(self):return f"bit_width={self.bit_width}, block_size={self.block_size}, shape={self.shape}, dtype={self.dtype}, device={self.device}" | 1 | 2 | 1 | 8 | 0 | 71 | 72 | 71 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantization_type) 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. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to | def to(self, *args, **kwargs):raise NotImplementedError("to() is not implemented for IntxOpaqueTensor") | 1 | 2 | 3 | 16 | 0 | 74 | 75 | 74 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to) defined within the public class called public.The function start at line 74 and ends at 75. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [74.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_lut_params | def _get_lut_params(cls, tensor: IntxUnpackedToInt8Tensor):assert isinstance(tensor, IntxUnpackedToInt8Tensor)assert tensor.target_dtype in [torch.int1, torch.int2, torch.int3, torch.int4]qdata = tensor.qdatascale = tensor.scalezero_point = tensor.zero_pointif tensor._has_float_zero_point():# Stretched tensors from PAR... | 3 | 21 | 2 | 173 | 0 | 78 | 109 | 78 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_lut_params) defined within the public class called public.The function start at line 78 and ends at 109. It contains 21 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [78.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_intx_unpacked_to_int8_tensor | def from_intx_unpacked_to_int8_tensor(cls,tensor: IntxUnpackedToInt8Tensor,*,bias: Optional[torch.Tensor] = None,):"""Constructs a Int8LutTensor from an IntxUnpackedToInt8Tensor.If bias is passed, bias is packed into the tensor."""assert _is_kernel_library_loaded(), "TorchAO kernel library is not loaded"assert (tensor.... | 3 | 44 | 3 | 194 | 0 | 112 | 164 | 112 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_intx_unpacked_to_int8_tensor) defined within the public class called public.The function start at line 112 and ends at 164. It contains 44 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [112.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _linear_impl_2d | def _linear_impl_2d(input_tensor: torch.Tensor, weight_tensor: torch.Tensor, bias: torch.Tensor):assert isinstance(weight_tensor, Int8LutTensor)assert input_tensor.dim() == 2assert weight_tensor.dim() == 2assert weight_tensor.block_size[0] == 1group_size = weight_tensor.block_size[1]m, k = input_tensor.shapen, k_ = wei... | 3 | 28 | 3 | 155 | 5 | 170 | 202 | 170 | null | ['res', 'group_size', 'packed_weights', 'bit_width', 'input_tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_linear_impl_2d) defined within the public class called public.The function start at line 170 and ends at 202. It contains 28 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [170.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):input_tensor, weight_tensor, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)# TODO: why was this added https://github.com/pytorch/ao/pull/2043if input_tensor.numel() == 0:return input_tensorif input_tensor.dim() == 1:k = input_tensor.shape[0]input_tensor = input_tensor.resh... | 6 | 27 | 4 | 219 | 4 | 206 | 237 | 206 | null | ['res', 'input_tensor', 'lead_shape', 'k'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 206 and ends at 237. It contains 27 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [206.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | eval | def eval(model, tokenizer, num_PPL_eval_samples, fqn_to_config):return {"cal_PPL": (cal_wikitext_ppl(model, tokenizer, num_PPL_eval_samples), 0.0),"model_size": (cal_model_size(model, fqn_to_config), 0.0),} | 1 | 5 | 4 | 46 | 0 | 23 | 27 | 23 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (eval) defined within the public class called public.The function start at line 23 and ends at 27. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [23.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_initial_samples | def get_initial_samples(num_BO_initial_samples=10):initial_points_set = []# auto sample the bit choices with random choice probability positive correlated to FIT scorefor _ in range(num_BO_initial_samples):initial_points = {}for i in range(0, 3):initial_points["bitwidth." + str(i) + "."] = 5initial_points["groupsize." ... | 8 | 42 | 1 | 437 | 2 | 32 | 79 | 32 | null | ['initial_points', 'initial_points_set'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_initial_samples) defined within the public class called public.The function start at line 32 and ends at 79. It contains 42 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_sequential_BO | def run_sequential_BO(device,checkpoint,num_PPL_eval_samples,num_trials,model_size_constraint,history_output,parameters_list,initial_samples,):# TODO: add default parameter list if not specifiedparameters_list = load_parameters_from_json(parameters_list)initial_points_set = load_initial_samples(initial_samples)num_BO_i... | 3 | 61 | 8 | 331 | 8 | 90 | 171 | 90 | null | ['history', 'constraint', 'eval_results', 'trial_id', 'initial_points_set', 'parameters_list', 'ax_client', 'num_BO_initial_samples'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_sequential_BO) defined within the public class called public.The function start at line 90 and ends at 171. It contains 61 lines of code and it has a cyclomatic complexity of 3. It takes 8 parameters, represented as [90.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | eval_in_parallel | def eval_in_parallel(gpu_id, checkpoint, num_PPL_eval_samples, config, return_dict, proc_id, trial_id):model, tokenizer = load_model(checkpoint, f"cuda:{gpu_id}")print(f"Process {proc_id} on GPU {gpu_id} starts!")dict_config = dict(config)quantize_by_fqn_to_config(model=model, device=f"cuda:{gpu_id}", fqn_to_config=dic... | 1 | 13 | 7 | 87 | 2 | 175 | 191 | 175 | null | ['dict_config', 'eval_results'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (eval_in_parallel) defined within the public class called public.The function start at line 175 and ends at 191. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [175.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_parallel_BO | def run_parallel_BO(device,checkpoint,num_PPL_eval_samples,num_trials,model_size_constraint,gpu_list,history_output,parameters_list,initial_samples,):# TODO: add default parameter list if not specifiedparameters_list = load_parameters_from_json(parameters_list)initial_points_set = load_initial_samples(initial_samples)n... | 11 | 101 | 9 | 497 | 13 | 201 | 327 | 201 | null | ['history', 'manager', 'p', 'constraint', 'parameter_tuple', 'gpu_list', 'trial_id', 'initial_points_set', 'return_dict', 'parameters_list', 'ax_client', 'processes', 'num_BO_initial_samples'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_parallel_BO) defined within the public class called public.The function start at line 201 and ends at 327. It contains 101 lines of code and it has a cyclomatic complexity of 11. It takes 9 parameters, represented as [201.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | decode_n_tokens | def decode_n_tokens(model: Transformer,cur_token: torch.Tensor,input_pos: torch.Tensor,num_new_tokens: int,callback=lambda _: _,**sampling_kwargs,):new_tokens, new_probs = [], []for i in range(num_new_tokens):with torch.backends.cuda.sdp_kernel(enable_flash=False, enable_mem_efficient=False, enable_math=True):# Actuall... | 2 | 23 | 6 | 141 | 1 | 39 | 62 | 39 | null | ['cur_token'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (decode_n_tokens) defined within the public class called public.The function start at line 39 and ends at 62. It contains 23 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [39.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | generate | def generate(model: Transformer,prompt: torch.Tensor,max_new_tokens: int,*,interactive: bool,callback=lambda x: x,kv_cache_quantization: bool = False,**sampling_kwargs,) -> torch.Tensor:"""Takes a conditioning sequence (prompt) as input and continues to generate as many tokens as requested."""# create an empty tensor o... | 3 | 44 | 7 | 282 | 7 | 66 | 129 | 66 | null | ['input_pos', 'seq', 'device', 'T', 'new_tokens', 'next_token', 'max_seq_length'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (generate) defined within the public class called public.The function start at line 66 and ends at 129. It contains 44 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [66.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | cal_throughput.callback | def callback(x):nonlocal done_generatingif done_generating:returnbuffer.append(tokenizer.decode([period_id] + x.tolist())[1:])if x.item() == tokenizer.eos_id():done_generating = Trueif len(buffer) == 4 or done_generating:print("".join(buffer), end="", flush=True)buffer.clear() | 5 | 10 | 1 | 82 | 0 | 196 | 205 | 196 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (cal_throughput.callback) defined within the public class called public.The function start at line 196 and ends at 205. It contains 10 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 | cal_throughput | def cal_throughput(model,tokenizer,device,prompt: str = "Hello, my name is",interactive: bool = False,num_samples: int = 5,max_new_tokens: int = 100,top_k: int = 200,temperature: float = 0.8,checkpoint_path: Path = Path("/tmp/Meta-Llama-3-8B/model.pth"),quantization: Optional[str] = None,kv_cache_quantization: bool = F... | 16 | 88 | 10 | 519 | 19 | 132 | 244 | 132 | null | ['callback', 't0', 'prof', 'encoded', 'tokpersec', 'prompt_length', 'decode_one_token', 'period_id', 'tokens_sec', 'aggregate_metrics', 'done_generating', 'prompt', 'prefill', 'is_chat', 'start', 't', 'buffer', 'y', 'tokens_generated'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (cal_throughput) defined within the public class called public.The function start at line 132 and ends at 244. It contains 88 lines of code and it has a cyclomatic complexity of 16. It takes 10 parameters, represented as [132.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | eval | def eval(model4ppl, model4tp, tokenizer, device, num_PPL_eval_samples, fqn_to_config):return {"cal_PPL": (cal_wikitext_ppl(model4ppl, tokenizer, num_PPL_eval_samples), 0.0),"cal_throughput": (cal_throughput(model=model4tp, tokenizer=tokenizer, device=device),0.0,),} | 1 | 8 | 6 | 59 | 0 | 248 | 255 | 248 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (eval) defined within the public class called public.The function start at line 248 and ends at 255. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [248.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | define_parameter_list | def define_parameter_list():# define the search space for all layersparameters_list = []for i in range(0, 3):parameters_list.append({"name": f"bitwidth.{i}.","type": "fixed","value_type": "int","value": 8,"is_ordered": True,"sort_values": True,})parameters_list.append({"name": f"groupsize.{i}.","type": "fixed","value_t... | 4 | 66 | 0 | 252 | 1 | 259 | 331 | 259 | null | ['parameters_list'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (define_parameter_list) defined within the public class called public.The function start at line 259 and ends at 331. It contains 66 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 | get_initial_samples | def get_initial_samples(num_BO_initial_samples=10):initial_points_set = []# auto sample the bit choices with random choice probability positive correlated to FIT scorefor _ in range(num_BO_initial_samples):initial_points = {}for i in range(0, 3):initial_points["bitwidth." + str(i) + "."] = 8initial_points["groupsize." ... | 8 | 42 | 1 | 453 | 2 | 336 | 384 | 336 | null | ['initial_points', 'initial_points_set'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_initial_samples) defined within the public class called public.The function start at line 336 and ends at 384. It contains 42 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_sequential_BO | def run_sequential_BO(device,checkpoint_path,repo_id,num_PPL_eval_samples,num_trials,ppl_constraint,args,):"""currently use the loader and benchmark code from torchao/_models/llama/generate,and use lm_eval for ppl evaluation"""# load tokenizersassert checkpoint_path.is_file(), checkpoint_pathtokenizer_path = checkpoint... | 3 | 93 | 7 | 545 | 16 | 394 | 522 | 394 | null | ['history', 'constraint', 'initial_samples', 'tokenizer4ppl', 'ppl', 'eval_results', 'trial_id', 'tokenizer4tp', 'model4tp', 'tokenizer_path', 'initial_points_set', 'tp', 'model4ppl', 'parameters_list', 'ax_client', 'num_BO_initial_samples'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_sequential_BO) defined within the public class called public.The function start at line 394 and ends at 522. It contains 93 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [394.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_wikitext2 | def get_wikitext2(nsamples, seed, seqlen, tokenizer):traindata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="train")testdata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="test")trainenc = tokenizer("\n\n".join(traindata["text"]), return_tensors="pt")testenc = tokenizer("\n\n".joi... | 2 | 15 | 4 | 159 | 9 | 15 | 31 | 15 | null | ['inp', 'trainenc', 'testdata', 'i', 'traindata', 'j', 'trainloader', 'tar', 'testenc'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_wikitext2) defined within the public class called public.The function start at line 15 and ends at 31. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [15.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | cal_FIT | def cal_FIT(device, data, nsamples, model, max_iter, max_seqlen, criterion, num_layers):# store the history of trace for each layerestimated_history = []# store the history of mean trace for each layerestimated_mean = [[] for _ in range(num_layers)]trace = [0.0] * num_layersfor iteration in range(max_iter):print("itera... | 11 | 32 | 8 | 315 | 11 | 34 | 79 | 34 | null | ['outputs', 'logits', 'trace', 'estimated_history', 'grads', 'trace_tmp', 'estimated_mean', 'loss', 'targets', 'F_average', 'inputs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (cal_FIT) defined within the public class called public.The function start at line 34 and ends at 79. It contains 32 lines of code and it has a cyclomatic complexity of 11. It takes 8 parameters, represented as [34.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | main | def main(max_seqlen, checkpoint, nsamples, max_iter, num_layers):device = "cuda" if torch.cuda.is_available() else "cpu"# have been tested models Llama-3-8B, Llama-2-7B, Mistral-7B, and stories110Mmodel = transformers.AutoModelForCausalLM.from_pretrained(checkpoint, dtype=torch.bfloat16)tokenizer = transformers.AutoTok... | 2 | 25 | 5 | 158 | 5 | 82 | 112 | 82 | null | ['device', 'tokenizer', 'criterion', 'model', 'seed'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main) defined within the public class called public.The function start at line 82 and ends at 112. It contains 25 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [82.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | group_product | def group_product(xs, ys):return [torch.sum(x * y) for (x, y) in zip(xs, ys)] | 2 | 2 | 2 | 31 | 0 | 16 | 17 | 16 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (group_product) defined within the public class called public.The function start at line 16 and ends at 17. It contains 2 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 | get_wikitext2 | def get_wikitext2(nsamples, seed, seqlen, tokenizer):traindata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="train")testdata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="test")trainenc = tokenizer("\n\n".join(traindata["text"]), return_tensors="pt")testenc = tokenizer("\n\n".joi... | 2 | 15 | 4 | 161 | 9 | 20 | 36 | 20 | null | ['inp', 'trainenc', 'testdata', 'i', 'traindata', 'j', 'trainloader', 'tar', 'testenc'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_wikitext2) defined within the public class called public.The function start at line 20 and ends at 36. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [20.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dataloader_hv_product | def dataloader_hv_product(layerid, params, device, v, data, nsamples, model, max_seqlen, criterion):model.zero_grad()THv = [torch.zeros(p.size()).to(device) for p in params]# accumulate result# Freeze all the parameters in the modelfor param in model.parameters():param.requires_grad = False# Unfreeze the parameters of ... | 8 | 32 | 9 | 289 | 9 | 39 | 86 | 39 | null | ['outputs', 'logits', 'layer_', 'Hv', 'grads', 'THv', 'loss', 'labels', 'inputs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dataloader_hv_product) defined within the public class called public.The function start at line 39 and ends at 86. It contains 32 lines of code and it has a cyclomatic complexity of 8. It takes 9 parameters, represented as [39.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | cal_trace | def cal_trace(layerid, params, device, data, nsamples, model, max_iter, max_seqlen, criterion):vhv_c_history = []trace_history = []trace = 0.0for i in range(max_iter):print("iteration: ", i)# generate Rademacher random variablesv = [torch.randint_like(p, high=2, device=device) for p in params]for v_i in v:v_i[v_i == 0]... | 5 | 23 | 9 | 181 | 7 | 89 | 123 | 89 | null | ['Hv', 'trace', 'v', 'vHv_c', 'vHv', 'vhv_c_history', 'trace_history'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (cal_trace) defined within the public class called public.The function start at line 89 and ends at 123. It contains 23 lines of code and it has a cyclomatic complexity of 5. It takes 9 parameters, represented as [89.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | main | def main(layer_id, checkpoint, max_seqlen, max_iter, nsamples):device = "cuda" if torch.cuda.is_available() else "cpu"# to avoid aten::_scaled_dot_product_flash_attention_backward not implemented errorwith sdpa_kernel(SDPBackend.MATH):# have been tested models Llama-3-8B, Llama-2-7B, Mistral-7B, and stories110Mmodel = ... | 4 | 30 | 5 | 200 | 8 | 126 | 164 | 126 | null | ['layer_', 'trace', 'device', 'tokenizer', 'criterion', 'model', 'seed', 'params'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main) defined within the public class called public.The function start at line 126 and ends at 164. It contains 30 lines of code and it has a cyclomatic complexity of 4. It takes 5 parameters, represented as [126.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | group_product | def group_product(xs, ys):return [torch.sum(x * y) for (x, y) in zip(xs, ys)] | 2 | 2 | 2 | 31 | 0 | 17 | 18 | 17 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (group_product) 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 2. It takes 2 parameters, represented as [17.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_wikitext2 | def get_wikitext2(nsamples, seed, seqlen, tokenizer):traindata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="train")testdata = load_dataset("Salesforce/wikitext", "wikitext-2-raw-v1", split="test")trainenc = tokenizer("\n\n".join(traindata["text"]), return_tensors="pt")testenc = tokenizer("\n\n".joi... | 2 | 15 | 4 | 161 | 9 | 21 | 37 | 21 | null | ['inp', 'trainenc', 'testdata', 'i', 'traindata', 'j', 'trainloader', 'tar', 'testenc'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_wikitext2) defined within the public class called public.The function start at line 21 and ends at 37. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [21.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | del_attr | def del_attr(obj, names):if len(names) == 1:delattr(obj, names[0])else:del_attr(getattr(obj, names[0]), names[1:]) | 2 | 5 | 2 | 44 | 0 | 41 | 45 | 41 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (del_attr) defined within the public class called public.The function start at line 41 and ends at 45. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [41.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | set_attr | def set_attr(obj, names, val):if len(names) == 1:setattr(obj, names[0], val)else:set_attr(getattr(obj, names[0]), names[1:], val) | 2 | 5 | 3 | 50 | 0 | 48 | 52 | 48 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_attr) defined within the public class called public.The function start at line 48 and ends at 52. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [48.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | make_functional | def make_functional(mod, layer_id):orig_params = tuple(mod.parameters())# remove all the parameters in the modelselected_params = []selected_params_names = []names = []for name, p in list(mod.named_parameters()):if name.startswith("model.layers." + str(layer_id) + ".self_attn.") or name.startswith("model.layers." + str... | 4 | 14 | 2 | 109 | 4 | 55 | 70 | 55 | null | ['selected_params_names', 'orig_params', 'selected_params', 'names'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (make_functional) defined within the public class called public.The function start at line 55 and ends at 70. It contains 14 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [55.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | main.load_weights | def load_weights(mod, names, params, selected_params, selected_params_names):for name, p in zip(names, params):if name.startswith("model.layers." + str(layer_id) + ".self_attn.") or name.startswith("model.layers." + str(layer_id) + ".mlp."):idx = selected_params_names.index(name)set_attr(mod, name.split("."), selected_... | 6 | 12 | 5 | 114 | 0 | 75 | 86 | 75 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main.load_weights) defined within the public class called public.The function start at line 75 and ends at 86. It contains 12 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [75.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | main.f | def f(*new_params):load_weights(model, names, params, new_params, selected_params_names)model.zero_grad()outputs = model(inputs)logits = outputs.logitsloss = criterion(logits.view(-1, logits.size(-1)), labels.view(-1))return loss | 1 | 7 | 1 | 64 | 0 | 89 | 95 | 89 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main.f) defined within the public class called public.The function start at line 89 and ends at 95. 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 | main | def main(layer_id, checkpoint, max_seqlen, max_iter, nsamples):# use the functional model to load the weights backdef load_weights(mod, names, params, selected_params, selected_params_names):for name, p in zip(names, params):if name.startswith("model.layers." + str(layer_id) + ".self_attn.") or name.startswith("model.l... | 13 | 47 | 5 | 407 | 19 | 73 | 166 | 73 | null | ['outputs', 'trace', 'tokenizer', 'loss', 'trace_history', 'device', 'v', 'vHv', 'params', 'selected_params_tuple', 'logits', 'labels', 'vhv_c_history', 'inputs', 'TvH', 'model', 'criterion', 'vHv_c', 'idx'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main) defined within the public class called public.The function start at line 73 and ends at 166. It contains 47 lines of code and it has a cyclomatic complexity of 13. It takes 5 parameters, represented as [73.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_evaluation.filter_fn_sen | def filter_fn_sen(child: torch.nn.Module, cur_fqn: str) -> bool:return isinstance(child, nn.Linear) and any(skiplayer in cur_fqnfor skiplayer in [".0.", ".1.", ".2.", ".30.", ".31."]) | 3 | 5 | 2 | 47 | 0 | 58 | 62 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_evaluation.filter_fn_sen) defined within the public class called public.The function start at line 58 and ends at 62. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [58.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_evaluation.filter_fn_nonsen | def filter_fn_nonsen(child: torch.nn.Module, cur_fqn: str) -> bool:return isinstance(child, nn.Linear) and not (any(skiplayer in cur_fqnfor skiplayer in [".0.", ".1.", ".2.", ".30.", ".31."])) | 3 | 7 | 2 | 50 | 0 | 65 | 71 | 65 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_evaluation.filter_fn_nonsen) defined within the public class called public.The function start at line 65 and ends at 71. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [65.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_evaluation | def run_evaluation(repo_id,tasks,limit,device,precision,quantization,compile,batch_size,max_length,sensi_bit,non_sensi_bit,quant_sym,group_size,):tokenizer = AutoTokenizer.from_pretrained(repo_id)model = AutoModelForCausalLM.from_pretrained(repo_id).to(device="cpu", dtype=precision)if quantization == "autoquant":model ... | 8 | 70 | 13 | 302 | 3 | 23 | 117 | 23 | null | ['result', 'tokenizer', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_evaluation) defined within the public class called public.The function start at line 23 and ends at 117. It contains 70 lines of code and it has a cyclomatic complexity of 8. It takes 13 parameters, represented as [23.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _intN_weight_only_transform.apply_intN_weight_only_quant_asym | def apply_intN_weight_only_quant_asym(weight):# avoid circular dependencyfrom torchao.dtypes import to_affine_quantized_intxmapping_type = MappingType.ASYMMETRICblock_size = (1, group_size)target_dtype = torch.uint8quant_min = 0quant_max = 2**n - 1eps = 1e-6zero_point_dtype = torch.int64return to_affine_quantized_intx(... | 1 | 19 | 1 | 70 | 0 | 56 | 76 | 56 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_intN_weight_only_transform.apply_intN_weight_only_quant_asym) defined within the public class called public.The function start at line 56 and ends at 76. It contains 19 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _intN_weight_only_transform.apply_intN_weight_only_quant_sym | def apply_intN_weight_only_quant_sym(weight):# avoid circular dependencyfrom torchao.dtypes import to_affine_quantized_intxmapping_type = MappingType.SYMMETRICblock_size = (1, group_size)target_dtype = torch.int8quant_min = -(2 ** (n - 1))quant_max = 2 ** (n - 1) - 1eps = 1e-6zero_point_dtype = torch.int64return to_aff... | 1 | 19 | 1 | 85 | 0 | 79 | 99 | 79 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_intN_weight_only_transform.apply_intN_weight_only_quant_sym) defined within the public class called public.The function start at line 79 and ends at 99. It contains 19 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _intN_weight_only_transform | def _intN_weight_only_transform(module: torch.nn.Module,config: IntNWeightOnlyConfig,) -> torch.nn.Module:group_size = config.group_sizen = config.nsymmetric = config.symmetricweight = module.weightif config.set_inductor_config:torchao.quantization.utils.recommended_inductor_config_setter()# for asymmetric quantization... | 5 | 28 | 2 | 135 | 12 | 44 | 116 | 44 | null | ['quant_min', 'n', 'group_size', 'symmetric', 'block_size', 'eps', 'target_dtype', 'new_weight', 'quant_max', 'mapping_type', 'zero_point_dtype', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_intN_weight_only_transform) defined within the public class called public.The function start at line 44 and ends at 116. It contains 28 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [44.0] and does not return any value.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.