{"id":37082971,"url":"https://github.com/sun-umn/pygranso","last_synced_at":"2026-01-14T10:02:24.859Z","repository":{"id":41827686,"uuid":"440683474","full_name":"sun-umn/PyGRANSO","owner":"sun-umn","description":"PyGRANSO: A PyTorch-enabled port of GRANSO with auto-differentiation","archived":false,"fork":false,"pushed_at":"2025-10-17T20:53:08.000Z","size":11986,"stargazers_count":42,"open_issues_count":9,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-21T20:14:38.901Z","etag":null,"topics":["computer-vision","data-science","deep-learning","machine-learning","mathematical-software","numerical-optimization"],"latest_commit_sha":null,"homepage":"https://ncvx.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sun-umn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-22T00:06:24.000Z","updated_at":"2025-07-02T21:42:37.000Z","dependencies_parsed_at":"2025-07-02T22:22:35.365Z","dependency_job_id":"9de2feba-8aa3-47fa-8726-c3580b7da12d","html_url":"https://github.com/sun-umn/PyGRANSO","commit_stats":{"total_commits":543,"total_committers":8,"mean_commits":67.875,"dds":"0.35543278084714547","last_synced_commit":"fb044600525545cdec9c152054209214e48eecd5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sun-umn/PyGRANSO","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sun-umn%2FPyGRANSO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sun-umn%2FPyGRANSO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sun-umn%2FPyGRANSO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sun-umn%2FPyGRANSO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sun-umn","download_url":"https://codeload.github.com/sun-umn/PyGRANSO/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sun-umn%2FPyGRANSO/sbom","scorecard":{"id":858434,"data":{"date":"2025-08-11","repo":{"name":"github.com/sun-umn/PyGRANSO","commit":"2a1efc2b4180e33f61c48f2fe44fa0680c569103"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Maintained","score":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":1,"reason":"Found 2/18 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Affero General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2022-180 / GHSA-m87f-39q9-6f55","Warn: Project is vulnerable to: PYSEC-2022-212 / GHSA-v7vq-3x77-87vg","Warn: Project is vulnerable to: GHSA-6p56-wp2h-9hxr","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114","Warn: Project is vulnerable to: GHSA-3749-ghw9-m3mg","Warn: Project is vulnerable to: PYSEC-2022-43015 / GHSA-47fc-vmwq-366v","Warn: Project is vulnerable to: PYSEC-2025-41 / GHSA-53q9-r3pm-6pq6","Warn: Project is vulnerable to: PYSEC-2024-252 / GHSA-5pcm-hx3q-hm94","Warn: Project is vulnerable to: GHSA-887c-mr87-cxwp","Warn: Project is vulnerable to: PYSEC-2024-251 / GHSA-pg7h-5qx3-wjr3","Warn: Project is vulnerable to: PYSEC-2024-250","Warn: Project is vulnerable to: PYSEC-2024-259"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T00:33:18.126Z","repository_id":41827686,"created_at":"2025-08-24T00:33:18.126Z","updated_at":"2025-08-24T00:33:18.126Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["computer-vision","data-science","deep-learning","machine-learning","mathematical-software","numerical-optimization"],"created_at":"2026-01-14T10:02:24.048Z","updated_at":"2026-01-14T10:02:24.835Z","avatar_url":"https://github.com/sun-umn.png","language":"Python","readme":"# PyGRANSO\n\n![PyGRANSO](./PyGRANSO_logo_banner.png)\n\n\nPyGRANSO: A PyTorch-enabled port of GRANSO with auto-differentiation\n\nPlease check https://ncvx.org for detailed instructions (introduction, installation, settings, examples...).\n\nPyGRANSO is AGPL v3.0 licensed, but it also contains a small portion of GPL code.  Please see the LICENSE_INFO folder for more information.\n\n## Brief Introduction\n\nOptimizing nonconvex (NCVX) problems, especially nonsmooth and constrained ones, is an essential part of machine learning. However, it can be hard to reliably solve such problems without optimization expertise. Existing general-purpose NCVX optimization packages are powerful but typically cannot handle nonsmoothness. GRANSO is among the first optimization solvers targeting general nonsmooth NCVX problems with nonsmooth constraints, but, as it is implemented in MATLAB and requires the user to provide analytical gradients, GRANSO is often not a convenient choice in machine learning (especially deep learning) applications. To greatly lower the technical barrier, we introduce a new software package called NCVX, whose initial release contains the solver PyGRANSO, a PyTorch-enabled port of GRANSO incorporating auto-differentiation, GPU acceleration, tensor input, and support for new QP solvers. NCVX is built on freely available and widely used open-source frameworks, and as a highlight, can solve general constrained deep learning problems, the first of its kind.\n\n## Installation\n\nInstalling PyGRANSO is simple. Here is a step-by-step instruction:\n\n1. Install [Python \u003e= 3.9](https://www.python.org/)\n\n2. Get the most recent PyGRANSO package (including examples and requirements file):\n\n        git clone https://github.com/sun-umn/PyGRANSO.git\n        cd PyGRANSO\n\n3.  Install PyGRANSO solver from PyPI:\n\n        pip install git+https://github.com/sun-umn/PyGRANSO.git\n\n4. Install Dependencies from PyPI: \n\n    OS: **Linux** OR **Windows**; Compute Platform: **CUDA**:\n\n        pip install -r requirements.txt -f https://download.pytorch.org/whl/cu111/torch_stable.html\n\n    OS: **Linux**; Compute Platform: **CPU**:\n\n        pip install -r requirements_linux_cpu.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html\n\n    OS: **Mac** OR **Windows**; Compute Platform: **CPU**:\n\n        pip install -r requirements_cpu.txt\n    \n5. (CUDA) Run test to make sure the dependency installation is correct:\n\n        python test_cuda.py\n\n    (CPU) Run test to make sure the dependency installation is correct:\n\n        python test_cpu.py\n\n6. Check the [example folder](./examples) in the source code or [example section](https://ncvx.org/examples) on the documentation website to get started.\n\n## Dependencies\n    Python-3.9.7\n\n    numpy-1.20.3\n\n    scipy-1.7.1\n\n    pytorch-1.9.0\n\n    osqp-0.6.2\n\n    Jupyter Notebook-6.4.5\n\n    gurobi\n\n## Change Logs\n\nPlease check [CHANGELOG.md](./CHANGELOG.md) in the main folder.\n\n## Notes on Documentation\n\nPyGRANSO is a PyTorch-enabled port of GRANSO with auto-differentiation, and some of its documentation uses MATLAB conventions. In the PyGRANSO source code docstrings, please note that:\n\n* `struct` refers to `pygransoStruct`, which is a simple class that users need to use for specifying their problems and options.\n* Vector and matrix refer to PyTorch tensor with *(n,1)* and *(m,n)* dimension, respectively. \n\n\n## Acknowledgements\n\nWe would like to thank [Frank E. Curtis](https://coral.ise.lehigh.edu/frankecurtis/) and [Michael L. Overton](https://cs.nyu.edu/~overton/) for their involvement in creating the BFGS-SQP algorithm that is \nimplemented in the software package [GRANSO](http://www.timmitchell.com/software/GRANSO). This work was supported by UMII Seed Grant Program and NSF CMMI 2038403.\n\n## Citation\n\nIf you publish work that uses or refers to PyGRANSO, please cite the following two papers,\nwhich respectively introduced PyGRANSO and GRANSO:\n\n*[1] Buyun Liang, Tim Mitchell, and Ju Sun, NCVX: A General-Purpose Optimization Solver for Constrained Machine and Deep Learning, arXiv preprint arXiv:2210.00973 (2022). Available at https://arxiv.org/abs/2210.00973*\n\n*[2] Frank E. Curtis, Tim Mitchell, and Michael L. Overton,\n    A BFGS-SQP method for nonsmooth, nonconvex, constrained\n    optimization and its evaluation using relative minimization\n    profiles, Optimization Methods and Software, 32(1):148-181, 2017.*\n    Available at https://dx.doi.org/10.1080/10556788.2016.1208749  \n\nBibTex:\n\n    @article{liang2021ncvx,\n        title={{NCVX}: {A} User-Friendly and Scalable Package for Nonconvex \n        Optimization in Machine Learning}, \n        author={Buyun Liang, Tim Mitchell, and Ju Sun},\n        year={2021},\n        eprint={2111.13984},\n        archivePrefix={arXiv},\n        primaryClass={cs.LG}\n    }\n    \n    @article{curtis2017bfgssqp,\n        title={A {BFGS-SQP} method for nonsmooth, nonconvex, constrained optimization and its evaluation using relative minimization profiles},\n        author={Frank E. Curtis, Tim Mitchell, and Michael L. Overton},\n        journal={Optimization Methods and Software},\n        volume={32},\n        number={1},\n        pages={148--181},\n        year={2017},\n        publisher={Taylor \\\u0026 Francis}\n    }\n\n## Contact\nFor questions or bug reports, please either:\n- raise issues in the [PyGRANSO repository](https://github.com/sun-umn/PyGRANSO/) or\n- send an email to our [NCVX PyGRANSO forum](https://groups.google.com/a/umn.edu/g/ncvx): ncvx@umn.edu\n\nMain authors:\n\n  - [Buyun Liang](https://buyunliang.org/) (*byliang an_at_symbol seas a_dot_symbol upenn a_dot_symbol edu*)\n  - [Tim Mitchell](http://www.timmitchell.com/) (*tim an_at_symbol timmitchell a_dot_symbol com*)\n  - [Ju Sun](https://sunju.org/) (*jusun an_at_symbol umn a_dot_symbol edu*)\n\nThanks to other contributors and bug reporters: \n\n- [Hengyue Liang](https://hengyuel.github.io/): Applied PyGRANSO on adversarial robustness problems. Tested PyGRANSO across multiple platforms. Debugged several functions.\n\n- Wenjie Zhang: Tested practical techniques on various constrained deep learning problems, which can be used to accelerate the convergence of PyGRANSO.\n\n- [Ryan de Vera](https://github.com/rydevera3): Applied PyGRANSO on neural topology optimization problems.\n\n- Yash Travadi: Applied PyGRANSO on imbalanced classification problems.\n\n- [Ying Cui](https://sites.google.com/site/optyingcui/home): Advised the adversarial robustness problems.\n\n- [Chen Jiang](https://github.com/shoopshoop): Tested perceptual attack example (ex6). Tested PyGRANSO on Win10. Debugged updatePenaltyParameter function.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsun-umn%2Fpygranso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsun-umn%2Fpygranso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsun-umn%2Fpygranso/lists"}