-
Notifications
You must be signed in to change notification settings - Fork 450
[Refactor][CI] Reduce sparse related test time #1637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,20 +97,13 @@ def gemm_sp_fp16( | |
| return gemm_sp_fp16 | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description="Autotuned MatMul Benchmark") | ||
| parser.add_argument("--m", type=int, default=16384, help="Matrix dimension M") | ||
| parser.add_argument("--n", type=int, default=16384, help="Matrix dimension N") | ||
| parser.add_argument("--k", type=int, default=16384, help="Matrix dimension K") | ||
| parser.add_argument("--accum_dtype", type=str, default=T.float, choices=[T.float, T.float16], help="Accumulation datatype") | ||
| parser.add_argument("--cfg", type=str, choices=["4090", "h20"], default="4090") | ||
| args = parser.parse_args() | ||
| kernel = matmul_sp_fp16(args.m, args.n, args.k, args.accum_dtype, **DEFAULT_CONFIG[args.cfg][args.accum_dtype]) | ||
| def main(M=1024, N=1024, K=1024, accum_dtype=T.float, cfg="h20"): | ||
| kernel = matmul_sp_fp16(M, N, K, accum_dtype, **DEFAULT_CONFIG[cfg][accum_dtype]) | ||
|
|
||
| a = randn_semi_sparse(args.m, args.k, device="cuda", dtype=torch.half) | ||
| b = torch.randn(args.k, args.n, device="cuda", dtype=torch.half) | ||
| a = randn_semi_sparse(M, K, device="cuda", dtype=torch.half) | ||
| b = torch.randn(K, N, device="cuda", dtype=torch.half) | ||
|
|
||
| a_sparse, e = compress(a, transposed=False, block_k=DEFAULT_CONFIG[args.cfg][args.accum_dtype]["block_K"], arch=arch) | ||
| a_sparse, e = compress(a, transposed=False, block_k=DEFAULT_CONFIG[cfg][accum_dtype]["block_K"], arch=arch) | ||
| c = kernel(a_sparse, e, b) | ||
|
|
||
| ref_c = a @ b | ||
|
|
@@ -122,12 +115,19 @@ def main(): | |
| latency = do_bench(lambda: kernel(a_sparse, e, b)) | ||
| ref_latency = do_bench(lambda: a @ b) | ||
|
|
||
| total_flops = 2 * args.m * args.n * args.k | ||
| total_flops = 2 * M * N * K | ||
| tflops = total_flops / latency / 1e9 | ||
| ref_tflops = total_flops / ref_latency / 1e9 | ||
| print(f"Sparse TFLOPS: {tflops:.2f}, Latency: {latency / 1e3} s") | ||
| print(f"Reference TFLOPS: {ref_tflops:.2f}, Latency: {ref_latency / 1e3:} s") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| parser = argparse.ArgumentParser(description="Autotuned MatMul Benchmark") | ||
| parser.add_argument("--m", type=int, default=16384, help="Matrix dimension M") | ||
| parser.add_argument("--n", type=int, default=16384, help="Matrix dimension N") | ||
| parser.add_argument("--k", type=int, default=16384, help="Matrix dimension K") | ||
| parser.add_argument("--accum_dtype", type=str, default=T.float, choices=[T.float, T.float16], help="Accumulation datatype") | ||
| parser.add_argument("--cfg", type=str, choices=["4090", "h20"], default="4090") | ||
|
Comment on lines
+130
to
+131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Argparse type mismatch for Same issue as in Proposed fix- parser.add_argument("--accum_dtype", type=str, default=T.float, choices=[T.float, T.float16], help="Accumulation datatype")
+ parser.add_argument("--accum_dtype", type=str, default="float", choices=["float", "float16"], help="Accumulation datatype")Then map in the call: + dtype_map = {"float": T.float, "float16": T.float16}
- main(M=args.m, N=args.n, K=args.k, accum_dtype=args.accum_dtype, cfg=args.cfg)
+ main(M=args.m, N=args.n, K=args.k, accum_dtype=dtype_map[args.accum_dtype], cfg=args.cfg)
|
||
| args = parser.parse_args() | ||
| main(M=args.m, N=args.n, K=args.k, accum_dtype=args.accum_dtype, cfg=args.cfg) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argparse type mismatch for
accum_dtype.The
--accum_dtypeargument is declared withtype=strbutchoices=[T.float, T.float16]contains type objects, not strings. Additionally, the default isT.float(a type object). This configuration is inconsistent: if a user passes--accum_dtype float, argparse will compare the string"float"againstT.float, which will fail validation.Proposed fix
Then map the string to the type in the main call:
🤖 Prompt for AI Agents