{"id":19444367,"url":"https://github.com/athemathmo/maxmin_cuda","last_synced_at":"2025-06-13T00:08:26.151Z","repository":{"id":66349469,"uuid":"176027246","full_name":"AtheMathmo/maxmin_cuda","owner":"AtheMathmo","description":"CUDA implementation of the MaxMin activation","archived":false,"fork":false,"pushed_at":"2021-07-06T16:58:15.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-25T08:19:48.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/AtheMathmo.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}},"created_at":"2019-03-16T21:34:40.000Z","updated_at":"2021-07-06T16:58:18.000Z","dependencies_parsed_at":"2023-02-21T12:45:38.134Z","dependency_job_id":null,"html_url":"https://github.com/AtheMathmo/maxmin_cuda","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AtheMathmo/maxmin_cuda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtheMathmo%2Fmaxmin_cuda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtheMathmo%2Fmaxmin_cuda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtheMathmo%2Fmaxmin_cuda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtheMathmo%2Fmaxmin_cuda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtheMathmo","download_url":"https://codeload.github.com/AtheMathmo/maxmin_cuda/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtheMathmo%2Fmaxmin_cuda/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259553128,"owners_count":22875610,"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":[],"created_at":"2024-11-10T16:06:47.268Z","updated_at":"2025-06-13T00:08:26.124Z","avatar_url":"https://github.com/AtheMathmo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA implementation of the MaxMin activation function\n\nThis repository provides a CUDA implementation of the MaxMin activation function, via a pytorch extension.\n\nThe MaxMin activation was first introduced as the [OPLU unit](https://arxiv.org/abs/1604.02313), and later as a special case of the [GroupSort activation function](https://arxiv.org/abs/1811.05381). It is especially useful for neural networks which incorporate norm constraints (e.g. Lipschitz-constrained neural networks or orthogonal RNNs).\n\n_The original pytorch GroupSort implementation can be found [here](https://github.com/cemanil/LNets), with a slightly newer version [here](https://github.com/ColinQiyangLi/LConvNet)._\n\n## Installation\n\nThe extension can be installed simply with `python setup.py install`, and then subsequently imported as\n\n```python\nfrom maxmin import MaxMin\n```\n\nAn implementation using standard pytorch ops is also available in `maxmin/maxmin_py`, and can be imported as\n\n```python\nfrom maxmin import PyMaxMin\n```\n\n## Benchmarking\n\nSome quick benchmarking, applying MaxMin to a random matrix of size (50000,5000), and averaging over 5000 trials.\n\n| Method        | CUDA?           | Fwd Avg Time (us)  | Bckwd Avg Time (us)  |\n| ------------- |:-------------:| -----:|-----:|\n| Default Pytorch | [ ] | 365 | 286 |\n| Default Pytorch | [x] |   93  | 320 |\n| This Repo       | [ ] |  1004 | 1057 |\n| This Repo       | [x] |    37 | 247 |\n\nIn short, the implementation in this repo is moderately faster than the GPU implementation using default pytorch ops. However, the CPU implementation is slower than the default method (so if you need a good CPU implementation then use that one). It is also worth noting that the default implementation is still plenty fast for most practical purposes.\n\n## Notes\n\n- Improved error handling is needed on the C++ side.\n- A specialized CUDA implementation of the more general GroupSort is harder to implement, and won't give substantial gains over the default pytorch operations. Therefore is isn't planned for now.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathemathmo%2Fmaxmin_cuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathemathmo%2Fmaxmin_cuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathemathmo%2Fmaxmin_cuda/lists"}