{"id":29514191,"url":"https://github.com/gaurisharan/cuda-ml-kernels","last_synced_at":"2026-04-30T12:33:14.590Z","repository":{"id":303253332,"uuid":"1014867965","full_name":"gaurisharan/cuda-ml-kernels","owner":"gaurisharan","description":"Repo for CUDA C++ GPU kernels for ML and HPC.","archived":false,"fork":false,"pushed_at":"2025-07-06T21:34:31.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T12:33:10.247Z","etag":null,"topics":["cpp","cuda","gpu","hpc","kernels","ml","parallel-computing","systems-ml"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaurisharan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-07-06T15:08:53.000Z","updated_at":"2025-07-06T21:50:15.000Z","dependencies_parsed_at":"2025-07-06T16:44:33.185Z","dependency_job_id":null,"html_url":"https://github.com/gaurisharan/cuda-ml-kernels","commit_stats":null,"previous_names":["gaurisharan/cuda-ml-kernels"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gaurisharan/cuda-ml-kernels","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurisharan%2Fcuda-ml-kernels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurisharan%2Fcuda-ml-kernels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurisharan%2Fcuda-ml-kernels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurisharan%2Fcuda-ml-kernels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaurisharan","download_url":"https://codeload.github.com/gaurisharan/cuda-ml-kernels/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaurisharan%2Fcuda-ml-kernels/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp","cuda","gpu","hpc","kernels","ml","parallel-computing","systems-ml"],"created_at":"2025-07-16T14:00:57.397Z","updated_at":"2026-04-30T12:33:14.573Z","avatar_url":"https://github.com/gaurisharan.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA ML Kernels\n\n## 🚀 Motivation\n\nThis repository implements **custom CUDA kernels for common ML operations**, benchmarked against PyTorch's highly optimized cuBLAS/cuDNN kernels. The goal is to:\n\n- Understand GPU parallelization patterns\n- Compare naive kernel performance vs. library implementations\n- Build intuition for ML Systems performance engineering\n\n---\n\n## 📁 Repository Structure\n\n```.\n├── kernels/\n│   ├── matrix_multiply.cu\n│   ├── vector_add.cu\n│   ├── relu.cu\n│   ├── dot_product.cu\n│   ├── intro.cu\n├── benchmarks/\n│   └── benchmark.py\n└── .gitignore\n```\n\n- `kernels/`: CUDA C++ kernel implementations\n- `benchmarks/`: Python script to benchmark kernels vs. PyTorch\n\n---\n\n## ⚡ Kernels Implemented\n\n| Kernel            | Description                       |\n|-------------------|-----------------------------------|\n| `matrix_multiply` | Matrix multiplication (1024x1024) |\n| `vector_add`      | Elementwise vector addition       |\n| `relu`            | ReLU activation function          |\n| `dot_product`     | Vector dot product reduction      |\n| `intro`           | 4x4 matrix multiplication demo    |\n\n---\n\n## 🔧 Build Instructions\n\n1. **Ensure NVIDIA CUDA Toolkit is installed.**\n\n2. **Compile each `.cu` file:**\n\n```bash\ncd kernels\n\nnvcc -o matrix_multiply.exe matrix_multiply.cu\nnvcc -o vector_add.exe vector_add.cu\nnvcc -o relu.exe relu.cu\nnvcc -o dot_product.exe dot_product.cu\nnvcc -o intro.exe intro.cu\n````\n\n\u003e Replace `.exe` with no extension if on Linux/Mac.\n\n---\n\n## 🧪 Running Benchmarks\n\nFrom the repo root:\n\n```bash\ncd benchmarks\npython benchmark.py\n```\n\n---\n\n## 📊 Results Summary\n\n| Kernel             | PyTorch Time (ms) | Custom CUDA Time (ms) | Speedup |\n| ------------------ | ----------------- | --------------------- | ------- |\n| matrix\\_multiply   | 14.28             | 6.95                  | 2.06x   |\n| vector\\_add        | 2.39              | 1.35                  | 1.77x   |\n| relu               | 2.97              | 0.56                  | 5.35x   |\n| dot\\_product       | \\~0               | 1.33                  | Slower  |\n| intro (4x4 matmul) | 2.25              | 1.08                  | 2.09x   |\n\n---\n\n## 💡 Key Insights\n\n* **Matrix multiplication and ReLU** kernels show significant speedups, demonstrating effective GPU thread parallelization.\n* **Vector addition** gains are modest, as PyTorch uses cuBLAS kernels optimized near theoretical peak.\n* **Dot product** is slower due to naive reduction implementation vs. PyTorch's warp-level optimized reductions.\n* **Small matmul (intro)** demonstrates kernel launch overhead optimization benefits.\n\n---\n\n## 📝 Future Improvements\n\n* Implement **warp-level reductions** for dot product\n* Integrate **unit tests** comparing kernel outputs with PyTorch for correctness validation\n* Extend to **batched kernels** relevant for end-to-end ML pipeline acceleration\n\n---\n\n## 👤 Author\n\nGauri Sharan\n\n---\n\n## 📜 License\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaurisharan%2Fcuda-ml-kernels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaurisharan%2Fcuda-ml-kernels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaurisharan%2Fcuda-ml-kernels/lists"}