{"id":20513402,"url":"https://github.com/bruce-lee-ly/cuda_back2back_hgemm","last_synced_at":"2025-04-13T23:51:10.547Z","repository":{"id":184797043,"uuid":"671470490","full_name":"Bruce-Lee-LY/cuda_back2back_hgemm","owner":"Bruce-Lee-LY","description":"Use tensor core to calculate back-to-back HGEMM (half-precision general matrix multiplication) with MMA PTX instruction.","archived":false,"fork":false,"pushed_at":"2023-11-03T13:29:43.000Z","size":874,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T14:01:45.252Z","etag":null,"topics":["back2back-gemm","back2back-hgemm","cublas","cuda","fused-gemm","fused-hgemm","gemm","gpu","hgemm","matrix-multiply","nvidia","tensor-core"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bruce-Lee-LY.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-27T11:47:27.000Z","updated_at":"2024-10-22T21:19:02.000Z","dependencies_parsed_at":"2023-10-10T14:35:49.724Z","dependency_job_id":"5ca640de-1c09-410c-9559-a44a34af1a98","html_url":"https://github.com/Bruce-Lee-LY/cuda_back2back_hgemm","commit_stats":null,"previous_names":["bruce-lee-ly/cuda_back2back_hgemm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_back2back_hgemm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_back2back_hgemm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_back2back_hgemm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_back2back_hgemm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bruce-Lee-LY","download_url":"https://codeload.github.com/Bruce-Lee-LY/cuda_back2back_hgemm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799904,"owners_count":21163400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["back2back-gemm","back2back-hgemm","cublas","cuda","fused-gemm","fused-hgemm","gemm","gpu","hgemm","matrix-multiply","nvidia","tensor-core"],"created_at":"2024-11-15T21:10:51.393Z","updated_at":"2025-04-13T23:51:10.505Z","avatar_url":"https://github.com/Bruce-Lee-LY.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA BACK2BACK HGEMM\nUse tensor core to calculate back-to-back HGEMM (half-precision general matrix multiplication) with MMA PTX instruction. The calculation expression is as follows, where the precision of matrix A (M * K), B (K * N), C (N * L) and D (M * L) is FP16. Tested in special scenarios, the performance can exceed cublas performance by 20% to 120%.\n```\nD (M * L) = A (M * K) * B (K * N) * C (N * L)\nHGEMM0: P (M * N) = A (M * K) * B (K * N)\nHGEMM1: D (M * L) = P (M * N) * C (N * L)\n```\n\n![b2b_hgemm](./media/images/b2b_hgemm.png)\n\n# Optimization Method\n- Simt Naive: naive algorithm using cuda core\n- Mma Naive Reg: naive algorithm using tensor core and transfer the intermediate results through shared memeory\n- Mma Naive Shm: naive algorithm using tensor core and transfer the intermediate results through register\n- Mma Async Reg: async algorithm using tensor core and transfer the intermediate results through shared memeory\n- Mma Async Shm: async algorithm using tensor core and transfer the intermediate results through register\n\n# Compile\n## Environment\n- OS: Linux\n- Cmake Version: \u003e= 3.12\n- GCC Version: \u003e= 4.8\n- CUDA Version: \u003e= 11.0\n- Gflags: install on ubuntu as follows\n```\nsudo apt-get install libgflags-dev\n```\n\n## Clone\n```\ngit clone https://github.com/Bruce-Lee-LY/cuda_back2back_hgemm.git\n```\n\n## Build\n### NVIDIA A100\n```\ncd cuda_back2back_hgemm\n./build.sh -a 80 -t Release -b OFF\n./build.sh -a 80 -t Debug -b OFF\n```\n\n### RTX3080Ti / RTX3090 / RTX A6000\n```\ncd cuda_back2back_hgemm\n./build.sh -a 86 -t Release -b OFF\n./build.sh -a 86 -t Debug -b OFF\n```\n\n# Run Sample\n```\n./run_sample.sh\n```\n\n# Performance\nProcess the data in the log and plot it as a line chart.\n\n```\ncd tools/performance\n./performance.sh\n```\n\n## RTX3090\n- CUDA Version: 11.8\n```\nL = 8\nN = 16\nK = 512\n```\n\nPerformance achieved by current optimization methods.\n\n![throughput](./performance/RTX3090/throughput.png)\n\n![performance](./performance/RTX3090/performance.png)\n\n# TODO\nCurrently only supports N=16 back-to-back HGEMM.\n- N = 32, 64, 128 etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-lee-ly%2Fcuda_back2back_hgemm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruce-lee-ly%2Fcuda_back2back_hgemm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-lee-ly%2Fcuda_back2back_hgemm/lists"}