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
from_linear
def from_linear(cls,mod: torch.nn.Linear,activation_config: Optional[FakeQuantizeConfigBase] = None,weight_config: Optional[FakeQuantizeConfigBase] = None,):new_linear = FakeQuantizedLinear(mod.in_features,mod.out_features,mod.bias is not None,activation_config=activation_config,weight_config=weight_config,device=mod.w...
2
19
4
106
0
134
155
134
null
[]
None
null
0
0
0
null
0
null
The function (from_linear) defined within the public class called public.The function start at line 134 and ends at 155. It contains 19 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [134.0] and does not return any value..
pytorch_ao
public
public
0
0
enable_linear_fake_quant
def enable_linear_fake_quant(mod: torch.nn.Module,enabled: bool = True,):"""Helper function to enable fake quantization in `FakeQuantizedLinear`."""if isinstance(mod, FakeQuantizedLinear):if mod.activation_fake_quantizer is not None:mod.activation_fake_quantizer.enabled = enabledif mod.weight_fake_quantizer is not None...
4
9
2
57
0
158
169
158
null
[]
None
null
0
0
0
null
0
null
The function (enable_linear_fake_quant) defined within the public class called public.The function start at line 158 and ends at 169. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [158.0] and does not return any value..
pytorch_ao
public
public
0
0
disable_linear_fake_quant
def disable_linear_fake_quant(mod: torch.nn.Module):"""Helper function to disable fake quantization in `FakeQuantizedLinear`."""enable_linear_fake_quant(mod, enabled=False)
1
2
1
20
0
172
176
172
null
[]
None
null
0
0
0
null
0
null
The function (disable_linear_fake_quant) defined within the public class called public.The function start at line 172 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
get_activation_fake_quantize_config
def get_activation_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return None
1
2
1
12
0
189
190
189
null
[]
None
null
0
0
0
null
0
null
The function (get_activation_fake_quantize_config) defined within the public class called public.The function start at line 189 and ends at 190. 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
get_weight_fake_quantize_config
def get_weight_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return None
1
2
1
12
0
192
193
192
null
[]
None
null
0
0
0
null
0
null
The function (get_weight_fake_quantize_config) 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
__init__
def __init__(self,groupsize: int = 256,padding_allowed: bool = False,precision: torch.dtype = torch.float32,scales_precision: torch.dtype = torch.float32,) -> None:super().__init__()torch._C._log_api_usage_once("torchao.quantization.qat.Int8DynActInt4WeightQATQuantizer")self.groupsize: int = groupsizeself.padding_allow...
1
16
5
94
0
208
224
208
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 208 and ends at 224. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [208.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare
def prepare(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:_replace_linear_8da4w(model,self.groupsize,self.padding_allowed,self.precision,self.scales_precision,Int8DynActInt4WeightQATLinear,copy_weights=True,)return model
1
13
4
58
0
226
238
226
null
[]
None
null
0
0
0
null
0
null
The function (prepare) defined within the public class called public.The function start at line 226 and ends at 238. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [226.0] and does not return any value..
pytorch_ao
public
public
0
0
convert
def convert(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:self._convert_qat_linear_8da4w(model)return model
1
5
4
37
0
240
244
240
null
[]
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 240 and ends at 244. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [240.0] and does not return any value..
pytorch_ao
public
public
0
0
_convert_qat_linear_8da4w
def _convert_qat_linear_8da4w(self, module: torch.nn.Module):"""Replace all `Int8DynActInt4WeightQATLinear` with `Int8DynActInt4WeightLinear`."""for name, child in module.named_children():if isinstance(child, Int8DynActInt4WeightQATLinear):config = child.weight_fake_quantizer.configquantized_linear = Int8DynActInt4Weig...
4
41
2
208
0
246
292
246
null
[]
None
null
0
0
0
null
0
null
The function (_convert_qat_linear_8da4w) defined within the public class called public.The function start at line 246 and ends at 292. It contains 41 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [246.0] and does not return any value..
pytorch_ao
public
public
0
0
get_activation_fake_quantize_config
def get_activation_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return _get_8da4w_activation_config(self.activation_scales_precision)
1
2
1
17
0
294
295
294
null
[]
None
null
0
0
0
null
0
null
The function (get_activation_fake_quantize_config) defined within the public class called public.The function start at line 294 and ends at 295. 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
get_weight_fake_quantize_config
def get_weight_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return _get_8da4w_weight_config(self.groupsize, self.scales_precision)
1
2
1
21
0
297
298
297
null
[]
None
null
0
0
0
null
0
null
The function (get_weight_fake_quantize_config) defined within the public class called public.The function start at line 297 and ends at 298. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,in_features: int,out_features: int,bias: bool = False,device: torch.device = None,groupsize: int = 256,precision: torch.dtype = torch.float32,scales_precision: torch.dtype = torch.float32,) -> None:# Use torch.float32 to match torchao.quantization.quant_api._int8_asymm_per_token_quant,# which is used ...
1
21
8
97
0
316
339
316
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 316 and ends at 339. It contains 21 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [316.0] and does not return any value..
pytorch_ao
public
public
0
0
enable_fake_quant
def enable_fake_quant(self, enabled: bool = True):self.activation_fake_quantizer.enabled = enabledself.weight_fake_quantizer.enabled = enabled
1
3
2
25
0
341
343
341
null
[]
None
null
0
0
0
null
0
null
The function (enable_fake_quant) defined within the public class called public.The function start at line 341 and ends at 343. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [341.0] and does not return any value..
pytorch_ao
public
public
0
0
disable_fake_quant
def disable_fake_quant(self):self.enable_fake_quant(False)
1
2
1
11
0
345
346
345
null
[]
None
null
0
0
0
null
0
null
The function (disable_fake_quant) defined within the public class called public.The function start at line 345 and ends at 346. 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
enable_8da4w_fake_quant
def enable_8da4w_fake_quant(mod: torch.nn.Module):"""(deprecated) Enable fake quantization for `Int8DynActInt4WeightQATLinear`."""if isinstance(mod, Int8DynActInt4WeightQATLinear):mod.enable_fake_quant()
2
3
1
25
0
350
355
350
null
[]
None
null
0
0
0
null
0
null
The function (enable_8da4w_fake_quant) defined within the public class called public.The function start at line 350 and ends at 355. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
disable_8da4w_fake_quant
def disable_8da4w_fake_quant(mod: torch.nn.Module):"""(deprecated) Disable fake quantization for `Int8DynActInt4WeightQATLinear`."""if isinstance(mod, Int8DynActInt4WeightQATLinear):mod.disable_fake_quant()
2
3
1
25
0
359
364
359
null
[]
None
null
0
0
0
null
0
null
The function (disable_8da4w_fake_quant) defined within the public class called public.The function start at line 359 and ends at 364. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_get_8da4w_activation_config
def _get_8da4w_activation_config(qparams_precision: torch.dtype,) -> IntxFakeQuantizeConfig:"""Return the activation `IntxFakeQuantizeConfig` for `Int8DynActInt4WeightQATQuantizer`."""# TODO: generalize thisassert qparams_precision == torch.float32return IntxFakeQuantizeConfig(dtype=torch.int8,granularity="per_token",i...
1
13
1
60
0
367
383
367
null
[]
None
null
0
0
0
null
0
null
The function (_get_8da4w_activation_config) defined within the public class called public.The function start at line 367 and ends at 383. 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
_get_8da4w_weight_config
def _get_8da4w_weight_config(group_size: int,qparams_precision: torch.dtype,) -> IntxFakeQuantizeConfig:"""Return the weight `IntxFakeQuantizeConfig` for `Int8DynActInt4WeightQATQuantizer`."""return IntxFakeQuantizeConfig(dtype=TorchAODType.INT4,group_size=group_size,is_symmetric=True,is_dynamic=True,scale_precision=qp...
1
12
2
47
0
386
400
386
null
[]
None
null
0
0
0
null
0
null
The function (_get_8da4w_weight_config) defined within the public class called public.The function start at line 386 and ends at 400. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [386.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,groupsize: int = 256,inner_k_tiles: Optional[int] = 8,precision: torch.dtype = torch.bfloat16,scales_precision: torch.dtype = torch.bfloat16,) -> None:super().__init__()torch._C._log_api_usage_once("torchao.quantization.qat.Int4WeightOnlyQATQuantizer")assert inner_k_tiles in [2, 4, 8]assert groupsize ...
1
17
5
100
0
414
430
414
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 414 and ends at 430. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [414.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare
def prepare(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:_replace_linear_int4(model,self.groupsize,self.inner_k_tiles,padding_allowed=True,precision=self.precision,scales_precision=self.scales_precision,linear_class=Int4WeightOnlyQATLinear,copy_weights=True,)return model
1
14
4
68
0
432
445
432
null
[]
None
null
0
0
0
null
0
null
The function (prepare) defined within the public class called public.The function start at line 432 and ends at 445. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [432.0] and does not return any value..
pytorch_ao
public
public
0
0
convert
def convert(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:self._convert_qat_linear_8da4w(model)return model
1
5
4
37
0
447
451
240
null
[]
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 447 and ends at 451. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [240.0] and does not return any value..
pytorch_ao
public
public
0
0
_convert_qat_linear_4w
def _convert_qat_linear_4w(self, module: torch.nn.Module):"""Replace all `Int4WeightOnlyQATLinear` with `WeightOnlyInt4Linear`."""for name, child in module.named_children():if isinstance(child, Int4WeightOnlyQATLinear):in_features = child.in_featuresout_features = child.out_featuresinner_k_tiles = child.inner_k_tilesco...
4
38
2
219
0
453
495
453
null
[]
None
null
0
0
0
null
0
null
The function (_convert_qat_linear_4w) defined within the public class called public.The function start at line 453 and ends at 495. It contains 38 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [453.0] and does not return any value..
pytorch_ao
public
public
0
0
get_weight_fake_quantize_config
def get_weight_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return _get_8da4w_weight_config(self.groupsize, self.scales_precision)
1
2
1
21
0
497
498
297
null
[]
None
null
0
0
0
null
0
null
The function (get_weight_fake_quantize_config) defined within the public class called public.The function start at line 497 and ends at 498. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,in_features: int,out_features: int,bias: bool = False,device: torch.device = None,groupsize: int = 256,inner_k_tiles: int = 8,precision: torch.dtype = torch.bfloat16,scales_precision: torch.dtype = torch.bfloat16,) -> None:assert scales_precision == torch.bfloat16, "only bf16 is supported for scales"i...
2
25
9
128
0
513
537
513
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 513 and ends at 537. It contains 25 lines of code and it has a cyclomatic complexity of 2. It takes 9 parameters, represented as [513.0] and does not return any value..
pytorch_ao
public
public
0
0
enable_fake_quant
def enable_fake_quant(self, enabled: bool = True):self.activation_fake_quantizer.enabled = enabledself.weight_fake_quantizer.enabled = enabled
1
3
2
25
0
539
541
341
null
[]
None
null
0
0
0
null
0
null
The function (enable_fake_quant) defined within the public class called public.The function start at line 539 and ends at 541. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [341.0] and does not return any value..
pytorch_ao
public
public
0
0
disable_fake_quant
def disable_fake_quant(self):self.enable_fake_quant(False)
1
2
1
11
0
543
544
345
null
[]
None
null
0
0
0
null
0
null
The function (disable_fake_quant) defined within the public class called public.The function start at line 543 and ends at 544. 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
enable_4w_fake_quant
def enable_4w_fake_quant(mod: torch.nn.Module):"""(deprecated) Enable fake quantization for `Int4WeightOnlyQATLinear`."""if isinstance(mod, Int4WeightOnlyQATLinear):mod.enable_fake_quant()
2
3
1
25
0
548
553
548
null
[]
None
null
0
0
0
null
0
null
The function (enable_4w_fake_quant) defined within the public class called public.The function start at line 548 and ends at 553. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
disable_4w_fake_quant
def disable_4w_fake_quant(mod: torch.nn.Module):"""(deprecated) Disable fake quantization for `Int4WeightOnlyQATLinear`."""if isinstance(mod, Int4WeightOnlyQATLinear):mod.disable_fake_quant()
2
3
1
25
0
557
562
557
null
[]
None
null
0
0
0
null
0
null
The function (disable_4w_fake_quant) defined within the public class called public.The function start at line 557 and ends at 562. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_get_4w_weight_config
def _get_4w_weight_config(group_size: int,qparams_precision: torch.dtype,) -> IntxFakeQuantizeConfig:"""Return the weight `IntxFakeQuantizeConfig` for `Int4WeightOnlyQATQuantizer`."""return IntxFakeQuantizeConfig(dtype=torch.uint4,group_size=group_size,is_symmetric=False,is_dynamic=True,scale_precision=qparams_precisio...
1
13
2
53
0
565
580
565
null
[]
None
null
0
0
0
null
0
null
The function (_get_4w_weight_config) defined within the public class called public.The function start at line 565 and ends at 580. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [565.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,group_size: Optional[int] = 64,scale_precision: torch.dtype = torch.bfloat16,):torch._C._log_api_usage_once("torchao.quantization.qat.Float8ActInt4WeightQATQuantizer")if group_size is not None:weight_granularity = "per_group"else:weight_granularity = "per_channel"self._activation_config = Float8FakeQu...
2
24
3
99
0
601
624
601
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 601 and ends at 624. It contains 24 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [601.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare
def prepare(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:"""Swap all `nn.Linear` with `FakeQuantizedLinear` with float8fake quantizer for activations and int4 fake quantizer for weights."""for name, child in model.named_children():if isinstance(child, torch.nn.Linear):new_linear = FakeQua...
3
14
4
92
0
626
643
626
null
[]
None
null
0
0
0
null
0
null
The function (prepare) defined within the public class called public.The function start at line 626 and ends at 643. It contains 14 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [626.0] and does not return any value..
pytorch_ao
public
public
0
0
convert
def convert(self, model: torch.nn.Module, *args: Any, **kwargs: Any) -> torch.nn.Module:raise NotImplementedError
1
4
4
31
0
646
649
646
null
[]
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 646 and ends at 649. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [646.0] and does not return any value..
pytorch_ao
public
public
0
0
get_activation_fake_quantize_config
def get_activation_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:raise NotImplementedError("Float8 FakeQuantizeConfig does not exist yet")
1
2
1
15
0
651
652
651
null
[]
None
null
0
0
0
null
0
null
The function (get_activation_fake_quantize_config) defined within the public class called public.The function start at line 651 and ends at 652. 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
get_weight_fake_quantize_config
def get_weight_fake_quantize_config(self) -> Optional[FakeQuantizeConfigBase]:return self.weight_config
1
2
1
14
0
654
655
654
null
[]
None
null
0
0
0
null
0
null
The function (get_weight_fake_quantize_config) defined within the public class called public.The function start at line 654 and ends at 655. 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
_fake_quantize_per_channel_group
def _fake_quantize_per_channel_group(input: torch.Tensor,scales: torch.Tensor,zero_points: torch.Tensor,quant_min: int,quant_max: int,group_size: int,zero_point_domain: ZeroPointDomain = ZeroPointDomain.INT,) -> torch.Tensor:assert group_size > 1assert input.shape[-1] % group_size == 0assert input.dim() == 2block_size ...
1
23
7
107
1
21
43
21
null
['block_size']
None
null
0
0
0
null
0
null
The function (_fake_quantize_per_channel_group) defined within the public class called public.The function start at line 21 and ends at 43. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [21.0] and does not return any value..
pytorch_ao
public
public
0
0
_fake_quantize_per_token
def _fake_quantize_per_token(input: torch.Tensor,scales: torch.Tensor,zero_points: torch.Tensor,quant_min: int,quant_max: int,) -> torch.Tensor:from torch.ao.quantization.fx._decomposed import _per_token_quant_qparam_dim_check_per_token_quant_qparam_dim_check(input, scales, zero_points)block_size = _get_per_token_block...
1
20
5
101
2
46
66
46
null
['fq', 'block_size']
None
null
0
0
0
null
0
null
The function (_fake_quantize_per_token) defined within the public class called public.The function start at line 46 and ends at 66. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [46.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_qmin_qmax
def _get_qmin_qmax(n_bit: int, symmetric: bool = True):if symmetric:qmin = -(2 ** (n_bit - 1))qmax = 2 ** (n_bit - 1) - 1else:qmin = 0qmax = 2**n_bit - 1return (qmin, qmax)
2
8
2
57
2
69
76
69
null
['qmax', 'qmin']
None
null
0
0
0
null
0
null
The function (_get_qmin_qmax) defined within the public class called public.The function start at line 69 and ends at 76. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [69.0] and does not return any value..
pytorch_ao
public
public
0
0
_log_deprecation_warning
def _log_deprecation_warning(old_api_object: Any):"""Log a helpful deprecation message pointing users to the new QAT API,only once per deprecated class."""warnings.warn("""'%s' is deprecated and will be removed in a future release. Please use the following API instead:base_config = Int8DynamicActivationInt4WeightConfig...
1
24
1
20
0
79
106
79
null
[]
None
null
0
0
0
null
0
null
The function (_log_deprecation_warning) defined within the public class called public.The function start at line 79 and ends at 106. 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
_choose_quant_func_and_quantize_tensor
def _choose_quant_func_and_quantize_tensor(tensor: torch.Tensor, quant_kwargs: QuantizeTensorKwargs) -> torch.Tensor:"""Given a tensor and a kwargs container, chooses a derived dtype (float8, int8, etc) to quantize tensor to, based on the type of quant_kwargsquantizes tensor to the derived dtype chosen in (1)This is ne...
2
18
2
79
0
33
56
33
null
[]
None
null
0
0
0
null
0
null
The function (_choose_quant_func_and_quantize_tensor) defined within the public class called public.The function start at line 33 and ends at 56. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [33.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata: torch.Tensor,scale: torch.Tensor,block_size: Optional[List[int]] = None,mm_config: Optional[Float8MMConfig] = None,act_quant_kwargs: Optional[QuantizeTensorToFloat8Kwargs] = None,kernel_preference: KernelPreference = KernelPreference.AUTO,dtype: Optional[torch.dtype] = None,):shape = qdata.shapek...
1
16
8
110
0
104
119
104
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 104 and ends at 119. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [104.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata: torch.Tensor,scale: torch.Tensor,block_size: Optional[List[int]] = None,mm_config: Optional[Float8MMConfig] = None,act_quant_kwargs: Optional[QuantizeTensorToFloat8Kwargs] = None,kernel_preference: KernelPreference = KernelPreference.AUTO,dtype: Optional[torch.dtype] = None,):super().__init__()...
1
17
8
104
0
121
137
121
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 121 and ends at 137. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):return (f"{self.__class__.__name__}({self.act_quant_kwargs=}, {self.qdata=}, {self.scale=}, "f"{self.block_size=}, {self.mm_config=}, {self.kernel_preference=} "f"{self.shape=}, {self.device=}, {self.dtype=})")
1
6
1
14
0
139
144
139
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 139 and ends at 144. 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
_quantization_type
def _quantization_type(self):return f"{self.act_quant_kwargs=}, {self.block_size=}, {self.mm_config=}, {self.scale.shape=}, {self.kernel_preference=}"
1
2
1
8
0
146
147
146
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 146 and ends at 147. 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
dequantize
def dequantize(self, output_dtype: Optional[torch.dtype] = None) -> torch.Tensor:if output_dtype is None:output_dtype = self.dtypeqdata, scale = self.qdata, self.scalereturn _dequantize_affine_float8(qdata, scale, output_dtype)
2
5
2
50
0
149
154
149
null
[]
None
null
0
0
0
null
0
null
The function (dequantize) defined within the public class called public.The function start at line 149 and ends at 154. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [149.0] and does not return any value..
pytorch_ao
public
public
0
0
from_hp
def from_hp(cls,hp_tensor: torch.Tensor,float8_dtype: torch.dtype = torch.float8_e4m3fn,granularity: FP8Granularity = PerRow(),mm_config: Optional[Float8MMConfig] = None,hp_value_lb: Optional[float] = None,hp_value_ub: Optional[float] = None,kernel_preference: KernelPreference = KernelPreference.AUTO,act_quant_kwargs: ...
13
76
4
362
0
157
244
157
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 157 and ends at 244. It contains 76 lines of code and it has a cyclomatic complexity of 13. It takes 4 parameters, represented as [157.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,)assert isinstance(weight_tensor, Float8Tensor), (f"Don't expect to reach here with an override other than weight currently, {type(input_tensor)} {type(weight_tensor)}")act_quant_kwargs = weight_tens...
12
95
4
501
14
251
359
251
null
['kernel_choice', 'res', 'scaled_mm_config', 'w_data', 'out_shape', 'w_scale', 'inpt_data', 'wq', 'input_scale', 'input_tensor', 'x_scale', 'mm_config', 'xq', 'act_quant_kwargs']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 251 and ends at 359. It contains 95 lines of code and it has a cyclomatic complexity of 12. It takes 4 parameters, represented as [251.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):input_tensor, weight_tensor = (args[0],args[1],)assert isinstance(weight_tensor, Float8Tensor), (f"Don't expect to reach here with an override other than weight currently, {type(input_tensor)} {type(weight_tensor)}")kernel_preference = weight_tensor.kernel_preferenceassert kernel_prefer...
7
46
4
257
10
363
416
363
null
['a_data', 'res', 'kernel_preference', 'b_data', 'a_scale', 'orig_act_size', 'input_tensor', 'orig_out_features', 'b_scale', 'act_quant_kwargs']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 363 and ends at 416. It contains 46 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [363.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):"""Only supports slicing for dim == 1 and dim == 2original tensor shape has dimension (N, K)qdata has dimension (N, K)scale (per row quantization) has dimension: (N,)since qdata has the same dimension as original tensor, we can directly slice thatfor scale, we'll do a slice when dim is ...
5
33
4
223
4
420
472
420
null
['end', 'block_size', 'sliced_data', 'sliced_scale']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 420 and ends at 472. It contains 33 lines of code and it has a cyclomatic complexity of 5. It takes 4 parameters, represented as [420.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):"""Concatenate multiple float8 quantized tensors(scale and qdata has the same rank)If the concatenation dimension is not the same as block_size, then we can just concatenate theqdata and scale directlyIf the concatention dimension is the same as block_size, theoretically we should eithe...
7
33
4
291
8
476
524
476
null
['cat_scale', 'cat_qdata', 'dim', 'scales', 'new', 'block_size', 'tensor_0', 'qdatas']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 476 and ends at 524. It contains 33 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [476.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, dim0, dim1 = argsqdata = self.qdata.transpose(dim0, dim1)scale = self.scale.transpose(dim0, dim1)block_size = self.block_size.copy()block_size[dim0], block_size[dim1] = block_size[dim1], block_size[dim0]new = self.__class__(qdata,scale,block_size,self.mm_config,self.act_quant_kwar...
1
16
4
110
4
528
545
528
null
['qdata', 'new', 'block_size', 'scale']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 528 and ends at 545. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [528.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, size = argsoriginal_shape = self.shapeif len(original_shape) == 3 and len(size) == 2:assert original_shape[-1] == size[-1], (f"Only support reshaping when last dimension matches, requested: reshaping from {original_shape} to {size}")qdata = self.qdata.reshape(*size)scale = self.sc...
11
46
4
353
6
549
595
549
null
['new', 'block_size', 'scale_shape', 'qdata', 'scale', 'original_shape']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 549 and ends at 595. It contains 46 lines of code and it has a cyclomatic complexity of 11. It takes 4 parameters, represented as [549.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, dim = argsassert dim == 0, f"Only dim == 0 is supported, got: {dim}"qdata = self.qdata.squeeze(dim=dim)scale = self.scale.squeeze(dim=dim)block_size = []for i in range(len(qdata.shape)):block_size.append(qdata.shape[i] // scale.shape[i])new = self.__class__(qdata,scale,block_size,...
2
18
4
115
4
599
617
599
null
['qdata', 'new', 'block_size', 'scale']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 599 and ends at 617. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [599.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):old_float8_tensor, dim, index = argsassert dim == 0, f"Float8Tensor aten.select.int with {dim=} is not yet supported"assert len(old_float8_tensor.qdata.shape) == len(old_float8_tensor.scale.shape), ("unsupported")assert len(old_float8_tensor.qdata.shape) == len(old_float8_tensor.block_s...
1
19
4
123
1
621
639
621
null
['new_float8_tensor']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 621 and ends at 639. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [621.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls, qdata, scale, zero_point, meta, block_size, num_bits, shape):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = scale.dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[attr-defined]
1
6
8
59
0
30
35
30
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 30 and ends at 35. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [30.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, qdata, scale, zero_point, meta, block_size, num_bits, shape):super().__init__()self.qdata = qdataself.scale = scaleself.zero_point = zero_pointself.meta = metaself.block_size = block_sizeself.num_bits = num_bits
1
8
8
56
0
37
44
37
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 37 and ends at 44. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [37.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):return f"shape={self.shape}, block_size={self.block_size}, device={self.device}"
1
2
1
8
0
46
47
46
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 46 and ends at 47. 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
from_hp
def from_hp(cls,w: torch.Tensor,block_size: List[int],):from torchao.sparsity.marlin import (const,inject_24,# avoid circular importpack_to_marlin_24,)"""Preprocess the input tensor to be in the correct format for the Marlin sparse kernel.- 1º: the input tensor is transposed since the linear layer keeps the weights in ...
11
79
3
402
0
50
158
50
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 50 and ends at 158. It contains 79 lines of code and it has a cyclomatic complexity of 11. It takes 3 parameters, represented as [50.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):from torchao.ops import marlin_24_gemmfrom torchao.sparsity.marlin import marlin_24_workspaceinput_tensor, weight_tensor, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)assert weight_tensor.qdata.is_contiguous(), "Expected qdata to be contiguous"assert weight_tensor.scale.i...
3
38
4
230
11
165
211
165
null
['out', 'original_shape', 'size_n', 'workspace_24', 'size_k', 'scale', 'num_bits', 'size_m', 'input_2d', 'meta', 'sparse_w_int4']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 165 and ends at 211. It contains 38 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [165.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata,scale_and_zero,block_size,shape,act_pre_scale: Optional[torch.Tensor] = None,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = scale_and_zero.dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[attr-defined]
1
13
6
65
0
64
76
64
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 64 and ends at 76. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [64.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata: torch.Tensor,scale_and_zero: torch.Tensor,block_size: List[int],shape: torch.Size,act_pre_scale: Optional[torch.Tensor] = None,):super().__init__()self.qdata = qdataself.scale_and_zero = scale_and_zeroself.block_size = block_sizeself.act_pre_scale = act_pre_scale
1
13
6
69
0
78
90
78
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 78 and ends at 90. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [78.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):s = f"shape={self.shape}, block_size={self.block_size}, device={self.device}"if self.act_pre_scale is not None:s += f", act_pre_scale.shape={self.act_pre_scale.shape}"return s
2
5
1
23
0
92
96
92
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 92 and ends at 96. 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
from_hp
def from_hp(cls,w: torch.Tensor,block_size: List[int],int4_choose_qparams_algorithm: Int4ChooseQParamsAlgorithm = Int4ChooseQParamsAlgorithm.TINYGEMM,):assert w.ndim == 2 and w.device.type == "cpu", (f"Expecting 2D tensor on CPU, but got: {w.shape} on {w.device.type}")assert len(block_size) == w.ndimassert block_size[0...
4
77
4
341
0
99
186
99
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 99 and ends at 186. It contains 77 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [99.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,)assert input_tensor.device.type == "cpu", (f"For CPU device only but got: {input_tensor.device}")assert isinstance(weight_tensor, Int4OpaqueTensor), (f"Expected weight_tensor to be Int4OpaqueTensor,...
4
37
4
245
9
193
239
193
null
['packed_weight', 'groupsize', 'scale_and_zero', 'orig_act_size', 'input_tensor', 'act_mat', 'y', 'orig_out_features', 'orig_dtype']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 193 and ends at 239. It contains 37 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [193.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata,scale,zero_point,block_size,shape,act_pre_scale: Optional[torch.Tensor] = None,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = scale.dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[attr-defined]
1
14
7
67
0
52
65
52
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 52 and ends at 65. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [52.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata,scale,zero_point,block_size,shape,act_pre_scale: Optional[torch.Tensor] = None,):self.qdata = qdataself.scale = scaleself.zero_point = zero_pointself.block_size = block_sizeself.act_pre_scale = act_pre_scale
1
14
7
52
0
67
80
67
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 67 and ends at 80. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [67.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):s = f"shape={self.shape}, block_size={self.block_size}, device={self.device}"if self.act_pre_scale is not None:s += f", act_pre_scale.shape={self.act_pre_scale.shape}"return s
2
5
1
23
0
82
86
82
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 82 and ends at 86. 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
from_hp
def from_hp(cls,w: torch.Tensor,block_size: List[int],):assert w.ndim == 2 and w.device.type == "xpu", (f"Expecting 2D tensor on XPU, but got: {w.shape} on {w.device.type}")assert len(block_size) == w.ndimassert w.dtype in [torch.float16, torch.bfloat16], (f"Expecting float16 or bfloat16 weight tensor, but got: {w.dtyp...
2
57
3
283
0
89
145
89
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 89 and ends at 145. It contains 57 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [89.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,)assert input_tensor.device.type == "xpu", (f"For XPU device only but got: {input_tensor.device}")assert isinstance(weight_tensor, Int4PlainInt32Tensor), (f"Expected weight_tensor to be Int4PlainInt3...
4
38
4
248
10
152
199
152
null
['packed_weight', 'groupsize', 'zero_point', 'scale', 'input_tensor', 'orig_act_size', 'act_mat', 'y', 'orig_out_features', 'orig_dtype']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 152 and ends at 199. It contains 38 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [152.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata: torch.Tensor,group_scale: torch.Tensor,block_size: List[int],shape: List[int],group_zero: Optional[torch.Tensor] = None,row_scale: Optional[torch.Tensor] = None,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = group_scale.dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_...
1
14
7
94
0
83
96
83
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 83 and ends at 96. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [83.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata: torch.Tensor,group_scale: torch.Tensor,block_size: List[int],shape: List[int],group_zero: Optional[torch.Tensor] = None,row_scale: Optional[torch.Tensor] = None,):super().__init__()# one and only one of group_scale and group_zero should be Noneassert group_zero is None or row_scale is Noneasser...
3
17
7
107
0
98
115
98
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 98 and ends at 115. It contains 17 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [98.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):return f"shape={self.shape}, block_size={self.block_size}, device={self.device}"
1
2
1
8
0
117
118
117
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 117 and ends at 118. 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
from_hp
def from_hp(cls,w: torch.Tensor,block_size: List[int],activation_dtype: torch.dtype = torch.bfloat16,):assert len(block_size) == w.ndim, (f"Expecting the length of block_size to be equal to the dimension of the weight, got {block_size=} and {w.ndim=}")assert all(x == 1 for x in block_size[:-1]), (f"Only per group quant...
8
60
4
310
0
121
188
121
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 121 and ends at 188. It contains 60 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
from_int4_tensor
def from_int4_tensor(cls,tensor: Int4Tensor,):assert isinstance(tensor, Int4Tensor), (f"Only conversion from Int4Tensor is supportd, got: {tensor}")# currently Int4Tensor only supports weight only, we can extend it to fp8-int4 a bit laterqdata = tensor.qdatagroup_scale = tensor.scalegroup_zero = tensor.zero_pointblock_...
1
26
2
114
0
191
220
191
null
[]
None
null
0
0
0
null
0
null
The function (from_int4_tensor) defined within the public class called public.The function start at line 191 and ends at 220. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [191.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,)orig_input_size = input_tensor.size()orig_out_features = weight_tensor.shape[-2]wq = weight_tensor.qdata.contiguous()group_scale = weight_tensor.group_scale.contiguous()if weight_tensor.group_zero i...
4
26
4
187
7
227
256
227
null
['res', 'group_zero', 'group_scale', 'wq', 'row_scale', 'orig_out_features', 'orig_input_size']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 227 and ends at 256. It contains 26 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [227.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):input_tensor, weight_tensor = (args[0],args[1],)orig_input_size = input_tensor.size()orig_out_features = weight_tensor.shape[-2]wq = weight_tensor.qdata.contiguous()group_scale = weight_tensor.group_scale.contiguous()if weight_tensor.group_zero is not None:# bfloat16 activationgroup_zer...
3
28
4
238
7
260
292
260
null
['res', 'group_zero', 'group_scale', 'wq', 'row_scale', 'orig_out_features', 'orig_input_size']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 260 and ends at 292. It contains 28 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [260.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,block_size: List[int],shape: torch.Size,act_pre_scale: Optional[torch.Tensor] = None,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = scale.dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, sh...
1
14
7
88
0
54
67
54
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 54 and ends at 67. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,block_size: List[int],shape: torch.Size,act_pre_scale: Optional[torch.Tensor] = None,):super().__init__()self.qdata = qdataself.scale = scaleself.zero_point = zero_pointself.block_size = block_sizeself.act_pre_scale = act_pre_scale
1
15
7
80
0
69
83
69
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 69 and ends at 83. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [69.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):s = f"shape={self.shape}, block_size={self.block_size}, device={self.device}"if self.act_pre_scale is not None:s += f", act_pre_scale.shape={self.act_pre_scale.shape}"return s
2
5
1
23
0
85
89
85
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 85 and ends at 89. 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
from_hp
def from_hp(cls,w: torch.Tensor,block_size: List[int],):assert len(block_size) == w.ndim, (f"Expecting the length of block_size to be equal to the dimension of the weight, got {block_size=} and {w.ndim=}")if int4_row_quantize_zp is None:raise ImportError("Requires fbgemm-gpu-genai >= 1.2.0")assert all(x == 1 for x in b...
7
35
3
229
0
92
131
92
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 92 and ends at 131. It contains 35 lines of code and it has a cyclomatic complexity of 7. It takes 3 parameters, represented as [92.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,)assert isinstance(weight_tensor, Int4Tensor)assert weight_tensor.qdata.is_contiguous(), "Expected qdata to be contiguous"assert weight_tensor.scale.is_contiguous(), "Expected scale to be contiguous"...
4
27
4
184
4
138
168
138
null
['res', 'orig_act_size', 'input_tensor', 'orig_out_features']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 138 and ends at 168. It contains 27 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [138.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):input_tensor, weight_tensor = (args[0],args[1],)assert weight_tensor.qdata.is_contiguous(), "Expected qdata to be contiguous"assert weight_tensor.scale.is_contiguous(), "Expected scale to be contiguous"assert weight_tensor.zero_point.is_contiguous(), ("Expected zero_point to be contiguo...
1
20
4
118
3
172
192
172
null
['res', 'orig_act_size', 'orig_out_features']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 172 and ends at 192. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [172.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):"""Only supports slicing for dim == 1 and dim == 2qdata has dimension: (N, K/2)scale and zero_point has dimension: (K/groups, N)dim, start, end, step are args that's referring to the original tensor shapewhich is (N, K), and we need to map that to the transformed weight shape of qdata,s...
6
53
4
339
16
196
274
196
null
['end', 'pw_ratio', 'end_pw', 'end_sz', 'zero_point', 'start_pw', 'start_sz', 'sz_ratio', 'new_shape', 'qdata', 'scale', 'new', 'sz_dim', 'sz_len', 'pw_len', 'data_len']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 196 and ends at 274. It contains 53 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [196.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):"""Concatenate multiple Int4 quantized tensorsFor Int4Tensor, we need to concatenate qdata, scale, and zero_point tensors.The concatenation behavior depends on the dimension and block_size configuration.If the concatenation dimension is not the same as the packed dimension, then we can ...
10
46
4
361
11
278
351
278
null
['cat_scale', 'cat_zero_point', 'cat_qdata', 'dim', 'scales', 'new', 'new_shape', 'tensor_0', 'sz_dim', 'qdatas', 'zero_points']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 278 and ends at 351. It contains 46 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [278.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, dim0, dim1 = args# Transpose the quantized dataqdata = self.qdata.transpose(dim0, dim1).contiguous()if self.scale.ndim == 3:# since scale/zero_point dimension order is different# (B, K/group_size, N), we'll need to remap the dimremapped_dim0 = dim0if dim0 in [1, 2]:remapped_dim0 =...
4
31
4
233
8
355
396
355
null
['remapped_dim1', 'zero_point', 'remapped_dim0', 'new', 'block_size', 'new_shape', 'qdata', 'scale']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 355 and ends at 396. It contains 31 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [355.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, size = argsoriginal_shape = self.shapeoriginal_packing_dim = Nonefor i in range(len(original_shape)):if original_shape[i] == (self.qdata.shape[i] * 2):original_packing_dim = iassert original_packing_dim is not None, "Didn't find a packing_dim"if len(original_shape) == 3 and len(si...
17
69
4
516
11
400
485
400
null
['packing_dim', 'zero_point', 'shape', 'new', 'block_size', 'qdata_shape', 'original_packing_dim', 'qdata', 'scale', 'sz_shape', 'original_shape']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 400 and ends at 485. It contains 69 lines of code and it has a cyclomatic complexity of 17. It takes 4 parameters, represented as [400.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self, dim = args# Squeeze qdataqdata = self.qdata.squeeze(dim=dim)# For scale and zero_point, we need to squeeze based on the tensor layout# Int4Tensor has scale and zero_point with shape (K/group_size, N) for 2D or (B, N, K/group_size) for 3Dif self.qdata.ndim == 2:# 2D case# qdata is ...
4
25
4
164
7
489
527
489
null
['new_block_size', 'zero_point', 'new', 'new_shape', 'qdata', 'scale', 'sz_dim']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 489 and ends at 527. It contains 25 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [489.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,qdata: torch.Tensor,scale_and_zero: torch.Tensor,block_size: List[int],shape: torch.Size,act_pre_scale: Optional[torch.Tensor] = None,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = torch.bfloat16# This tensor subclass only supports bfloat16kwargs["requires_grad"] = Falsereturn torch.Tenso...
1
13
6
82
0
63
75
63
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 63 and ends at 75. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [63.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,qdata: torch.Tensor,scale_and_zero: torch.Tensor,block_size: List[int],shape: torch.Size,act_pre_scale: Optional[torch.Tensor] = None,):self.qdata = qdataself.scale_and_zero = scale_and_zeroself.block_size = block_sizeself.act_pre_scale = act_pre_scale
1
12
6
62
0
77
88
77
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 77 and ends at 88. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [77.0] and does not return any value..
pytorch_ao
public
public
0
0
_quantization_type
def _quantization_type(self):s = f"shape={self.shape}, block_size={self.block_size}, device={self.device}"if self.act_pre_scale is not None:s += f", act_pre_scale.shape={self.act_pre_scale.shape}"return s
2
5
1
23
0
90
94
90
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 90 and ends at 94. 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
from_hp.quant_2d
def quant_2d(int_data_2d):int_data_2d = (int_data_2d[::, ::2] << 4 | int_data_2d[::, 1::2]).to(torch.uint8)return torch.ops.aten._convert_weight_to_int4pack(int_data_2d.contiguous(), inner_k_tiles)
1
7
1
52
0
197
203
197
null
[]
None
null
0
0
0
null
0
null
The function (from_hp.quant_2d) defined within the public class called public.The function start at line 197 and ends at 203. 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
from_hp
def from_hp(cls,hp_tensor: torch.Tensor,block_size: List[int],int4_choose_qparams_algorithm: Int4ChooseQParamsAlgorithm = Int4ChooseQParamsAlgorithm.TINYGEMM,):assert len(block_size) == hp_tensor.ndim, (f"Expecting the length of block_size to be equal to the dimension of the weight, got {block_size=} and {hp_tensor.ndi...
8
103
4
553
0
97
235
97
null
[]
None
null
0
0
0
null
0
null
The function (from_hp) defined within the public class called public.The function start at line 97 and ends at 235. It contains 103 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [97.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,)assert weight_tensor.qdata.is_contiguous(), "Expected qdata to be contiguous"assert weight_tensor.scale_and_zero.is_contiguous(), ("Expected scale_and_zero to be contiguous")assert weight_tensor.blo...
5
40
4
303
11
242
296
242
null
['groupsize', 'scale_and_zero', 'qdata', 'orig_act_size', 'input_tensor', 'act_mat', 'y', 'orig_out_features', 'pad_size', 'original_shape', 'orig_dtype']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 242 and ends at 296. It contains 40 lines of code and it has a cyclomatic complexity of 5. It takes 4 parameters, represented as [242.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, _types, args, _kwargs):"""Slice operation for tensor core tiled packed tensor"""self, dim, start, end, step = fill_defaults(args, 5, [0, None, None, 1])cur_shape = self.shapeassert len(cur_shape) == 2assert self.qdata.dim() == 4# qdata has shape [n/8, k/(inner_k_tiles*16), 32, inner_k_tiles/2]n_by_8, k_by_i...
4
47
4
297
14
300
359
300
null
['pw_ratio', 'end_pw', 'end_sz', 'start_sz', 'new_shape', 'sz_ratio', 'scale_and_zero', 'qdata', 'block_size', 'pw_len', 'sz_len', 'start_pw', 'cur_shape', 'data_len']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 300 and ends at 359. It contains 47 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [300.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_kernel_library_loaded
def _is_kernel_library_loaded():loaded = Falsetry:torch.ops.torchao._pack_8bit_act_4bit_weightloaded = Trueexcept AttributeError:passreturn loaded
2
8
0
25
1
33
40
33
null
['loaded']
None
null
0
0
0
null
0
null
The function (_is_kernel_library_loaded) defined within the public class called public.The function start at line 33 and ends at 40. It contains 8 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_weights,bit_width,block_size,shape,dtype,packed_weights_has_zeros,packed_weights_has_bias,intx_packing_format,):kwargs = {}kwargs["device"] = packed_weights.devicekwargs["dtype"] = dtypekwargs["requires_grad"] = Falsereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[a...
1
16
9
60
0
71
86
71
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 71 and ends at 86. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [71.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_zeros,packed_weights_has_bias,intx_packing_format,):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_...
1
19
9
70
0
88
106
88
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 88 and ends at 106. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [88.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} intx_packing_format={self.intx_packing_format}"
1
2
1
8
0
108
109
108
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 108 and ends at 109. 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
111
112
111
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 111 and ends at 112. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [111.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,intx_packing_format: IntxPackingFormat = IntxPackingFormat.OPAQUE_TORCHAO_AUTO,):"""Constructs a IntxOpaqueTensor from an IntxUnpackedToInt8Tensor.If bias is passed, bias is packed into the tensor.The intx_p...
14
109
4
582
0
115
243
115
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 115 and ends at 243. It contains 109 lines of code and it has a cyclomatic complexity of 14. It takes 4 parameters, represented as [115.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_impl_2d_aten
def _linear_impl_2d_aten(input_tensor, weight_tensor):assert isinstance(weight_tensor, IntxOpaqueTensor)assert weight_tensor.intx_packing_format == IntxPackingFormat.OPAQUE_ATEN_KLEIDIAIassert input_tensor.dim() == 2assert weight_tensor.dim() == 2assert weight_tensor.block_size[0] == 1assert weight_tensor.bit_width == ...
1
15
2
103
2
249
266
249
null
['packed_weights', 'group_size']
None
null
0
0
0
null
0
null
The function (_linear_impl_2d_aten) defined within the public class called public.The function start at line 249 and ends at 266. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [249.0] and does not return any value..