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
benchmark
def benchmark(num_tokens, hidden_size=8192, intermediate_size=8192):ffn_ref = (nn.Sequential(nn.Linear(hidden_size, intermediate_size, bias=False),SquaredReLU(),nn.Linear(intermediate_size, hidden_size, bias=False),).to(torch.bfloat16).cuda())input_tensor = torch.randn(num_tokens, hidden_size).to(torch.bfloat16).cuda()...
1
95
3
546
10
29
136
29
null
['ffn_ref', 'fp16_c_time', 'fp8_c_sparse_time', 'fp16_time', 'ffn_clone', 'fp8_c_activation_sparse_time', 'input_tensor', 'fp8_c_time', 'ao_fast_sparsification_time', 'cusparselt_time']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 29 and ends at 136. It contains 95 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [29.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(m: int, k: int, n: int):float_data_fp16 = torch.randn(n, k, dtype=torch.float16, device="cuda")float_data_bf16 = torch.randn(n, k, dtype=torch.bfloat16, device="cuda")fp6_weight_fp16 = to_affine_quantized_fpx(float_data_fp16, FloatxTensorCoreLayout(3, 2))fp6_weight_bf16 = to_affine_quantized_fpx(float_dat...
1
48
3
328
18
16
69
16
null
['bf16_time', 'fp16_act', 'correct_bf16', 'fp6_output_bf16', 'fp16_time', 'fp6_output_fp16', 'fp6_time_fp16', 'bf16_output', 'bf16_weight', 'fp16_weight', 'fp6_weight_bf16', 'float_data_fp16', 'float_data_bf16', 'bf16_act', 'correct_fp16', 'fp6_time_bf16', 'fp6_weight_fp16', 'fp16_output']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 16 and ends at 69. It contains 48 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [16.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_model_with_warmup
def benchmark_model_with_warmup(func, x, N_WARMUP=3):benchmark_model(func, N_WARMUP, device_type="cuda")return benchmark_model(func, 10, device_type="cuda")
1
3
3
32
0
31
33
31
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_model_with_warmup) defined within the public class called public.The function start at line 31 and ends at 33. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [31.0] and does not return any value..
pytorch_ao
public
public
0
0
run_gpu_sparse_benchmark.dense_func
def dense_func():return F.linear(x, A, b)
1
2
0
15
0
72
73
72
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.dense_func) defined within the public class called public.The function start at line 72 and ends at 73. 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
run_gpu_sparse_benchmark.sparse_func
def sparse_func():return F.linear(x, A_sparse, b)
1
2
0
15
0
75
76
75
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.sparse_func) defined within the public class called public.The function start at line 75 and ends at 76. 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
run_gpu_sparse_benchmark.dense_func
def dense_func():return torch._scaled_mm(A, x, scale_a=scale_a, scale_b=scale_b, out_dtype=torch.bfloat16)
1
4
0
27
0
85
88
85
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.dense_func) defined within the public class called public.The function start at line 85 and ends at 88. 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
run_gpu_sparse_benchmark.sparse_func
def sparse_func():return torch._scaled_mm(A_sparse,x,scale_a=scale_a,scale_b=scale_b,out_dtype=torch.bfloat16,)
1
8
0
28
0
90
97
90
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.sparse_func) defined within the public class called public.The function start at line 90 and ends at 97. 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
run_gpu_sparse_benchmark.dense_func
def dense_func():return torch.mm(A, x)
1
2
0
13
0
101
102
101
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.dense_func) defined within the public class called public.The function start at line 101 and ends at 102. 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
run_gpu_sparse_benchmark.sparse_func
def sparse_func():return torch.mm(A_sparse, x)
1
2
0
13
0
104
105
104
null
[]
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark.sparse_func) defined within the public class called public.The function start at line 104 and ends at 105. 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
run_gpu_sparse_benchmark
def run_gpu_sparse_benchmark(m, k, n, args):with torch.no_grad():dtype = getattr(torch, args.dtype)x = torch.randn(n, k).to(dtype).cuda()# handle sparsity typesif args.sparsity == "semi-structured":SparseSemiStructuredTensor._FORCE_CUTLASS = args.backend == "cutlass"A = create_semi_structured_tensor(m, k, dtype)A_spars...
7
68
4
391
13
36
136
36
null
['scale_a', 'sparse_time_c', 'dense_time_c', 'A_sparse', 'x', 'dense_func_c', 'b', 'dtype', 'scale_b', 'sparse_func_c', 'sparse_time', 'dense_time', 'A']
None
null
0
0
0
null
0
null
The function (run_gpu_sparse_benchmark) defined within the public class called public.The function start at line 36 and ends at 136. It contains 68 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [36.0] and does not return any value..
pytorch_ao
public
public
0
0
bench_custom_kernel.fn
def fn():_ = triton_mixed_mm(x,packed_w,scales.T,zeros.T,transposed=transposed,group_size=group_size,fp8_fast_accum=fp8_fast_accum,kernel_type=kernel_type,)
1
11
0
37
0
46
56
46
null
[]
None
null
0
0
0
null
0
null
The function (bench_custom_kernel.fn) defined within the public class called public.The function start at line 46 and ends at 56. 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
bench_custom_kernel
def bench_custom_kernel(x,W_q,scales,zeros,group_size,transposed=False,kernel_type="max_autotune",fp8_fast_accum=False,):packed_w = pack_2xint4(W_q.T)def fn():_ = triton_mixed_mm(x,packed_w,scales.T,zeros.T,transposed=transposed,group_size=group_size,fp8_fast_accum=fp8_fast_accum,kernel_type=kernel_type,)t = do_bench(f...
1
14
8
44
3
34
59
34
null
['t', 'packed_w', '_']
None
null
0
0
0
null
0
null
The function (bench_custom_kernel) defined within the public class called public.The function start at line 34 and ends at 59. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [34.0] and does not return any value..
pytorch_ao
public
public
0
0
bench_hqq.reference_fn
def reference_fn():W_dq = hqq_linear.dequantize()_ = x @ W_dq.T if not transposed else x @ W_dq
2
3
0
25
0
68
70
68
null
[]
None
null
0
0
0
null
0
null
The function (bench_hqq.reference_fn) defined within the public class called public.The function start at line 68 and ends at 70. 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
bench_hqq
def bench_hqq(x,hqq_linear: HQQLinear | HQQLinearTorchWeightOnlyInt4,transposed=False,tinygemm=False,):def reference_fn():W_dq = hqq_linear.dequantize()_ = x @ W_dq.T if not transposed else x @ W_dqfn = reference_fn if not tinygemm else lambda: hqq_linear(x)t = do_bench(fn)return t
2
10
4
43
4
62
75
62
null
['fn', 'W_dq', '_', 't']
None
null
0
0
0
null
0
null
The function (bench_hqq) defined within the public class called public.The function start at line 62 and ends at 75. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [62.0] and does not return any value..
pytorch_ao
public
public
0
0
run_benchmark
def run_benchmark(shape, group_size, dtype, axis=1, transposed=False, quant_dtype=torch.uint8):qcfg = {**BASE_QUANT_CONFIG,**dict(group_size=group_size, axis=axis),}M, N, K = shapex = (torch.randn(M, K, dtype=dtype, device="cuda")if not transposedelse torch.randn(M, N, dtype=dtype, device="cuda"))linear = torch.nn.Line...
7
52
6
364
14
78
140
78
null
['ref_time', 'should_run_tinygemm', '_', 'hqq_int4mm', 'zeros', 'scales', 'tt_time', 'hqq_linear', 'x', 'W_q', 'int4_time', 'quant_config', 'linear', 'qcfg']
None
null
0
0
0
null
0
null
The function (run_benchmark) defined within the public class called public.The function start at line 78 and ends at 140. It contains 52 lines of code and it has a cyclomatic complexity of 7. It takes 6 parameters, represented as [78.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, lr: float, total_steps: int, warmup: float = 0.05) -> None:self.lr = lrself.final_lr = 0self.total_steps = total_stepsself.warmup_steps = round(total_steps * warmup)
1
5
4
48
0
71
75
71
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 71 and ends at 75. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [71.0] and does not return any value..
pytorch_ao
public
public
0
0
get_lr
def get_lr(self, step: int) -> float:if step < self.warmup_steps:return self.lr * step / self.warmup_stepsif step < self.total_steps:progress = (step - self.warmup_steps) / (self.total_steps - self.warmup_steps)return self.final_lr + 0.5 * (self.lr - self.final_lr) * (1 + math.cos(progress * math.pi))return self.final_...
3
11
2
91
0
77
87
77
null
[]
None
null
0
0
0
null
0
null
The function (get_lr) defined within the public class called public.The function start at line 77 and ends at 87. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [77.0] and does not return any value..
pytorch_ao
public
public
0
0
get_parser
def get_parser():parser = argparse.ArgumentParser()parser.add_argument("--model", required=True)parser.add_argument("--model_kwargs", type=json.loads, default=dict())parser.add_argument("--checkpoint_activations", action="store_true")parser.add_argument("--amp", default="none")parser.add_argument("--full_bf16", action=...
1
25
0
261
1
90
118
90
null
['parser']
None
null
0
0
0
null
0
null
The function (get_parser) defined within the public class called public.The function start at line 90 and ends at 118. It contains 25 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
get_dloader
def get_dloader(args, training: bool):transforms = [v2.ToImage()]if training:transforms.extend([v2.RandomResizedCrop(224), v2.RandomHorizontalFlip()])else:transforms.extend([v2.Resize(256), v2.CenterCrop(224)])transforms.append(v2.ToDtype(torch.float32, scale=True))transforms.append(v2.Normalize(mean=[0.485, 0.456, 0.4...
3
24
2
213
2
121
149
121
null
['transforms', 'ds']
None
null
0
0
0
null
0
null
The function (get_dloader) defined within the public class called public.The function start at line 121 and ends at 149. It contains 24 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
get_amp_ctx
def get_amp_ctx(amp, device):dtype = dict(bf16=torch.bfloat16, fp16=torch.float16, none=None)[amp]return torch.autocast(device, dtype=dtype, enabled=amp != "none")
1
3
2
47
1
152
154
152
null
['dtype']
None
null
0
0
0
null
0
null
The function (get_amp_ctx) defined within the public class called public.The function start at line 152 and ends at 154. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [152.0] and does not return any value..
pytorch_ao
public
public
0
0
evaluate_model
def evaluate_model(model, args):model.eval()val_dloader = get_dloader(args, False)all_labels = []all_preds = []for batch in tqdm(val_dloader, dynamic_ncols=True, desc="Evaluating"):all_labels.append(batch["label"].clone())if args.full_bf16:batch["image"] = batch["image"].bfloat16()if args.channels_last:batch["image"] =...
4
17
2
175
4
158
179
158
null
['all_labels', 'all_preds', 'acc', 'val_dloader']
None
null
0
0
0
null
0
null
The function (evaluate_model) defined within the public class called public.The function start at line 158 and ends at 179. It contains 17 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
get_problem
def get_problem(m, n, k, groupsize=-1):if groupsize == -1:groupsize = kdev = torch.device("cuda")A_ref = torch.randn((m, k), dtype=torch.half, device=dev)B_ref = torch.randn((k, n), dtype=torch.half, device=dev)A = torch.randint(-128, 127, (m, k), dtype=torch.int8, device=dev)B = torch.randint(low=-(2**31), high=2**31,...
3
19
4
258
10
15
34
15
null
['s_group', 'B_ref', 'groupsize', 'B', 'qqq_workspace', 'A_ref', 'dev', 's_channel', 's_tok', 'A']
None
null
0
0
0
null
0
null
The function (get_problem) defined within the public class called public.The function start at line 15 and ends at 34. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [15.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(m: int, k: int, n: int, group_size: int):A, B, A_ref, B_ref, s_tok, s_channel, s_group, qqq_workspace = get_problem(m, n, k, group_size)fp16_time = benchmark_torch_function_in_microseconds(torch.matmul, A_ref, B_ref)marlin_qqq_w4a8_time = benchmark_torch_function_in_microseconds(marlin_qqq_gemm, A, B, s_t...
1
17
4
114
2
37
55
37
null
['fp16_time', 'marlin_qqq_w4a8_time']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 37 and ends at 55. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [37.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_microseconds
def benchmark_microseconds(f, *args):return do_bench(lambda: f(*args), return_mode="median") * 1e3
1
2
2
25
0
26
27
26
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_microseconds) defined within the public class called public.The function start at line 26 and ends at 27. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [26.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem
def get_problem(m: int, n: int, k: int, Xq_nbits: int):assert k % 2 == 0assert Xq_nbits in [4, 8]X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = torch.rand((n, k), dtype=dtype, device=device)X_quant_func = (_int4_symm_cutlass_quant if Xq_nbits == 4 else _int8_symm_cutlass_quant)W_quant_func = _int4_symm_...
2
18
4
153
12
30
51
30
null
['Xq', 'W_quant_func', 'X_aqt', 'X_quant_func', 'W_scale', 'X_scale', 'bias', 'W_aqt', 'Wq', 'out_dtype', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem) defined within the public class called public.The function start at line 30 and ends at 51. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [30.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(m: int, k: int, n: int):ref_args, args = get_problem(m, n, k, 4)fp16_time = benchmark_microseconds(torch.nn.functional.linear, *ref_args)rowwise_scaled_linear_cutlass_s4s4_time = benchmark_microseconds(rowwise_scaled_linear_cutlass_s4s4, *args)_, args = get_problem(m, n, k, 8)rowwise_scaled_linear_cutlass...
1
20
3
115
3
54
75
54
null
['fp16_time', 'rowwise_scaled_linear_cutlass_s8s4_time', 'rowwise_scaled_linear_cutlass_s4s4_time']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 54 and ends at 75. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_microseconds
def benchmark_microseconds(f, *args):return do_bench(lambda: f(*args), return_mode="median") * 1e3
1
2
2
25
0
24
25
24
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_microseconds) defined within the public class called public.The function start at line 24 and ends at 25. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [24.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_cutlass
def get_problem_cutlass(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)X_quant_func = _float8_cutlass_quantW_quant_func = _float8_cutlass_quant_sparseX_aqt = X_quant_func(X_ref, dtypeq_X)W_aqt = W_quant_func(W_ref, dtypeq...
1
15
3
137
13
28
45
28
null
['Xq', 'Wq_sparse', 'W_meta', 'W_quant_func', 'X_aqt', 'X_quant_func', 'W_scale', 'X_scale', 'bias', 'W_aqt', 'out_dtype', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_cutlass) defined within the public class called public.The function start at line 28 and ends at 45. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [28.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_cusparselt
def get_problem_cusparselt(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)Xq = X_ref.to(dtypeq_W)Wq = W_ref.to(dtypeq_W)Wqs = torch._cslt_compress(Wq)alg_id, split_k, split_k_one_kernel, _ = torch._C._cusparselt.mm_search...
1
10
3
132
5
48
61
48
null
['Xq', 'Wqs', 'Wq', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_cusparselt) defined within the public class called public.The function start at line 48 and ends at 61. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [48.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_scaled_mm
def get_problem_scaled_mm(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)X_aqt = _float8_cutlass_quant(X_ref, dtypeq_W)W_aqt = _float8_cutlass_quant(W_ref, dtypeq_W)Xq = X_aqt.tensor_impl.float8_dataWq = W_aqt.tensor_impl...
1
10
3
127
8
64
76
64
null
['Xq', 'X_aqt', 'W_scale', 'X_scale', 'W_aqt', 'Wq', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_scaled_mm) defined within the public class called public.The function start at line 64 and ends at 76. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [64.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(m: int, k: int, n: int):ref_args, args = get_problem_cutlass(m, n, k)fp16_time = benchmark_microseconds(torch.nn.functional.linear, *ref_args)rowwise_scaled_linear_sparse_cutlass_f8f8_time = benchmark_microseconds(rowwise_scaled_linear_sparse_cutlass_f8f8, *args)cslt_args = get_problem_cusparselt(m, n, k)...
1
20
3
130
6
79
101
79
null
['fp16_time', 'fp8_args', 'rowwise_scaled_linear_sparse_cutlass_f8f8_time', 'cslt_args', 'cusparselt_time', 'fp8_time']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 79 and ends at 101. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [79.0] and does not return any value..
pytorch_ao
public
public
0
0
product_dict
def product_dict(**kwargs):keys = kwargs.keys()vals = kwargs.values()for instance in itertools.product(*vals):yield dict(zip(keys, instance))
2
5
1
41
2
26
30
26
null
['keys', 'vals']
None
null
0
0
0
null
0
null
The function (product_dict) defined within the public class called public.The function start at line 26 and ends at 30. It contains 5 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
benchmark_helper.benchmark_helper.handle_case.run_one
def run_one():if fw:benchmark_object.fw()if bw:benchmark_object.bw()
3
5
0
20
0
59
63
59
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_helper.benchmark_helper.handle_case.run_one) defined within the public class called public.The function start at line 59 and ends at 63. It contains 5 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
benchmark_helper.benchmark_helper.handle_case.run_one
def run_one():g.replay()
1
2
0
9
0
72
73
72
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_helper.benchmark_helper.handle_case.run_one) defined within the public class called public.The function start at line 72 and ends at 73. 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
benchmark_helper.handle_case
def handle_case(**case):for sparsity_config, benchmark_cls in functions.items():result = {"sparsity_config": sparsity_config,}result.update(**case)try:benchmark_object = benchmark_cls(**case)def run_one():if fw:benchmark_object.fw()if bw:benchmark_object.bw()if cuda_graph:run_one()benchmark_object = benchmark_cls(**cas...
10
51
1
258
0
50
112
50
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_helper.handle_case) defined within the public class called public.The function start at line 50 and ends at 112. It contains 51 lines of code and it has a cyclomatic complexity of 10. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
benchmark_helper
def benchmark_helper(functions,cases,fw: bool = False,bw: bool = False,cuda_graph: bool = False,compile: bool = False,blocked_autorange=False,):assert fw or bwassert not (cuda_graph and compile)print(f"Running benchmarks with: fw={fw}, bw={bw}, cuda_graph={cuda_graph}, compile={compile}: ")results = []def handle_case(*...
4
19
7
75
6
33
116
33
null
['g', 'res', 'benchmark_object', 't0', 'results', 'result']
None
null
0
0
0
null
0
null
The function (benchmark_helper) defined within the public class called public.The function start at line 33 and ends at 116. It contains 19 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [33.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, mkn):super().__init__()m, k, n = mknself.model = torch.nn.Linear(k, n).cuda().half()self.input = torch.randn([m, k], device="cuda", dtype=torch.half, requires_grad=True)self.grad = torch.randn([m, n], device="cuda", dtype=torch.half)
1
8
2
95
0
121
128
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 128. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
fw
def fw(self):self.out = self.model(self.input)
1
2
1
17
0
130
131
130
null
[]
None
null
0
0
0
null
0
null
The function (fw) defined within the public class called public.The function start at line 130 and ends at 131. 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
bw
def bw(self):self.out.backward(self.grad, retain_graph=True)
1
2
1
19
0
133
134
133
null
[]
None
null
0
0
0
null
0
null
The function (bw) defined within the public class called public.The function start at line 133 and ends at 134. 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, mkn):super().__init__()m, k, n = mknself.model = torch.nn.Linear(k, n).cuda().half()self.model.weight = torch.nn.Parameter(to_sparse_semi_structured(self.model.weight))self.input = torch.randn([m, k], device="cuda", dtype=torch.half, requires_grad=True)self.grad = torch.randn([m, n], device="cuda", d...
1
11
2
116
0
138
148
138
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 138 and ends at 148. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [138.0] and does not return any value..
pytorch_ao
public
public
0
0
fw
def fw(self):self.out = self.model(self.input)
1
2
1
17
0
150
151
130
null
[]
None
null
0
0
0
null
0
null
The function (fw) defined within the public class called public.The function start at line 150 and ends at 151. 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, mkn):super().__init__(mkn)self.model = SemiSparseLinear.from_dense(self.model)
1
3
2
27
0
155
157
155
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 155 and ends at 157. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [155.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, mkn):super().__init__(mkn)
1
2
2
15
0
161
162
161
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 161 and ends at 162. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [161.0] and does not return any value..
pytorch_ao
public
public
0
0
fw
def fw(self):self.out = semi_structured_sparsify(self.input)
1
2
1
15
0
164
165
164
null
[]
None
null
0
0
0
null
0
null
The function (fw) defined within the public class called public.The function start at line 164 and ends at 165. 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
bw
def bw(self):pass
1
2
1
6
0
167
168
167
null
[]
None
null
0
0
0
null
0
null
The function (bw) defined within the public class called public.The function start at line 167 and ends at 168. 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, model_type, batch_size):super().__init__()self.model = (sam_model_registry[model_type]().image_encoder.cuda().half().train())self.input = torch.randn(batch_size,3,1024,1024,device="cuda",dtype=torch.half,requires_grad=True,)self.grad = torch.randn([batch_size, 256, 64, 64], device="cuda", dtype=torch...
1
17
3
101
0
173
189
173
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 173 and ends at 189. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [173.0] and does not return any value..
pytorch_ao
public
public
0
0
fw
def fw(self):self.out = self.model(self.input)
1
2
1
17
0
191
192
130
null
[]
None
null
0
0
0
null
0
null
The function (fw) defined within the public class called public.The function start at line 191 and ends at 192. 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
bw
def bw(self):self.out.backward(self.grad, retain_graph=True)
1
2
1
19
0
194
195
133
null
[]
None
null
0
0
0
null
0
null
The function (bw) defined within the public class called public.The function start at line 194 and ends at 195. 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, model_type, batch_size):super().__init__(model_type, batch_size)# Apply to just MLP linear layers of SAM image encoder (ViT)sparse_config = {}for name, mod in self.model.named_modules():if isinstance(mod, torch.nn.Linear) and "mlp" in name:sparse_config[name] = SemiSparseLinearswap_linear_with_semi_s...
4
7
3
66
0
199
206
199
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 199 and ends at 206. It contains 7 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [199.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, model_type, batch_size):super().__init__(model_type, batch_size)# Apply to all linear layers of SAM image encoder (ViT)sparse_config = {}for name, mod in self.model.named_modules():if isinstance(mod, torch.nn.Linear):sparse_config[name] = SemiSparseLinearswap_linear_with_semi_sparse_linear(self.model...
3
7
3
62
0
210
217
210
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 210 and ends at 217. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [210.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_microseconds
def benchmark_microseconds(f, *args):return do_bench(lambda: f(*args), return_mode="median") * 1e3
1
2
2
25
0
25
26
25
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_microseconds) defined within the public class called public.The function start at line 25 and ends at 26. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [25.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_cutlass
def get_problem_cutlass(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)X_quant_func = _float8_cutlass_quantW_quant_func = _float8_cutlass_quant_sparseX_aqt = X_quant_func(X_ref, dtypeq_X)W_aqt = W_quant_func(W_ref, dtypeq...
1
15
3
137
13
29
46
29
null
['Xq', 'Wq_sparse', 'W_meta', 'W_quant_func', 'X_aqt', 'X_quant_func', 'W_scale', 'X_scale', 'bias', 'W_aqt', 'out_dtype', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_cutlass) defined within the public class called public.The function start at line 29 and ends at 46. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [29.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_cusparselt
def get_problem_cusparselt(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)Xq = X_ref.to(dtypeq_W)Wq = W_ref.to(dtypeq_W)Wqs = torch._cslt_compress(Wq)alg_id, split_k, split_k_one_kernel, _ = torch._C._cusparselt.mm_search...
1
10
3
132
5
49
62
49
null
['Xq', 'Wqs', 'Wq', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_cusparselt) defined within the public class called public.The function start at line 49 and ends at 62. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [49.0] and does not return any value..
pytorch_ao
public
public
0
0
get_problem_scaled_mm
def get_problem_scaled_mm(m: int, n: int, k: int):X_ref = torch.randn((m, k), dtype=dtype, device=device)W_ref = create_semi_structured_tensor(n, k, dtype=dtype).to(device)X_aqt = _float8_cutlass_quant(X_ref, dtypeq_W)W_aqt = _float8_cutlass_quant(W_ref, dtypeq_W)Xq = X_aqt.tensor_impl.float8_dataWq = W_aqt.tensor_impl...
1
10
3
127
8
65
77
65
null
['Xq', 'X_aqt', 'W_scale', 'X_scale', 'W_aqt', 'Wq', 'X_ref', 'W_ref']
None
null
0
0
0
null
0
null
The function (get_problem_scaled_mm) defined within the public class called public.The function start at line 65 and ends at 77. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [65.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(m, k):torch.manual_seed(123)W_ref = create_semi_structured_tensor(m, k, dtype=torch.float8_e4m3fn).cuda()# packed, meta = torch.ops.torchao.sparse_semi_structured_tile.default(W_ref, "", True)cutlass_reference_args = (W_ref,)cutlass_custom_args = (W_ref, "", True)cutlass_reference_compression_time = bench...
1
15
2
83
5
80
98
80
null
['cutlass_reference_args', 'cutlass_custom_args', 'cutlass_custom_compression_time', 'cutlass_reference_compression_time', 'W_ref']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 80 and ends at 98. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [80.0] and does not return any value..
pytorch_ao
public
public
0
0
profile
def profile():torch.manual_seed(123)W_ref = create_semi_structured_tensor(8192, 8192, dtype=torch.float8_e4m3fn).cuda()# clear cachenew_val = torch.empty(10000, 10000, device="cuda")new_val[:, :] = 0packed, meta = torch.ops.torchao.sparse_semi_structured_tile.default(W_ref, "", True)
1
8
0
70
2
101
111
101
null
['new_val', 'W_ref']
None
null
0
0
0
null
0
null
The function (profile) defined within the public class called public.The function start at line 101 and ends at 111. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, scale):super().__init__()self.net = torch.nn.Sequential(torch.nn.Linear(scale * 2, scale, bias=True, dtype=torch.float16).cuda(),torch.nn.Linear(scale, scale, bias=True, dtype=torch.float16).cuda(),torch.nn.Linear(scale, scale // 2, bias=True, dtype=torch.float16).cuda(),)
1
7
2
87
0
18
24
18
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 18 and ends at 24. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [18.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):return self.net(x)
1
2
2
14
0
26
27
26
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 26 and ends at 27. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [26.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark
def benchmark(function, args, num_runs):# warmuptorch._dynamo.reset()for i in range(100):function(*args)torch.cuda.synchronize()start_event = torch.cuda.Event(enable_timing=True)end_event = torch.cuda.Event(enable_timing=True)start_event.record()for _ in range(num_runs):function(*args)end_event.record()torch.cuda.synch...
3
13
3
99
2
30
45
30
null
['start_event', 'end_event']
None
null
0
0
0
null
0
null
The function (benchmark) defined within the public class called public.The function start at line 30 and ends at 45. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [30.0] and does not return any value..
pytorch_ao
public
public
0
0
profile_bitpack
def profile_bitpack():from torch.profiler import ProfilerActivity, profilefake_tensor = [torch.randint(2**8, (512, 512), dtype=torch.uint8).cuda()]func = torch.compile(unpack_cpu, fullgraph=True)with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],record_shapes=True,with_stack=True,) as prof:for _ in r...
2
17
0
142
2
48
83
48
null
['fake_tensor', 'func']
None
null
0
0
0
null
0
null
The function (profile_bitpack) defined within the public class called public.The function start at line 48 and ends at 83. 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
uintx_vs_fp16
def uintx_vs_fp16(nbits=[1, 2, 3, 4, 5, 6, 7], scales=[256, 512, 1024], repeats=30):results = []nbits.sort()scales.sort()for scale in scales:test_input = torch.randn(scale * 2, dtype=torch.float16).cuda()forward_args = [test_input]times = [scale]fp16 = Linear16(scale)fp16c = torch.compile(fp16, fullgraph=True)fp16_time...
5
25
3
213
9
86
112
86
null
['times', 'forward_args', 'fp16c', 'test_input', 'results', 'fp16_time', 'fp16', 'm', 'uintx_time']
None
null
0
0
0
null
0
null
The function (uintx_vs_fp16) defined within the public class called public.The function start at line 86 and ends at 112. It contains 25 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [86.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_in_ms
def benchmark_in_ms(warmup, iters, f, *args, **kwargs):for _ in range(warmup):f(*args, **kwargs)torch.cuda.synchronize()start_event = torch.cuda.Event(enable_timing=True)end_event = torch.cuda.Event(enable_timing=True)start_event.record()for _ in range(iters):f(*args, **kwargs)end_event.record()torch.cuda.synchronize()...
3
12
5
107
2
28
41
28
null
['start_event', 'end_event']
None
null
0
0
0
null
0
null
The function (benchmark_in_ms) defined within the public class called public.The function start at line 28 and ends at 41. It contains 12 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [28.0] and does not return any value..
pytorch_ao
public
public
0
0
compiled_mm
def compiled_mm(x, w):return torch.mm(x, w)
1
2
2
16
0
45
46
45
null
[]
None
null
0
0
0
null
0
null
The function (compiled_mm) defined within the public class called public.The function start at line 45 and ends at 46. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [45.0] and does not return any value..
pytorch_ao
public
public
0
0
compiled_int_mm
def compiled_int_mm(x, w):return torch._int_mm(x, w)
1
2
2
16
0
50
51
50
null
[]
None
null
0
0
0
null
0
null
The function (compiled_int_mm) defined within the public class called public.The function start at line 50 and ends at 51. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [50.0] and does not return any value..
pytorch_ao
public
public
0
0
run_int_mm_benchmark
def run_int_mm_benchmark(x, w, b):fp_time = benchmark_in_ms(10, 100, torch.mm, x, w)x_int = x.to(dtype=torch.int8)w_int = w.to(dtype=torch.int8)int_mm_time = benchmark_in_ms(10, 100, int_matmul, x_int, w_int)return fp_time, int_mm_time
1
6
3
67
4
54
59
54
null
['x_int', 'int_mm_time', 'w_int', 'fp_time']
None
null
0
0
0
null
0
null
The function (run_int_mm_benchmark) defined within the public class called public.The function start at line 54 and ends at 59. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [54.0] and does not return any value..
pytorch_ao
public
public
0
0
run_int_scaled_mm_benchmark
def run_int_scaled_mm_benchmark(x, w, b):scales = x.sum(-1, keepdim=True)fp_time = benchmark_in_ms(10, 100, lambda x, w, s: torch.mm(x, w) * s, x, w, scales)x_int = x.to(dtype=torch.int8)w_int = w.to(dtype=torch.int8)int_scaled_mm_time = benchmark_in_ms(10, 100, int_scaled_matmul, x_int, w_int, scales)return fp_time, i...
1
9
3
98
5
62
70
62
null
['int_scaled_mm_time', 'scales', 'x_int', 'fp_time', 'w_int']
None
null
0
0
0
null
0
null
The function (run_int_scaled_mm_benchmark) defined within the public class called public.The function start at line 62 and ends at 70. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [62.0] and does not return any value..
pytorch_ao
public
public
0
0
run_benchmarks
def run_benchmarks(shapes):print("fn,m,k,n,fp_time,int_mm_time,ratio")dtype = torch.bfloat16device = "cuda"for fn, (m, k, n) in itertools.product([run_int_mm_benchmark, run_int_scaled_mm_benchmark], shapes):x = torch.randn(m, k, dtype=dtype, device=device)w = torch.randn(n, k, dtype=dtype, device=device).t()b = torch.r...
2
14
1
147
7
73
87
73
null
['device', 'x', 'b', 'dtype', 'w', 'result', 'ratio']
None
null
0
0
0
null
0
null
The function (run_benchmarks) defined within the public class called public.The function start at line 73 and ends at 87. It contains 14 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
bench_fwd_bwd_microseconds.fwd_bwd
def fwd_bwd(*args, **kwargs):out = fn(*args, **kwargs)loss = F.mse_loss(out, labels)loss.backward()
1
4
2
34
0
11
14
11
null
[]
None
null
0
0
0
null
0
null
The function (bench_fwd_bwd_microseconds.fwd_bwd) defined within the public class called public.The function start at line 11 and ends at 14. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [11.0] and does not return any value..
pytorch_ao
public
public
0
0
bench_fwd_bwd_microseconds
def bench_fwd_bwd_microseconds(fn, *args, labels=None, use_compile=False, fullgraph=True, **kwargs):assert labels is not Nonedef fwd_bwd(*args, **kwargs):out = fn(*args, **kwargs)loss = F.mse_loss(out, labels)loss.backward()fwd_bwd_compiled = (torch.compile(fwd_bwd, fullgraph=fullgraph) if use_compile else fwd_bwd)retu...
2
13
6
60
3
6
23
6
null
['fwd_bwd_compiled', 'out', 'loss']
None
null
0
0
0
null
0
null
The function (bench_fwd_bwd_microseconds) defined within the public class called public.The function start at line 6 and ends at 23. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [6.0] and does not return any value..
pytorch_ao
public
public
0
0
bench_fwd_microseconds.inference_fn
def inference_fn(*args, **kwargs):with torch.no_grad():return fn_compiled(*args, **kwargs)
1
3
2
25
0
29
31
29
null
[]
None
null
0
0
0
null
0
null
The function (bench_fwd_microseconds.inference_fn) defined within the public class called public.The function start at line 29 and ends at 31. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [29.0] and does not return any value..
pytorch_ao
public
public
0
0
bench_fwd_microseconds
def bench_fwd_microseconds(fn, *args, use_compile=False, fullgraph=True, **kwargs):fn_compiled = torch.compile(fn, fullgraph=fullgraph) if use_compile else fndef inference_fn(*args, **kwargs):with torch.no_grad():return fn_compiled(*args, **kwargs)return benchmark_cuda_function_in_microseconds(inference_fn,*args,**kwar...
2
8
5
49
1
26
37
26
null
['fn_compiled']
None
null
0
0
0
null
0
null
The function (bench_fwd_microseconds) defined within the public class called public.The function start at line 26 and ends at 37. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [26.0] and does not return any value..
pytorch_ao
public
public
0
0
profile_fwd_bwd
def profile_fwd_bwd(fn,*args,labels=None,use_compile=False,fullgraph=True,profile_name="profile",**kwargs,):assert labels is not Nonefn = torch.compile(fn, fullgraph=fullgraph) if use_compile else fnwait, warmup, active = 1, 3, 1total_steps = wait + warmup + activewith torch.profiler.profile(activities=[torch.profiler....
3
31
7
182
4
40
72
40
null
['fn', 'total_steps', 'out', 'loss']
None
null
0
0
0
null
0
null
The function (profile_fwd_bwd) defined within the public class called public.The function start at line 40 and ends at 72. It contains 31 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [40.0] and does not return any value..
pytorch_ao
public
public
0
0
profile_fn
def profile_fn(fn, *args, profile_name="profile", distributed=False, **kwargs):wait, warmup, active = 1, 1, 1total_steps = wait + warmup + activewith torch.profiler.profile(activities=[torch.profiler.ProfilerActivity.CPU,torch.profiler.ProfilerActivity.CUDA,],schedule=torch.profiler.schedule(wait=wait, warmup=warmup, a...
4
20
5
147
2
75
96
75
null
['total_steps', '_']
None
null
0
0
0
null
0
null
The function (profile_fn) defined within the public class called public.The function start at line 75 and ends at 96. It contains 20 lines of code and it has a cyclomatic complexity of 4. It takes 5 parameters, represented as [75.0] and does not return any value..
pytorch_ao
public
public
0
0
benchmark_cuda_function_in_microseconds
def benchmark_cuda_function_in_microseconds(f, *args, **kwargs):return do_bench(lambda: f(*args, **kwargs), return_mode="median") * 1e3
1
2
3
31
0
99
100
99
null
[]
None
null
0
0
0
null
0
null
The function (benchmark_cuda_function_in_microseconds) defined within the public class called public.The function start at line 99 and ends at 100. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [99.0] and does not return any value..
pytorch_ao
public
public
0
0
quantize_model_and_save
def quantize_model_and_save(model_id, quant_config, output_dir="results"):"""Quantize the model and save it to the output directory."""print("Quantizing model with config: ", quant_config)if quant_config is None:quantization_config = Noneelse:quantization_config = TorchAoConfig(quant_type=quant_config)quantized_model =...
2
16
3
91
3
18
34
18
null
['quantization_config', 'tokenizer', 'quantized_model']
None
null
0
0
0
null
0
null
The function (quantize_model_and_save) defined within the public class called public.The function start at line 18 and ends at 34. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [18.0] and does not return any value..
pytorch_ao
public
public
0
0
run_lm_eval
def run_lm_eval(model_dir, tasks_list=["hellaswag"], device="cuda:0", batch_size=8):"""Run the lm_eval command using subprocess."""tasks_str = ",".join(tasks_list)command = ["lm_eval","--model","hf","--model_args",f"pretrained={model_dir}","--tasks",f"{tasks_str}","--device",f"{device}","--batch_size",f"{batch_size}",]...
1
16
4
68
2
37
53
37
null
['tasks_str', 'command']
None
null
0
0
0
null
0
null
The function (run_lm_eval) defined within the public class called public.The function start at line 37 and ends at 53. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [37.0] and does not return any value..
pytorch_ao
public
public
0
0
get_model_size_in_bytes.flat_size
def flat_size(tensor):if hasattr(tensor, "__tensor_flatten__"):size = 0# 0th element is a list of attributes that# hold tensorsfor attr_name in tensor.__tensor_flatten__()[0]:sub_tensor = getattr(tensor, attr_name)size += flat_size(sub_tensor)return sizeelse:return tensor.numel() * tensor.element_size()
3
9
1
58
0
63
73
63
null
[]
None
null
0
0
0
null
0
null
The function (get_model_size_in_bytes.flat_size) defined within the public class called public.The function start at line 63 and ends at 73. It contains 9 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
get_model_size_in_bytes
def get_model_size_in_bytes(model, ignore_embeddings=False):"""Returns the model size in bytes. The option to ignore embeddingsis useful for models with disproportionately large embeddings comparedto other model parameters that get quantized/sparsified."""def flat_size(tensor):if hasattr(tensor, "__tensor_flatten__"):s...
5
11
2
85
3
56
83
56
null
['model_size', 'size', 'sub_tensor']
None
null
0
0
0
null
0
null
The function (get_model_size_in_bytes) defined within the public class called public.The function start at line 56 and ends at 83. It contains 11 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [56.0] and does not return any value..
pytorch_ao
public
public
0
0
run
def run(model_id,quantization,tasks,device,batch_size,model_output_dir,):print(f"Running model {model_id} with quantization {quantization}")model_name = model_id.split("/")[-1]model_output_dir = f"quantized_model/{model_name}-{quantization}"quant_config = string_to_config(quantization, None)quantized_model, tokenizer =...
1
26
6
115
5
86
111
86
null
['model_output_dir', 'model_size', 'quantized_model', 'quant_config', 'model_name']
None
null
0
0
0
null
0
null
The function (run) defined within the public class called public.The function start at line 86 and ends at 111. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [86.0] and does not return any value..
pytorch_ao
public
public
0
0
create_benchmark_result
def create_benchmark_result(benchmark_name: str,shape: List[int],metric_name: str,metric_values: List[float],quant_type: str,device: str,torch_compile_mode: str,metric_extra_info: Dict[str, Any] = {},) -> Dict[str, Any]:"""Create a benchmark result in the PyTorch OSS benchmark database format.Args:benchmark_name: Name ...
4
48
8
198
2
35
100
35
null
['benchmark_device', 'mkn_name']
None
null
0
0
0
null
0
null
The function (create_benchmark_result) defined within the public class called public.The function start at line 35 and ends at 100. It contains 48 lines of code and it has a cyclomatic complexity of 4. It takes 8 parameters, represented as [35.0] and does not return any value..
pytorch_ao
public
public
0
0
run_ci_benchmarks
def run_ci_benchmarks(config_path: str) -> List[Dict[str, Any]]:"""Run benchmarks using configurations from YAML file and return results in OSS format.Args:config_path: Path to the benchmark configuration fileReturns:List of benchmark results in the PyTorch OSS benchmark database format"""# Load configuration using exi...
3
57
1
331
7
103
174
103
null
['configs', 'baseline_time_result', 'results', 'speedup_result', 'quantize_time_result', 'allocated_memory_result', 'result']
None
null
0
0
0
null
0
null
The function (run_ci_benchmarks) defined within the public class called public.The function start at line 103 and ends at 174. It contains 57 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
main
def main():torch.manual_seed(42)parser = argparse.ArgumentParser(description="Run microbenchmarks and output results in PyTorch OSS benchmark database format")parser.add_argument("--config",type=str,required=True,help="Path to benchmark configuration file",)parser.add_argument("--output",type=str,default="benchmark_res...
1
22
0
102
3
177
203
177
null
['results', 'parser', 'args']
None
null
0
0
0
null
0
null
The function (main) defined within the public class called public.The function start at line 177 and ends at 203. It contains 22 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
benchmark_torch_function_in_microseconds
def benchmark_torch_function_in_microseconds(func: Callable,*args,**kwargs,) -> float:t0 = benchmark.Timer(stmt="func(*args, **kwargs)",globals={"args": args, "kwargs": kwargs, "func": func},)return t0.blocked_autorange().median * 1e6
1
10
3
53
1
52
61
52
null
['t0']
None
null
0
0
0
null
0
null
The function (benchmark_torch_function_in_microseconds) defined within the public class called public.The function start at line 52 and ends at 61. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [52.0] and does not return any value..
pytorch_ao
public
public
0
0
ref_tops_sec
def ref_tops_sec(self):M, K, N = self.shapereturn float(3 * (2 * M * K * N)) / self.ref_time_sec
1
3
1
33
0
77
79
77
null
[]
None
null
0
0
0
null
0
null
The function (ref_tops_sec) defined within the public class called public.The function start at line 77 and ends at 79. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
ref_pct_top_peak
def ref_pct_top_peak(self):return self.ref_tops_sec / dtype_to_peak_tops[self.dtype]
1
2
1
16
0
82
83
82
null
[]
None
null
0
0
0
null
0
null
The function (ref_pct_top_peak) defined within the public class called public.The function start at line 82 and ends at 83. 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
float8_tops_sec
def float8_tops_sec(self):M, K, N = self.shapereturn float(3 * (2 * M * K * N)) / self.float8_time_sec
1
3
1
33
0
86
88
86
null
[]
None
null
0
0
0
null
0
null
The function (float8_tops_sec) defined within the public class called public.The function start at line 86 and ends at 88. 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
float8_pct_top_peak
def float8_pct_top_peak(self):return self.float8_tops_sec / dtype_to_peak_tops[torch.float8_e4m3fn]
1
2
1
16
0
91
92
91
null
[]
None
null
0
0
0
null
0
null
The function (float8_pct_top_peak) defined within the public class called public.The function start at line 91 and ends at 92. 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
main.float8_forw_backward
def float8_forw_backward():linear_float8(input_tensor).sum().backward()
1
2
0
16
0
173
174
173
null
[]
None
null
0
0
0
null
0
null
The function (main.float8_forw_backward) 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
main.main.n_times.wrapper
def wrapper(*args, **kwargs):for _ in range(n):fn(*args, **kwargs)
2
3
2
25
0
177
179
177
null
[]
None
null
0
0
0
null
0
null
The function (main.main.n_times.wrapper) defined within the public class called public.The function start at line 177 and ends at 179. It contains 3 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [177.0] and does not return any value..
pytorch_ao
public
public
0
0
main.n_times
def n_times(n, fn, *args, **kwargs):def wrapper(*args, **kwargs):for _ in range(n):fn(*args, **kwargs)return wrapper
1
3
4
17
0
176
181
176
null
[]
None
null
0
0
0
null
0
null
The function (main.n_times) defined within the public class called public.The function start at line 176 and ends at 181. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [176.0] and does not return any value..
pytorch_ao
public
public
0
0
main
def main(sweep_path: Optional[Path] = None,compile: bool = True,n_limit: Optional[int] = None,fast_accum_filter: Optional[bool] = None,shape_name_filter: Optional[str] = None,*,shape_gen_name: str = "llama",M: Optional[int] = None,K: Optional[int] = None,N: Optional[int] = None,scaling_type_input: str = "dynamic",scali...
13
167
13
811
28
97
287
97
null
['scaling_type_input', 'config', 'cast_config_input', 'data_pd', 'scaling_granularity', 'ref_time', 'float8_forw_backward', 'ref_forw_backward', 'experiment', 'device', 'scaling_type_grad_output', 'REPEAT_N', 'cast_config_weight', 'linear_float8', 'float8_time', 'name_to_shapes', 'use_fast_accum', 'data_pd_simple', 'in...
None
null
0
0
0
null
0
null
The function (main) defined within the public class called public.The function start at line 97 and ends at 287. It contains 167 lines of code and it has a cyclomatic complexity of 13. It takes 13 parameters, represented as [97.0] and does not return any value..
pytorch_ao
public
public
0
0
invoke_main
def invoke_main() -> None:parser = argparse.ArgumentParser()parser.add_argument("-o", "--output_path", type=str, required=False)parser.add_argument("--disable_compile", action="store_true")parser.add_argument("-n", "--n_limit", type=int, required=False)parser.add_argument("--shape_gen_name", type=str, required=False)pa...
10
42
0
385
4
290
331
290
null
['output_path', 'parser', 'args', 'kwargs']
None
null
0
0
0
null
0
null
The function (invoke_main) defined within the public class called public.The function start at line 290 and ends at 331. It contains 42 lines of code and it has a cyclomatic complexity of 10. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
run.do_matmul_fp8
def do_matmul_fp8(A, B):nonlocal scale_anonlocal scale_breturn torch._scaled_mm(A, B, scale_a, scale_b, out_dtype=d3, use_fast_accum=fast_accum)
1
6
2
32
0
135
140
135
null
[]
None
null
0
0
0
null
0
null
The function (run.do_matmul_fp8) defined within the public class called public.The function start at line 135 and ends at 140. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [135.0] and does not return any value..
pytorch_ao
public
public
0
0
run.do_matmul_mxfp4
def do_matmul_mxfp4(A, B):nonlocal scale_anonlocal scale_breturn mx_fp4_bf16(A, B, scale_a, scale_b)
1
4
2
22
0
142
145
142
null
[]
None
null
0
0
0
null
0
null
The function (run.do_matmul_mxfp4) defined within the public class called public.The function start at line 142 and ends at 145. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [142.0] and does not return any value..
pytorch_ao
public
public
0
0
run.do_matmul_nvfp4
def do_matmul_nvfp4(A, B):nonlocal scale_anonlocal scale_breturn torch._scaled_mm(A, B, scale_a, scale_b, out_dtype=dtype)
1
4
2
28
0
147
150
147
null
[]
None
null
0
0
0
null
0
null
The function (run.do_matmul_nvfp4) defined within the public class called public.The function start at line 147 and ends at 150. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [147.0] and does not return any value..
pytorch_ao
public
public
0
0
run.do_grouped_mm
def do_grouped_mm(A, B):return torch._grouped_mm(A, B, use_fast_accum=fast_accum)
1
2
2
20
0
152
153
152
null
[]
None
null
0
0
0
null
0
null
The function (run.do_grouped_mm) defined within the public class called public.The function start at line 152 and ends at 153. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [152.0] and does not return any value..
pytorch_ao
public
public
0
0
run.do_scaled_grouped_mm
def do_scaled_grouped_mm(A, B):nonlocal scale_anonlocal scale_breturn torch._scaled_grouped_mm(A, B, scale_a, scale_b, use_fast_accum=fast_accum)
1
6
2
28
0
155
160
155
null
[]
None
null
0
0
0
null
0
null
The function (run.do_scaled_grouped_mm) defined within the public class called public.The function start at line 155 and ends at 160. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [155.0] and does not return any value..
pytorch_ao
public
public
0
0
run
def run(n_limit: Optional[int] = None,shape_gen_name: str = "pow2_extended",out_filename: Optional[str] = None,M: Optional[int] = None,K: Optional[int] = None,N: Optional[int] = None,use_gpu_kernel_time: bool = True,recipe: str = "tensorwise",):device = "cuda"# TODO(future PR): this is uglyassert recipe in ("tensorwise...
19
132
8
792
23
25
199
25
null
['use_fp4', 'specs', 'scale_a', 'results', 'device', 'do_matmul', 'fp4_peak_tops', 'peak_tops', 'm_ref', 'fp8_peak_tops', 'e4m3_dtype', 'name_to_shapes', 'B', 'headers', 'scale_b', 'dtype', 'bf16_peak_tops', 'A', 'A_hp', 'B_hp_t', 'data_df', 'fast_accum_vals', 'tops']
None
null
0
0
0
null
0
null
The function (run) defined within the public class called public.The function start at line 25 and ends at 199. It contains 132 lines of code and it has a cyclomatic complexity of 19. It takes 8 parameters, represented as [25.0] and does not return any value..
pytorch_ao
public
public
0
0
main
def main() -> None:fire.Fire(run)
1
2
0
12
0
202
203
202
null
[]
None
null
0
0
0
null
0
null
The function (main) defined within the public class called public.The function start at line 202 and ends at 203. 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
benchmark_fn_in_usec
def benchmark_fn_in_usec(f, *args, **kwargs):no_args = lambda: f(*args, **kwargs)time = do_bench_using_profiling(no_args)return time * 1e3
1
4
3
33
2
40
43
40
null
['no_args', 'time']
None
null
0
0
0
null
0
null
The function (benchmark_fn_in_usec) defined within the public class called public.The function start at line 40 and ends at 43. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [40.0] and does not return any value..