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 | device_mesh_1d | def device_mesh_1d() -> DeviceMesh:"""Fixture for setting up and tearing down the distributed environmentfor the entire test module."""rank = int(os.environ["RANK"])world_size = int(os.environ["WORLD_SIZE"])if not dist.is_initialized():dist.init_process_group("nccl", rank=rank, world_size=world_size)device_mesh = init_... | 2 | 10 | 0 | 83 | 3 | 76 | 92 | 76 | null | ['device_mesh', 'world_size', 'rank'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (device_mesh_1d) defined within the public class called public.The function start at line 76 and ends at 92. It contains 10 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_moe_training_tp.moe_module_filter_fn | def moe_module_filter_fn(mod: nn.Module, cur_fqn: str) -> bool:for target_fqn in target_fqns:if target_fqn in cur_fqn:return Truereturn False | 3 | 5 | 2 | 29 | 0 | 188 | 192 | 188 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_moe_training_tp.moe_module_filter_fn) defined within the public class called public.The function start at line 188 and ends at 192. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [188.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_moe_training_tp | def test_moe_training_tp(target_fqns: list[str],compile: bool,recipe_config: dict,device_mesh_1d: DeviceMesh,):(recipe,group_alignment_size,min_out_sqnr,min_input_grad_sqnr,min_param_grad_sqnr,) = (recipe_config["recipe"],recipe_config["group_alignment_size"],recipe_config["min_out_sqnr"],recipe_config["min_input_grad_... | 8 | 105 | 4 | 625 | 16 | 122 | 269 | 122 | null | ['out', 'config', 'ref_x', 'out_loss', 'ref_loss', 'device', 'init_std', 'model', 'ref_model', 'x', 'ref_out', 'input_grad_sqnr', 'out_sqnr', 'labels', 'param_grad_sqnr', 'model_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_moe_training_tp) defined within the public class called public.The function start at line 122 and ends at 269. It contains 105 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [122.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_moe_ep_tp | def apply_moe_ep_tp(model: nn.Module,tp_mesh: DeviceMesh | None,ep_mesh: DeviceMesh | None,ep_tp_mesh: DeviceMesh | None,):# Modified version of moe parallelization from https://github.com/pytorch/torchtitan/pull/1324/# that supports single MoE layer independent of a transformer.if tp_mesh is not None:moe_layer_plan = ... | 4 | 38 | 4 | 180 | 3 | 272 | 320 | 272 | null | ['moe_layer_plan', 'experts_plan', 'experts_mesh'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_moe_ep_tp) defined within the public class called public.The function start at line 272 and ends at 320. It contains 38 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [272.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_moe_training.moe_module_filter_fn | def moe_module_filter_fn(mod: nn.Module, cur_fqn: str) -> bool:for target_fqn in target_fqns:if target_fqn in cur_fqn:return Truereturn False | 3 | 5 | 2 | 29 | 0 | 115 | 119 | 115 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_moe_training.moe_module_filter_fn) defined within the public class called public.The function start at line 115 and ends at 119. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [115.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_moe_training | def test_moe_training(target_fqns: list[str], compile: bool, recipe_config: dict):(recipe,group_alignment_size,min_out_sqnr,min_input_grad_sqnr,min_param_grad_sqnr,) = (recipe_config["recipe"],recipe_config["group_alignment_size"],recipe_config["min_out_sqnr"],recipe_config["min_input_grad_sqnr"],recipe_config["min_par... | 8 | 77 | 3 | 477 | 16 | 59 | 172 | 59 | null | ['out', 'config', 'ref_x', 'out_loss', 'ref_loss', 'device', 'init_std', 'model', 'ref_model', 'x', 'ref_out', 'input_grad_sqnr', 'out_sqnr', 'labels', 'param_grad_sqnr', 'model_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_moe_training) defined within the public class called public.The function start at line 59 and ends at 172. It contains 77 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [59.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _validate_model_conversion._recursive_validate | def _recursive_validate(module: nn.Module,cur_fqn: str,):is_allowed_module = any([target_fqn in cur_fqn for target_fqn in target_fqns])# check current module paramsfor param_name, param in module.named_parameters(recurse=False):is_converted_type = isinstance(param, ScaledGroupedMMTensor)if is_converted_type:assert is_a... | 7 | 18 | 2 | 97 | 0 | 11 | 32 | 11 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_validate_model_conversion._recursive_validate) defined within the public class called public.The function start at line 11 and ends at 32. It contains 18 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [11.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _validate_model_conversion | def _validate_model_conversion(root_module: nn.Module,target_fqns: list[str],):def _recursive_validate(module: nn.Module,cur_fqn: str,):is_allowed_module = any([target_fqn in cur_fqn for target_fqn in target_fqns])# check current module paramsfor param_name, param in module.named_parameters(recurse=False):is_converted_... | 1 | 6 | 2 | 25 | 3 | 7 | 34 | 7 | null | ['child_fqn', 'is_converted_type', 'is_allowed_module'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_validate_model_conversion) defined within the public class called public.The function start at line 7 and ends at 34. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [7.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | generate_split_sizes | def generate_split_sizes(K: int, N: int, device: str = "cpu") -> torch.Tensor:"""Generates a tensor of K random non-negative integers that sum to N.Used for testing mxfp8_all_to_all_v implementation."""if K <= 0:raise ValueError("K must be a positive integer.")if N < 0:raise ValueError("N must be a non-negative integer... | 4 | 14 | 3 | 160 | 4 | 37 | 64 | 37 | null | ['result', 'boundaries', 'sorted_boundaries', 'dividers'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (generate_split_sizes) defined within the public class called public.The function start at line 37 and ends at 64. It contains 14 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [37.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | setUp | def setUp(self) -> None:super().setUp()self._spawn_processes() | 1 | 3 | 1 | 19 | 0 | 35 | 37 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (setUp) defined within the public class called public.The function start at line 35 and ends at 37. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | world_size | def world_size(self) -> int:return 4 | 1 | 2 | 1 | 9 | 0 | 40 | 41 | 40 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (world_size) defined within the public class called public.The function start at line 40 and ends at 41. 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 | device | def device(self) -> torch.device:return torch.device(f"cuda:{self.rank}") | 1 | 2 | 1 | 17 | 0 | 44 | 45 | 44 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (device) defined within the public class called public.The function start at line 44 and ends at 45. 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_process | def _init_process(self):torch.cuda.set_device(self.device)store = dist.FileStore(self.file_name, self.world_size)dist.init_process_group(backend="nccl",world_size=self.world_size,rank=self.rank,store=store,)torch.manual_seed(42 + self.rank) | 1 | 10 | 1 | 64 | 0 | 47 | 56 | 47 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_init_process) defined within the public class called public.The function start at line 47 and ends at 56. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _init_device | def _init_device(self):symm_mem.set_backend("NVSHMEM") | 1 | 2 | 1 | 11 | 0 | 58 | 59 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_init_device) defined within the public class called public.The function start at line 58 and ends at 59. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_a2a_fwd_bwd | def test_a2a_fwd_bwd(self):self._init_process()try:torch.manual_seed(42 + self.rank)self._init_device()group_name = dist.group.WORLD.group_namesymm_mem.enable_symm_mem_for_group(group_name)tokens_per_ep_rank = 8192dim = 2048input_tensor = torch.randn(tokens_per_ep_rank,dim,device=self.device,dtype=torch.float32,require... | 2 | 62 | 1 | 312 | 0 | 61 | 145 | 61 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_a2a_fwd_bwd) defined within the public class called public.The function start at line 61 and ends at 145. It contains 62 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 | setUp | def setUp(self) -> None:super().setUp()self._spawn_processes() | 1 | 3 | 1 | 19 | 0 | 150 | 152 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (setUp) defined within the public class called public.The function start at line 150 and ends at 152. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | world_size | def world_size(self) -> int:return 4 | 1 | 2 | 1 | 9 | 0 | 155 | 156 | 40 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (world_size) defined within the public class called public.The function start at line 155 and ends at 156. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | device | def device(self) -> torch.device:return torch.device(f"cuda:{self.rank}") | 1 | 2 | 1 | 17 | 0 | 159 | 160 | 44 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (device) defined within the public class called public.The function start at line 159 and ends at 160. 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_process | def _init_process(self):torch.cuda.set_device(self.device)store = dist.FileStore(self.file_name, self.world_size)dist.init_process_group(backend="nccl",world_size=self.world_size,rank=self.rank,store=store,)torch.manual_seed(42 + self.rank) | 1 | 10 | 1 | 64 | 0 | 162 | 171 | 47 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_init_process) defined within the public class called public.The function start at line 162 and ends at 171. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _init_device | def _init_device(self):symm_mem.set_backend("NVSHMEM") | 1 | 2 | 1 | 11 | 0 | 173 | 174 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_init_device) defined within the public class called public.The function start at line 173 and ends at 174. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_a2a_fwd_bwd | def test_a2a_fwd_bwd(self):self._init_process()try:torch.manual_seed(42 + self.rank)self._init_device()group_name = dist.group.WORLD.group_namesymm_mem.enable_symm_mem_for_group(group_name)tokens_per_ep_rank = 8192dim = 2048input_tensor = torch.randn(tokens_per_ep_rank,dim,device=self.device,dtype=torch.float32,require... | 2 | 70 | 1 | 361 | 0 | 176 | 266 | 176 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_a2a_fwd_bwd) defined within the public class called public.The function start at line 176 and ends at 266. It contains 70 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 | run_around_tests | def run_around_tests():# 1. before test - set up (currently do nothing)# 2. run testyield# 3. after test - teardowntorch._dynamo.reset() | 1 | 3 | 0 | 12 | 0 | 39 | 44 | 39 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_around_tests) defined within the public class called public.The function start at line 39 and ends at 44. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_inference_workflow_mx | def test_inference_workflow_mx(elem_dtype, bias: bool, compile: bool, emulate: bool):"""Smoke test for inference compile"""# TODO(future): figure out why these CUDA capability conditions are not properly# applied when inside `pytest.mark.skipif` for this testif elem_dtype in (torch.float8_e4m3fn, torch.float8_e5m2):if ... | 14 | 40 | 4 | 303 | 10 | 59 | 112 | 59 | null | ['kernel_choice', 'config', 'm_mx', '_', 'm', 'y_mx', 'x', 'sqnr', 'y_ref', 'SQNR_THRESHOLD'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_inference_workflow_mx) defined within the public class called public.The function start at line 59 and ends at 112. It contains 40 lines of code and it has a cyclomatic complexity of 14. It takes 4 parameters, represented as [59.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_inference_workflow_nvfp4 | def test_inference_workflow_nvfp4(bias: bool,compile: bool,mm_config: NVFP4MMConfig,inpt_dtype: torch.dtype,use_triton_kernel: bool,use_dynamic_per_tensor_scale: bool,shapes: tuple,):"""Test NVFP4 recipe with scale_dtype=float8_e4m3fn and block_size=16Tests both DYNAMIC and WEIGHT_ONLY mm_config modes"""# DYNAMIC mode ... | 9 | 38 | 7 | 239 | 8 | 142 | 192 | 142 | null | ['config', 'm_mx', 'm', 'y_mx', 'x', 'sqnr', 'y_ref', 'SQNR_THRESHOLD'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_inference_workflow_nvfp4) defined within the public class called public.The function start at line 142 and ends at 192. It contains 38 lines of code and it has a cyclomatic complexity of 9. It takes 7 parameters, represented as [142.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_slice_and_copy_similar_to_vllm | def test_slice_and_copy_similar_to_vllm(self):config = MXFPInferenceConfig(activation_dtype=torch.float8_e4m3fn,weight_dtype=torch.float8_e4m3fn,gemm_kernel_choice=MXGemmKernelChoice.EMULATED,)self._test_slice_and_copy_similar_to_vllm(config) | 1 | 7 | 1 | 34 | 0 | 201 | 207 | 201 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_slice_and_copy_similar_to_vllm) defined within the public class called public.The function start at line 201 and ends at 207. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_narrow_similar_to_vllm | def test_narrow_similar_to_vllm(self):config = MXFPInferenceConfig(activation_dtype=torch.float8_e4m3fn,weight_dtype=torch.float8_e4m3fn,gemm_kernel_choice=MXGemmKernelChoice.EMULATED,)self._test_narrow_similar_to_vllm(config) | 1 | 7 | 1 | 34 | 0 | 214 | 220 | 214 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_narrow_similar_to_vllm) defined within the public class called public.The function start at line 214 and ends at 220. 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 | to_mx_dim1_reference | def to_mx_dim1_reference(x_hp, block_size, scaling_mode):x_hp = x_hp.t().contiguous()scale_d1, data_d1 = to_mx(x_hp, torch.float8_e4m3fn, block_size, scaling_mode=scaling_mode)return data_d1.t(), scale_d1 | 1 | 6 | 3 | 46 | 1 | 59 | 64 | 59 | null | ['x_hp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_mx_dim1_reference) defined within the public class called public.The function start at line 59 and ends at 64. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [59.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp32 | def test_fp32():dtype = torch.floatinteresting_values = dtype_to_interesting_values[dtype]for fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, _notes in interesting_values:_assert_equals(fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, dtype) | 2 | 5 | 0 | 40 | 2 | 70 | 74 | 70 | null | ['interesting_values', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp32) defined within the public class called public.The function start at line 70 and ends at 74. 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 | test_bf16 | def test_bf16():dtype = torch.bfloat16interesting_values = dtype_to_interesting_values[dtype]for fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, _notes in interesting_values:_assert_equals(fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, dtype) | 2 | 5 | 0 | 40 | 2 | 80 | 84 | 80 | null | ['interesting_values', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_bf16) defined within the public class called public.The function start at line 80 and ends at 84. 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 | test_fp16 | def test_fp16():dtype = torch.float16interesting_values = dtype_to_interesting_values[dtype]for fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, _notes in interesting_values:_assert_equals(fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, dtype) | 2 | 5 | 0 | 40 | 2 | 87 | 91 | 87 | null | ['interesting_values', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp16) defined within the public class called public.The function start at line 87 and ends at 91. 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 | test_float8_e4m3fn | def test_float8_e4m3fn():dtype = torch.float8_e4m3fninteresting_values = dtype_to_interesting_values[dtype]for fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, _notes in interesting_values:_assert_equals(fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, dtype) | 2 | 5 | 0 | 40 | 2 | 94 | 98 | 94 | null | ['interesting_values', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_float8_e4m3fn) defined within the public class called public.The function start at line 94 and ends at 98. 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 | test_float8_e5m2 | def test_float8_e5m2():dtype = torch.float8_e5m2interesting_values = dtype_to_interesting_values[dtype]for fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, _notes in interesting_values:_assert_equals(fp_ref, s_enc_ref, e_enc_ref, m_enc_ref, dtype) | 2 | 5 | 0 | 40 | 2 | 101 | 105 | 101 | null | ['interesting_values', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_float8_e5m2) defined within the public class called public.The function start at line 101 and ends at 105. 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 | _sem_enc_to_fp32_val | def _sem_enc_to_fp32_val(s_enc, e_enc, m_enc, is_zero, is_denorm, exp_bias):s_i = 1.0 if s_enc == "0" else -1.0if is_zero:e_i = 0m_f = 0.0elif is_denorm:e_i = int(e_enc, 2) - exp_bias + 1m_f = 0.0cur_pow_of_two = -1for m_bit in m_enc:m_f += int(m_bit, 2) * pow(2, cur_pow_of_two)cur_pow_of_two -= 1else:e_i = int(e_enc, ... | 6 | 21 | 6 | 144 | 5 | 108 | 128 | 108 | null | ['cur_pow_of_two', 's_i', 'e_i', 'fp32', 'm_f'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_sem_enc_to_fp32_val) defined within the public class called public.The function start at line 108 and ends at 128. It contains 21 lines of code and it has a cyclomatic complexity of 6. It takes 6 parameters, represented as [108.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_float4_e2m1_table | def test_float4_e2m1_table():for (fp32_ref,_formula,s_enc,e_enc,m_enc,_label,) in float4_e2m1_interesting_values:is_zero = e_enc == "00" and m_enc == "0"# normal vs denormalis_denorm = e_enc == "00" and m_enc == "1"# get exponent and mantissaexp_bias = F4_E2M1_EXP_BIASfp32 = _sem_enc_to_fp32_val(s_enc, e_enc, m_enc, is... | 4 | 14 | 0 | 70 | 4 | 131 | 146 | 131 | null | ['is_zero', 'fp32', 'is_denorm', 'exp_bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_float4_e2m1_table) defined within the public class called public.The function start at line 131 and ends at 146. It contains 14 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_float6_e3m2_table | def test_float6_e3m2_table():for (fp32_ref,_formula,s_enc,e_enc,m_enc,_label,) in float6_e3m2_interesting_values:is_zero = e_enc == "000" and m_enc == "00"# normal vs denormalis_denorm = e_enc == "000" and m_enc != "00"# get exponent and mantissaexp_bias = F6_E3M2_EXP_BIASfp32 = _sem_enc_to_fp32_val(s_enc, e_enc, m_enc... | 4 | 14 | 0 | 70 | 4 | 149 | 164 | 149 | null | ['is_zero', 'fp32', 'is_denorm', 'exp_bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_float6_e3m2_table) defined within the public class called public.The function start at line 149 and ends at 164. It contains 14 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_float6_e2m3_table | def test_float6_e2m3_table():for (fp32_ref,_formula,s_enc,e_enc,m_enc,_label,) in float6_e2m3_interesting_values:is_zero = e_enc == "00" and m_enc == "000"# normal vs denormalis_denorm = e_enc == "00" and m_enc != "000"# get exponent and mantissaexp_bias = F6_E2M3_EXP_BIASfp32 = _sem_enc_to_fp32_val(s_enc, e_enc, m_enc... | 4 | 14 | 0 | 70 | 4 | 167 | 182 | 167 | null | ['is_zero', 'fp32', 'is_denorm', 'exp_bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_float6_e2m3_table) defined within the public class called public.The function start at line 167 and ends at 182. It contains 14 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_fp4_case | def _test_fp4_case(f32_val, f32_val_ref, f4_enc_ref):# 1. verify that a fp32 value gets quantized to correct fp4 encoding# TODO test on cudaf4_unpacked = f32_to_f4_unpacked(torch.tensor(f32_val))s_enc, e_enc, m_enc = get_sem_bits(f4_unpacked, bitwidth=4)assert s_enc + e_enc + m_enc == f4_enc_ref# 2. verify that fp4 val... | 1 | 6 | 3 | 56 | 2 | 197 | 206 | 197 | null | ['f32_dequantized', 'f4_unpacked'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_fp4_case) defined within the public class called public.The function start at line 197 and ends at 206. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [197.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_fp4_cases | def _test_fp4_cases(cases):# test the exp and mantissa with both values of the sign bitfor s_enc in "0", "1":s_i = 1.0 if s_enc == "0" else -1.0for val, val_ref, em_enc in cases:_test_fp4_case(s_i * val, s_i * val_ref, s_enc + em_enc) | 4 | 5 | 1 | 49 | 1 | 209 | 214 | 209 | null | ['s_i'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_fp4_cases) defined within the public class called public.The function start at line 209 and ends at 214. It contains 5 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_0_0 | def test_fp4_0_0():cases = [(0.25, 0.0, "000"),# tie to even(0.1, 0.0, "000"),(0.0, 0.0, "000"),# note: -0.1 is tested in the negative zero test]_test_fp4_cases(cases) | 1 | 7 | 0 | 48 | 1 | 240 | 247 | 240 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_0_0) defined within the public class called public.The function start at line 240 and ends at 247. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_0_5 | def test_fp4_0_5():cases = [(0.6, 0.5, "001"),(0.5, 0.5, "001"),(0.4, 0.5, "001"),]_test_fp4_cases(cases) | 1 | 7 | 0 | 48 | 1 | 250 | 256 | 250 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_0_5) defined within the public class called public.The function start at line 250 and ends at 256. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_1_0 | def test_fp4_1_0():cases = [(1.25, 1.0, "010"),# tie to even(1.1, 1.0, "010"),(1.0, 1.0, "010"),(0.9, 1.0, "010"),(0.75, 1.0, "010"),# tie to even]_test_fp4_cases(cases) | 1 | 9 | 0 | 72 | 1 | 259 | 267 | 259 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_1_0) defined within the public class called public.The function start at line 259 and ends at 267. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_1_5 | def test_fp4_1_5():cases = [(1.6, 1.5, "011"),(1.5, 1.5, "011"),(1.4, 1.5, "011"),]_test_fp4_cases(cases) | 1 | 7 | 0 | 48 | 1 | 270 | 276 | 270 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_1_5) defined within the public class called public.The function start at line 270 and ends at 276. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_2_0 | def test_fp4_2_0():cases = [(2.5, 2.0, "100"),# tie to even(2.1, 2.0, "100"),(2.0, 2.0, "100"),(1.9, 2.0, "100"),(1.75, 2.0, "100"),# tie to even]_test_fp4_cases(cases) | 1 | 9 | 0 | 72 | 1 | 279 | 287 | 279 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_2_0) defined within the public class called public.The function start at line 279 and ends at 287. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_3_0 | def test_fp4_3_0():cases = [(3.1, 3.0, "101"),(3.0, 3.0, "101"),(2.9, 3.0, "101"),]_test_fp4_cases(cases) | 1 | 7 | 0 | 48 | 1 | 290 | 296 | 290 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_3_0) defined within the public class called public.The function start at line 290 and ends at 296. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_4_0 | def test_fp4_4_0():cases = [(5.0, 4.0, "110"),# tie to even(4.1, 4.0, "110"),(4.0, 4.0, "110"),(3.9, 4.0, "110"),(3.5, 4.0, "110"),# tie to even]_test_fp4_cases(cases) | 1 | 9 | 0 | 72 | 1 | 299 | 307 | 299 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_4_0) defined within the public class called public.The function start at line 299 and ends at 307. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_6_0 | def test_fp4_6_0():cases = [(6.1, 6.0, "111"),(6.0, 6.0, "111"),(5.9, 6.0, "111"),]_test_fp4_cases(cases) | 1 | 7 | 0 | 48 | 1 | 310 | 316 | 310 | null | ['cases'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_6_0) defined within the public class called public.The function start at line 310 and ends at 316. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp4_pack_unpack | def test_fp4_pack_unpack():orig_vals = torch.Tensor([[0.0, 0.5, 4.0, -0.0], [-0.0, 1.0, -6.0, 3.0]])orig_vals_f4_unpacked = f32_to_f4_unpacked(orig_vals)orig_vals_f4_packed = pack_uint4(orig_vals_f4_unpacked)assert orig_vals_f4_packed.numel() == (orig_vals.numel() / 2)orig_vals_f4_packed_unpacked = unpack_uint4(orig_va... | 1 | 8 | 0 | 100 | 5 | 319 | 326 | 319 | null | ['orig_vals', 'orig_vals_dq', 'orig_vals_f4_packed', 'orig_vals_f4_unpacked', 'orig_vals_f4_packed_unpacked'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp4_pack_unpack) defined within the public class called public.The function start at line 319 and ends at 326. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp6_values | def test_fp6_values(dtype_name):"""The fp6 dtypes have 2**6 = 64 unique values each. The testbelow tests the f32 -> f6 and f6 -> f32 cast for each value.TODO(future PR): also verify rounding tie-to-even works properly."""for i in range(2**6):t = torch.tensor(i, dtype=torch.uint8)bits = get_bits(t.to(torch.int8))# go fr... | 8 | 28 | 1 | 235 | 5 | 330 | 371 | 330 | null | ['t', 'f32_ref', 'bits', 'f6', 'f32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp6_values) defined within the public class called public.The function start at line 330 and ends at 371. It contains 28 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 | test_fp6_e3m2_rounding | def test_fp6_e3m2_rounding(f32_val, f6_e3m2_enc, device):f6_e3m2_unpacked = f32_to_f6_e3m2_unpacked(torch.tensor(f32_val, device=device))assert f6_e3m2_unpacked.item() == f6_e3m2_encf6_e3m2_unpacked = f32_to_f6_e3m2_unpacked(torch.tensor(-f32_val, device=device))assert f6_e3m2_unpacked.item() == (f6_e3m2_enc | 0b100000... | 1 | 5 | 3 | 60 | 1 | 396 | 401 | 396 | null | ['f6_e3m2_unpacked'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp6_e3m2_rounding) defined within the public class called public.The function start at line 396 and ends at 401. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [396.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp6_e2m3_pack_unpack | def test_fp6_e2m3_pack_unpack():orig_vals = torch.Tensor([[0.0, 0.5, 7.5, -0.0], [-0.875, 1.0, -6.0, 0.125]]).to("cuda")orig_vals_f6_unpacked = f32_to_f6_e2m3_unpacked(orig_vals)orig_vals_f6_packed = pack_uint6(orig_vals_f6_unpacked)assert orig_vals_f6_packed.numel() == (3 * orig_vals.numel() // 4)orig_vals_f6_packed_u... | 1 | 11 | 0 | 106 | 4 | 406 | 416 | 406 | null | ['orig_vals_f6_packed', 'orig_vals_f6_packed_unpacked', 'orig_vals', 'orig_vals_f6_unpacked'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp6_e2m3_pack_unpack) defined within the public class called public.The function start at line 406 and ends at 416. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp6_e3m2_pack_unpack | def test_fp6_e3m2_pack_unpack():orig_vals = torch.Tensor([[0.0, 5.0, 28.0, -0.0], [-0.25, 0.1875, 0.0625, 8.0]]).to("cuda")orig_vals_f6_unpacked = f32_to_f6_e3m2_unpacked(orig_vals)orig_vals_f6_packed = pack_uint6(orig_vals_f6_unpacked)assert orig_vals_f6_packed.numel() == (3 * orig_vals.numel() // 4)orig_vals_f6_packe... | 1 | 11 | 0 | 105 | 4 | 421 | 431 | 421 | null | ['orig_vals_f6_packed', 'orig_vals_f6_packed_unpacked', 'orig_vals', 'orig_vals_f6_unpacked'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp6_e3m2_pack_unpack) defined within the public class called public.The function start at line 421 and ends at 431. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_triton_mxfp8_dim1_randn | def test_triton_mxfp8_dim1_randn(M, K):x = torch.randn(M, K, dtype=torch.bfloat16, device="cuda")x_mx_ref, x_s_ref = triton_to_mxfp8_dim1_reference(x, block_size=32)x_mx_t, x_s_t = triton_to_mxfp8_dim1(x, inner_block_size=32)torch.testing.assert_close(x_mx_t, x_mx_ref, rtol=0, atol=0)torch.testing.assert_close(x_s_t, x... | 1 | 6 | 2 | 87 | 1 | 441 | 446 | 441 | null | ['x'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_triton_mxfp8_dim1_randn) defined within the public class called public.The function start at line 441 and ends at 446. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [441.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_rearrange | def test_rearrange(shape):scales = torch.randint(256, size=shape, device="cuda", dtype=torch.uint8)eager = to_blocked(scales, False)triton = to_blocked(scales, True)torch.testing.assert_close(eager, triton, atol=0, rtol=0) | 1 | 5 | 1 | 61 | 3 | 463 | 467 | 463 | null | ['scales', 'eager', 'triton'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_rearrange) defined within the public class called public.The function start at line 463 and ends at 467. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_cuda_mx_dim1_numerics | def test_cuda_mx_dim1_numerics(M, K, input_dtype, scaling_mode):from torchao.prototype import mxfp8_cudascaling_mode_str = ("floor" if scaling_mode == ScaleCalculationMode.FLOOR else "rceil")block_size = 32# Use disinct incrementing values from 0 to M*K-1 to make debugging easier.x = (torch.arange(0, M * K, dtype=input... | 2 | 27 | 4 | 168 | 3 | 480 | 515 | 480 | null | ['x', 'scaling_mode_str', 'block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_cuda_mx_dim1_numerics) defined within the public class called public.The function start at line 480 and ends at 515. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [480.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_cuda_mx_dim0_not_supported | def test_cuda_mx_dim0_not_supported():from torchao.prototype import mxfp8_cudaM, K = 64, 64block_size = 32x = (torch.arange(0, M * K, dtype=torch.bfloat16, device="cuda").reshape(M, K).contiguous())with pytest.raises(RuntimeError):_, y_d1, _, s_d1 = mxfp8_cuda.quantize(x,rowwise=True,colwise=False,scale_dim_x=block_siz... | 1 | 17 | 0 | 94 | 2 | 522 | 539 | 522 | null | ['x', 'block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_cuda_mx_dim0_not_supported) defined within the public class called public.The function start at line 522 and ends at 539. It contains 17 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_cuda_mx_dim1_invalid_block_size | def test_cuda_mx_dim1_invalid_block_size():from torchao.prototype import mxfp8_cudaM, K = 64, 64x = (torch.arange(0, M * K, dtype=torch.bfloat16, device="cuda").reshape(M, K).contiguous())invalid_block_size = 4with pytest.raises(RuntimeError):_, y_d1, _, s_d1 = mxfp8_cuda.quantize(x,rowwise=False,colwise=True,scale_dim... | 1 | 17 | 0 | 94 | 2 | 546 | 563 | 546 | null | ['x', 'invalid_block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_cuda_mx_dim1_invalid_block_size) defined within the public class called public.The function start at line 546 and ends at 563. It contains 17 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | setup_distributed | def setup_distributed():world_size = int(os.environ.get("WORLD_SIZE", -1))device_mesh = init_device_mesh("cuda", (world_size,))# seed must be the same in all processestorch.manual_seed(1)local_rank = torch.distributed.get_rank()torch.cuda.set_device(local_rank)return device_mesh | 1 | 7 | 0 | 56 | 3 | 37 | 44 | 37 | null | ['local_rank', 'device_mesh', 'world_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (setup_distributed) defined within the public class called public.The function start at line 37 and ends at 44. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_dtensor_cast_to_mxfp8 | def _test_dtensor_cast_to_mxfp8(mesh: DeviceMesh, size=4):device = mesh.device_typex_fp32 = torch.rand(size, size, device=device)x_fp8 = MXTensor.to_mx(x_fp32, torch.float8_e4m3fn, block_size=size // 2)dist_x_fp32 = distribute_tensor(x_fp32, mesh, [Shard(0)])dist_x_fp8 = MXTensor.to_mx(dist_x_fp32, torch.float8_e4m3fn,... | 1 | 18 | 2 | 175 | 12 | 47 | 69 | 47 | null | ['x_fp8', 'dist_x_fp32', 'x_fp8_fp32_slice', 'device', 'world_size', 'x_fp8_fp32', 'slice_start', 'slice_end', 'local_rank', 'dist_x_fp8', 'x_fp32', 'rows_per_slice'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_dtensor_cast_to_mxfp8) defined within the public class called public.The function start at line 47 and ends at 69. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [47.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_mxfp8_mlp_tensor_parallelism | def _test_mxfp8_mlp_tensor_parallelism(mesh: DeviceMesh, size=128):config = MXLinearConfig.from_recipe_name("mxfp8_emulated")config.block_size = 32_test_lowp_mlp_tensor_parallelism_base(mesh, config, size, compile=False, allgather_in_lowp=False)_test_lowp_mlp_tensor_parallelism_base(mesh, config, size, compile=True, al... | 1 | 9 | 2 | 56 | 1 | 72 | 80 | 72 | null | ['config'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_mxfp8_mlp_tensor_parallelism) defined within the public class called public.The function start at line 72 and ends at 80. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [72.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_mxfp8_mlp_tensor_parallelism_dim1_triton | def _test_mxfp8_mlp_tensor_parallelism_dim1_triton(mesh: DeviceMesh, size=128):config = MXLinearConfig.from_recipe_name("mxfp8_emulated")config.block_size = 32config.mxfp8_cast_kernel_choice = MXFP8Dim1CastKernelChoice.TRITON_test_lowp_mlp_tensor_parallelism_base(mesh, config, size, compile=False, allgather_in_lowp=Fal... | 1 | 7 | 2 | 47 | 1 | 83 | 89 | 83 | null | ['config'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_mxfp8_mlp_tensor_parallelism_dim1_triton) defined within the public class called public.The function start at line 83 and ends at 89. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [83.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_mxfp8_mlp_tensor_parallelism_dim1_cuda | def _test_mxfp8_mlp_tensor_parallelism_dim1_cuda(mesh: DeviceMesh, size=128):config = MXLinearConfig.from_recipe_name("mxfp8_emulated")config.block_size = 32config.mxfp8_cast_kernel_choice = MXFP8Dim1CastKernelChoice.CUDA_test_lowp_mlp_tensor_parallelism_base(mesh, config, size, compile=False, allgather_in_lowp=False) | 1 | 7 | 2 | 47 | 1 | 97 | 103 | 97 | null | ['config'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_mxfp8_mlp_tensor_parallelism_dim1_cuda) defined within the public class called public.The function start at line 97 and ends at 103. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [97.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_around_tests | def run_around_tests():# 1. before test - set up (currently do nothing)# 2. run testyield# 3. after test - teardowntorch._dynamo.reset() | 1 | 3 | 0 | 12 | 0 | 42 | 47 | 42 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_around_tests) defined within the public class called public.The function start at line 42 and ends at 47. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_linear_eager_vs_hp | def test_linear_eager_vs_hp(elem_dtype, bias, input_shape, mxfp8_cast_kernel_choice, scale_calculation_mode):"""Smoke test for training linear module with mx weight, compares the following:* baseline: float32* experiment: emulated MX"""if mxfp8_cast_kernel_choice != MXFP8Dim1CastKernelChoice.TORCH:if elem_dtype != (tor... | 10 | 59 | 5 | 399 | 12 | 91 | 164 | 91 | null | ['config', 'm_mx', 'g', 'm', 'y_mx', 'y_sqnr', 'w_g_sqnr', 'x', 'grad_shape', 'x_g_sqnr', 'y_ref', 'x_ref'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_linear_eager_vs_hp) defined within the public class called public.The function start at line 91 and ends at 164. It contains 59 lines of code and it has a cyclomatic complexity of 10. It takes 5 parameters, represented as [91.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_linear_eager_emulated_vs_real_gemm | def test_linear_eager_emulated_vs_real_gemm(recipe_name, mkn):M, K, N = mknx = torch.randn(M, K, dtype=torch.bfloat16, device="cuda").requires_grad_()x_copy = copy.deepcopy(x)g = torch.randn(M, N, device="cuda", dtype=torch.bfloat16)m_emulated = nn.Sequential(nn.Linear(K, N, bias=False, device="cuda", dtype=torch.bfloa... | 2 | 27 | 2 | 257 | 13 | 179 | 212 | 179 | null | ['g', 'm_real', 'g_sqnr', 'config_emulated', 'x_copy', 'y_real', 'y_sqnr', 'y_emulated', 'config_real', 'm_emulated', 'x', 'w_sqnr', 'elem_dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_linear_eager_emulated_vs_real_gemm) defined within the public class called public.The function start at line 179 and ends at 212. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [179.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_activation_checkpointing | def test_activation_checkpointing():input_shape = (16, 4)grad_shape = (16, 8)elem_dtype = torch.float8_e4m3fnm = nn.Sequential(nn.Linear(4, 8, bias=True, device="cuda"),nn.Linear(8, 8, bias=True, device="cuda"),)config = MXLinearConfig(block_size=4, elem_dtype=elem_dtype)quantize_(m, config=config)x = torch.randn(*inpu... | 1 | 14 | 0 | 138 | 8 | 217 | 232 | 217 | null | ['config', 'g', 'm', 'input_shape', 'x', 'grad_shape', 'y', 'elem_dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_activation_checkpointing) defined within the public class called public.The function start at line 217 and ends at 232. It contains 14 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_linear_compile | def test_linear_compile(hp_dtype, recipe_name, bias, mxfp8_cast_kernel_choice, scale_calculation_mode):"""Verify that compile does not change numerics of MX linear fw + bw"""if recipe_name in ["mxfp8_emulated"]:if not is_sm_at_least_89():pytest.skip("CUDA capability >= 8.9 required for float8 in triton")if recipe_name ... | 22 | 66 | 5 | 494 | 14 | 268 | 361 | 268 | null | ['config', 'm_mx', 'g', 'x_g_ref', 'x_g', 'w_g', 'm_mx_c', 'w_g_ref', 'input_shape', 'x', 'grad_shape', 'y', 'y_ref', 'x_ref'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_linear_compile) defined within the public class called public.The function start at line 268 and ends at 361. It contains 66 lines of code and it has a cyclomatic complexity of 22. It takes 5 parameters, represented as [268.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_filter_fn | def test_filter_fn():m1 = nn.Sequential(nn.Linear(32, 32),nn.Linear(32, 32),)filter_fn = lambda mod, fqn: isinstance(mod, torch.nn.Linear) and fqn != "1"# noqa: E731config = MXLinearConfig(block_size=32)quantize_(m1, config=config, filter_fn=filter_fn)assert type(m1[0]) == MXLinearassert type(m1[1]) == torch.nn.Linear | 2 | 10 | 0 | 94 | 3 | 364 | 374 | 364 | null | ['filter_fn', 'm1', 'config'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_filter_fn) defined within the public class called public.The function start at line 364 and ends at 374. It contains 10 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_training_print_str | def test_training_print_str():m = nn.Sequential(nn.Linear(32, 32))config = MXLinearConfig()quantize_(m, config=config)s = str(m)assert "bl_sz=32" in sassert "kernel=emulated" in s | 1 | 7 | 0 | 46 | 3 | 377 | 383 | 377 | null | ['s', 'm', 'config'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_training_print_str) defined within the public class called public.The function start at line 377 and ends at 383. 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 | run_matrix_test | def run_matrix_test(M: int, K: int, N: int, format) -> float:dtype = torch.bfloat16device = torch.device("cuda")a = torch.rand((M, K), dtype=dtype, device=device)b = torch.rand((N, K), dtype=dtype, device=device)fmt = torch.float8_e4m3fn if format == "fp8" else torch.float4_e2m1fn_x2mx_func = (partial(torch._scaled_mm,... | 3 | 26 | 4 | 246 | 16 | 24 | 57 | 24 | null | ['a_data', 'out_hp', 'out', 'fmt', 'mx_func', 'b_data', 'a_scale_block', 'b_mx', 'device', 'a_scale', 'b_scale_block', 'a', 'b', 'dtype', 'b_scale', 'a_mx'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_matrix_test) defined within the public class called public.The function start at line 24 and ends at 57. It contains 26 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [24.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_matrix_multiplication | def test_matrix_multiplication(size, format):M, K, N = sizesqnr = run_matrix_test(M, K, N, format)threshold = 80.0assert sqnr >= threshold, (f"{format} SQNR {sqnr} below threshold for dims {M}x{K}x{N}") | 1 | 7 | 2 | 40 | 2 | 84 | 90 | 84 | null | ['sqnr', 'threshold'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_matrix_multiplication) defined within the public class called public.The function start at line 84 and ends at 90. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [84.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | run_before_and_after_tests | def run_before_and_after_tests():# source: https://stackoverflow.com/questions/22627659/run-code-before-and-after-each-test-in-py-test# noqa: E501# setup (currently do nothing)# tests will run hereyield# teardown# avoid dynamo cache limit issuestorch._dynamo.reset() | 1 | 3 | 0 | 12 | 0 | 39 | 49 | 39 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (run_before_and_after_tests) defined within the public class called public.The function start at line 39 and ends at 49. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_mx.assert_sqnr_gt_threshold | def assert_sqnr_gt_threshold(orig, new, threshold):sqnr = compute_error(orig, new)if torch.all(torch.isnan(sqnr)):# if both operands are full of zeroes, sqnr is nan and this is ok# test for this explicitlyassert torch.all(orig == 0) and torch.all(new == 0)else:assert sqnr >= threshold | 3 | 6 | 3 | 54 | 0 | 58 | 65 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_mx.assert_sqnr_gt_threshold) defined within the public class called public.The function start at line 58 and ends at 65. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [58.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_mx | def _test_mx(data_hp, elem_dtype, block_size, scale_calculation_mode=ScaleCalculationMode.FLOOR):data_mx = MXTensor.to_mx(data_hp, elem_dtype, block_size, scale_calculation_mode)data_mx_dq = data_mx.to_dtype(data_hp.dtype)def assert_sqnr_gt_threshold(orig, new, threshold):sqnr = compute_error(orig, new)if torch.all(tor... | 3 | 16 | 4 | 138 | 3 | 52 | 78 | 52 | null | ['sqnr', 'data_mx_dq', 'data_mx'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_mx) defined within the public class called public.The function start at line 52 and ends at 78. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [52.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_hello_world | def test_hello_world(elem_dtype):data = torch.randn(8, 8, device="cuda", dtype=torch.bfloat16)block_size = 4_test_mx(data, elem_dtype, block_size) | 1 | 4 | 1 | 36 | 2 | 83 | 86 | 83 | null | ['block_size', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_hello_world) defined within the public class called public.The function start at line 83 and ends at 86. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_realistic_numerics | def test_realistic_numerics(elem_dtype, scale_calculation_mode):data = torch.randn(128, 128, device="cuda", dtype=torch.bfloat16)block_size = 32_test_mx(data, elem_dtype, block_size, scale_calculation_mode) | 1 | 4 | 2 | 40 | 2 | 92 | 95 | 92 | null | ['block_size', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_realistic_numerics) defined within the public class called public.The function start at line 92 and ends at 95. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [92.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_all_zeros | def test_all_zeros(elem_dtype):data = torch.zeros(4, 4, device="cuda", dtype=torch.bfloat16)block_size = 4_test_mx(data, elem_dtype, block_size) | 1 | 4 | 1 | 36 | 2 | 100 | 103 | 100 | null | ['block_size', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_all_zeros) defined within the public class called public.The function start at line 100 and ends at 103. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_some_zeros | def test_some_zeros(elem_dtype):data = torch.randn(4, 4, device="cuda", dtype=torch.bfloat16)data[0, :] = 0.0data[:, 2] = 0.0block_size = 4_test_mx(data, elem_dtype, block_size) | 1 | 6 | 1 | 56 | 2 | 108 | 113 | 108 | null | ['block_size', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_some_zeros) defined within the public class called public.The function start at line 108 and ends at 113. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_to_mx_rceil | def test_to_mx_rceil():# nan# fmt: offdata_hp = torch.tensor([2143289344, 1054459450, 1060527345, 1045656552, 1058239340, 1045057552, 1061158006, 1049626606,1052757568, 1032293288, 1056992320, 1064929425, 1061036255, 1047450552, 1057077424, 1055125012,1036491424, 1063542041, 1057099838, 1058731224, 1050189482, 10491142... | 1 | 178 | 0 | 1,683 | 4 | 119 | 328 | 119 | null | ['ground_truth_fp8', 'data_hp', 'ground_truth_scale', 'data_mx'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_to_mx_rceil) defined within the public class called public.The function start at line 119 and ends at 328. It contains 178 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_exponent_nan_in | def test_exponent_nan_in(elem_dtype):"""If high precision block values has a NaN, the exponent blockvalue is set to is NaN"""tensor_hp = torch.tensor([float("nan"), 1, 2, 3, 4, 5, 6, 7], device="cuda", dtype=torch.bfloat16)block_size = 4tensor_mx = MXTensor.to_mx(tensor_hp, elem_dtype, block_size)assert torch.all(torch... | 1 | 8 | 1 | 94 | 3 | 333 | 344 | 333 | null | ['tensor_mx', 'block_size', 'tensor_hp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_exponent_nan_in) defined within the public class called public.The function start at line 333 and ends at 344. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_exponent_nan_out | def test_exponent_nan_out(elem_dtype, pack_fp6):"""If block exponent value is NaN, the MX tensor block value is NaN"""if pack_fp6 and elem_dtype not in (DTYPE_FP6_E2M3, DTYPE_FP6_E3M2):pytest.skip("invalid configuration")scale_e8m0 = torch.tensor([float("nan"), 1.0], dtype=torch.float8_e8m0fnu, device="cuda")block_size... | 7 | 39 | 2 | 298 | 5 | 350 | 394 | 350 | null | ['scale_e8m0', 'tensor_hp', 'block_size', 'tensor_mx', 'data_bits'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_exponent_nan_out) defined within the public class called public.The function start at line 350 and ends at 394. It contains 39 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [350.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_ranks | def test_ranks(elem_dtype):"""The reshaping logic works for various ranks"""B = 4shapes = ((B * 4,), (B * 4, 4), (B * 4, 4, 4), (B * 4, 4, 4, 4))for s in shapes:tensor_hp = torch.randn(*s, device="cuda", dtype=torch.bfloat16)_test_mx(tensor_hp, elem_dtype, B) | 2 | 6 | 1 | 81 | 3 | 399 | 407 | 399 | null | ['B', 'shapes', 'tensor_hp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_ranks) defined within the public class called public.The function start at line 399 and ends at 407. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_block_sizes | def test_block_sizes(elem_dtype, B):"""Smoke test for various block sizes"""if B == 1 and elem_dtype == torch.float4_e2m1fn_x2:pytest.skip("unsupported configuration")elif B % 4 != 0 and elem_dtype in [DTYPE_FP6_E2M3, DTYPE_FP6_E3M2]:pytest.skip("unsupported configuration")tensor_hp = torch.randn(B, device="cuda", dtyp... | 5 | 7 | 2 | 72 | 1 | 413 | 422 | 413 | null | ['tensor_hp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_block_sizes) defined within the public class called public.The function start at line 413 and ends at 422. It contains 7 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [413.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_transpose | def test_transpose(elem_dtype):"""Verify that transposing an MX tensor works"""M, K = 128, 256block_size = 32tensor_hp = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)tensor_mx = MXTensor.to_mx(tensor_hp,elem_dtype,block_size,)tensor_mx_dq_t = tensor_mx.to_dtype(tensor_hp.dtype).t()tensor_mx_t = tensor_mx.t()te... | 1 | 14 | 1 | 106 | 6 | 427 | 445 | 427 | null | ['tensor_hp', 'tensor_mx_dq_t', 'block_size', 'tensor_mx', 'tensor_mx_t_dq', 'tensor_mx_t'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_transpose) defined within the public class called public.The function start at line 427 and ends at 445. It contains 14 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_view | def test_view(elem_dtype):x = torch.randn(1, 2, 4, device="cuda")block_size = 4x_mx = MXTensor.to_mx(x, elem_dtype, block_size)x_mx_2 = x_mx.view(2, 4)# noqa: F841 | 1 | 5 | 1 | 46 | 4 | 450 | 454 | 450 | null | ['x', 'x_mx', 'x_mx_2', 'block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_view) defined within the public class called public.The function start at line 450 and ends at 454. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_clone | def test_clone():data = torch.randn(8, 8, device="cuda", dtype=torch.bfloat16)block_size = 4data_mx = MXTensor.to_mx(data, torch.float8_e4m3fn, block_size)data_mx_c = data_mx.clone()torch.testing.assert_close(data_mx.to_dtype(torch.bfloat16),data_mx_c.to_dtype(torch.bfloat16),atol=0,rtol=0,) | 1 | 11 | 0 | 81 | 4 | 458 | 468 | 458 | null | ['block_size', 'data', 'data_mx_c', 'data_mx'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_clone) defined within the public class called public.The function start at line 458 and ends at 468. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_fp6_packing | def test_fp6_packing(elem_dtype, pack_fp6):x = torch.randn(1, 2, 4, device="cuda")block_size = 4x_mx = MXTensor.to_mx(x, elem_dtype, block_size, pack_fp6=pack_fp6)if pack_fp6:expected_packed_shape = torch.Size([*x.shape[:-1], 3 * x.shape[-1] // 4])else:expected_packed_shape = x.shapeassert x_mx.qdata.shape == expected_... | 2 | 9 | 2 | 87 | 4 | 474 | 483 | 474 | null | ['x', 'expected_packed_shape', 'x_mx', 'block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_fp6_packing) defined within the public class called public.The function start at line 474 and ends at 483. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [474.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_to_mx_from_mx_compile_numerics | def test_to_mx_from_mx_compile_numerics(elem_dtype, hp_dtype, all_zeros):"""Verifies that compile does not change numerics of MX casts"""if elem_dtype in (torch.float8_e4m3fn, torch.float8_e5m2):if not is_sm_at_least_89():# separate ifs because flake8 is outsmarting mepytest.skip("CUDA capability >= 8.9 required for fl... | 4 | 39 | 3 | 247 | 10 | 490 | 536 | 490 | null | ['x_mx', 'pack_fp6', 'shape', 'block_size', 'x', 'x_mx_dq', 'to_mx_c', 'x_mx_c_dq', 'to_dtype_c', 'x_mx_c'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_to_mx_from_mx_compile_numerics) defined within the public class called public.The function start at line 490 and ends at 536. It contains 39 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [490.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_to_mx_inductor_single_kernel | def test_to_mx_inductor_single_kernel():"""Verify that inductor can fuse the cast of a high precision tensor to mxinto a single kernel"""# TODO(future PR): add fp4 and fp6 here# TODO(#1773): add swizzled scale format herex = torch.randn(2048, 2048, dtype=torch.bfloat16, device="cuda")block_size = 32to_mx_c = torch.comp... | 1 | 6 | 0 | 85 | 3 | 544 | 555 | 544 | null | ['x', 'to_mx_c', 'block_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_to_mx_inductor_single_kernel) defined within the public class called public.The function start at line 544 and ends at 555. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_index_select | def test_index_select():"""test that `x_0 = x[0]` works when `x` is a 3D `MXTensor`. This isuseful when stitching checkpoints of `num_experts` 2D parameters intoa single 3D parameter when converting between model definitions thatuse 2D and 3D parameters for their expert weights."""E, K, N = 128, 256, 512x = torch.randn... | 1 | 8 | 0 | 93 | 3 | 560 | 575 | 560 | null | ['x', 'x_mx', 'x_mx_1'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_index_select) defined within the public class called public.The function start at line 560 and ends at 575. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_cast_to_float8_e4m3fn_saturation_behavior.to_f8 | def to_f8(x):x = x.to(torch.float8_e4m3fn)return x | 1 | 3 | 1 | 17 | 0 | 616 | 618 | 616 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_cast_to_float8_e4m3fn_saturation_behavior.to_f8) defined within the public class called public.The function start at line 616 and ends at 618. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_cast_to_float8_e4m3fn_saturation_behavior | def test_cast_to_float8_e4m3fn_saturation_behavior():# TODO(#1912): make the saturated cast work in eager mode and remove this# testmax_val = torch.finfo(torch.float8_e4m3fn).max# create example data inside the representable rangedata_in_range_bf16 = torch.tensor([max_val,-1 * max_val,],dtype=torch.bfloat16,device="cud... | 1 | 31 | 0 | 187 | 9 | 583 | 627 | 583 | null | ['data_in_range_bf16', 'max_val', 'data_out_of_range_f8', 'data_in_range_f8_c', 'x', 'data_out_of_range_bf16', 'data_out_of_range_f8_c', 'data_in_range_f8', 'to_f8_c'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_cast_to_float8_e4m3fn_saturation_behavior) defined within the public class called public.The function start at line 583 and ends at 627. It contains 31 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_to_blocked_from_blocked_roundtrip | def test_to_blocked_from_blocked_roundtrip(shape, use_triton_kernel: bool):from torchao.prototype.mx_formats.utils import from_blocked, to_blockedrows, cols = shapedevice = "cuda" if torch.cuda.is_available() else "cpu"original = torch.randint(0, 255, (rows, cols), device=device, dtype=torch.uint8)blocked = to_blocked(... | 2 | 14 | 2 | 113 | 4 | 647 | 664 | 647 | null | ['reconstructed', 'blocked', 'device', 'original'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_to_blocked_from_blocked_roundtrip) defined within the public class called public.The function start at line 647 and ends at 664. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [647.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_reconstruction.assert_sqnr_gt_threshold | def assert_sqnr_gt_threshold(orig, new, threshold):sqnr = compute_error(orig, new)if torch.all(torch.isnan(sqnr)):# if both operands are full of zeroes, sqnr is nan and this is ok# test for this explicitlyassert torch.all(orig == 0) and torch.all(new == 0)else:assert sqnr >= threshold | 3 | 6 | 3 | 54 | 0 | 62 | 69 | 62 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_reconstruction.assert_sqnr_gt_threshold) defined within the public class called public.The function start at line 62 and ends at 69. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [62.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_reconstruction | def test_nvfp4_reconstruction(dtype, shape, use_per_tensor_scale):x = torch.randn(shape, dtype=dtype, device="cuda")if use_per_tensor_scale:tensor_amax = torch.max(torch.abs(x))scale = per_tensor_amax_to_scale(tensor_amax)else:scale = Nonex_nvfp4 = NVFP4Tensor.to_nvfp4(x, per_tensor_scale=scale)x_reconstructed = x_nvfp... | 2 | 31 | 3 | 244 | 10 | 51 | 95 | 51 | null | ['x_nvfp4_t', 'reconstructed_amax', 'x_reconstructed', 'max_abs', 'x_nvfp4', 'x', 'scale', 'tensor_amax', 'sqnr', 'x_reconstructed_t'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_reconstruction) defined within the public class called public.The function start at line 51 and ends at 95. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [51.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_construction | def test_nvfp4_swizzled_scales_construction(is_swizzled_scales, shape):"""Test that NVFP4Tensor can be constructed with swizzled scales andthat the _is_swizzled_scales flag is set correctly."""M, K = shapedata = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)tensor = NVFP4Tensor.to_nvfp4(data, is_swizzled_scales... | 1 | 7 | 2 | 69 | 3 | 112 | 124 | 112 | null | ['reconstructed', 'tensor', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_construction) defined within the public class called public.The function start at line 112 and ends at 124. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [112.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_slicing | def test_nvfp4_swizzled_scales_slicing(slice_dim, slice_spec):"""Test that slicing works correctly with swizzled scales and maintainsthe swizzled state in the output tensor."""# Use larger tensor sizes that align with swizzled requirementsif slice_dim == 0:# For row slicing, need at least 256 rows to test 128-row bound... | 4 | 20 | 2 | 161 | 6 | 149 | 186 | 149 | null | ['sliced_reconstructed', 'expected', 'tensor', 'original_reconstructed', 'sliced_tensor', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_slicing) defined within the public class called public.The function start at line 149 and ends at 186. It contains 20 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [149.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_slicing_errors | def test_nvfp4_swizzled_scales_slicing_errors(slice_dim, slice_spec, expected_error):"""Test that slicing raises appropriate errors for misaligned boundaries."""M, K = 256, 4096data = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)tensor = NVFP4Tensor.to_nvfp4(data, is_swizzled_scales=True)with pytest.raises(Run... | 2 | 9 | 3 | 84 | 3 | 243 | 256 | 243 | null | ['_', 'tensor', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_slicing_errors) defined within the public class called public.The function start at line 243 and ends at 256. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [243.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_view_semantics | def test_nvfp4_swizzled_scales_view_semantics():"""Test that slicing maintains proper view semantics where possible."""M, K = 256, 4096data = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)tensor = NVFP4Tensor.to_nvfp4(data, is_swizzled_scales=True)# Test row slicing (should maintain views)sliced_tensor = tensor... | 1 | 9 | 0 | 112 | 4 | 263 | 282 | 263 | null | ['sliced_tensor', 'tensor', 'data', 'full_width_slice'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_view_semantics) defined within the public class called public.The function start at line 263 and ends at 282. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_serialization | def test_nvfp4_swizzled_scales_serialization():"""Test that tensor flatten/unflatten preserves the swizzled scales state."""M, K = 32, 64data = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)# Create tensor with swizzled scalesoriginal_tensor = NVFP4Tensor.to_nvfp4(data, is_swizzled_scales=True)# Test serializat... | 2 | 17 | 0 | 146 | 6 | 289 | 323 | 289 | null | ['reconstructed_dq', 'original_tensor', 'reconstructed_tensor', 'original_dq', 'inner_tensors', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_serialization) defined within the public class called public.The function start at line 289 and ends at 323. It contains 17 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_nvfp4_swizzled_scales_get_scales_method | def test_nvfp4_swizzled_scales_get_scales_method():"""Test that the get_scales() method correctly unswizzles scales when needed."""M, K = 32, 64data = torch.randn(M, K, device="cuda", dtype=torch.bfloat16)# Create tensors with both storage methodsregular_tensor = NVFP4Tensor.to_nvfp4(data, is_swizzled_scales=False)swiz... | 1 | 11 | 0 | 111 | 6 | 330 | 350 | 330 | null | ['swizzled_tensor', 'regular_tensor', 'swizzled_scales', 'expected_shape', 'regular_scales', 'data'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_nvfp4_swizzled_scales_get_scales_method) defined within the public class called public.The function start at line 330 and ends at 350. 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.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.