{"id":18508854,"url":"https://github.com/flaport/klujax","last_synced_at":"2026-01-20T14:02:59.689Z","repository":{"id":60174895,"uuid":"372940078","full_name":"flaport/klujax","owner":"flaport","description":"Solve sparse linear systems in JAX using the KLU algorithm","archived":false,"fork":false,"pushed_at":"2025-05-13T19:03:36.000Z","size":231,"stargazers_count":36,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T21:48:24.560Z","etag":null,"topics":["autograd","jax","klu","klu-algorithm","python","solve","solver","sparse-linear-solver","sparse-linear-systems","sparse-matrices","sparse-matrix","suitesparse"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flaport.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":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-06-01T19:26:37.000Z","updated_at":"2025-07-25T02:08:33.000Z","dependencies_parsed_at":"2025-02-23T11:20:50.296Z","dependency_job_id":"08cc37d5-3d1e-415f-a648-c13e46225cb3","html_url":"https://github.com/flaport/klujax","commit_stats":{"total_commits":83,"total_committers":2,"mean_commits":41.5,"dds":"0.012048192771084376","last_synced_commit":"f28f3db564ae28cb91991b43aa9842f021e36215"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/flaport/klujax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaport%2Fklujax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaport%2Fklujax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaport%2Fklujax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaport%2Fklujax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flaport","download_url":"https://codeload.github.com/flaport/klujax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaport%2Fklujax/sbom","scorecard":{"id":402577,"data":{"date":"2025-08-11","repo":{"name":"github.com/flaport/klujax","commit":"2fa020b7e9a80ed330c9a34e79dbecc0eb9d05c5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"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":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/13 approved changesets -- score normalized to 0","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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:78: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:88: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:93: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:98: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/flaport/klujax/main.yml/main?enable=pin","Info:   0 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Lesser General Public License v2.1: 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":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/main.yml:61"],"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 0.4.3 not signed: https://api.github.com/repos/flaport/klujax/releases/218379207","Warn: release artifact 0.4.2 not signed: https://api.github.com/repos/flaport/klujax/releases/217133774","Warn: release artifact 0.4.1 not signed: https://api.github.com/repos/flaport/klujax/releases/204217692","Warn: release artifact 0.4.0 not signed: https://api.github.com/repos/flaport/klujax/releases/202155502","Warn: release artifact 0.3.1 not signed: https://api.github.com/repos/flaport/klujax/releases/185019697","Warn: release artifact 0.4.3 does not have provenance: https://api.github.com/repos/flaport/klujax/releases/218379207","Warn: release artifact 0.4.2 does not have provenance: https://api.github.com/repos/flaport/klujax/releases/217133774","Warn: release artifact 0.4.1 does not have provenance: https://api.github.com/repos/flaport/klujax/releases/204217692","Warn: release artifact 0.4.0 does not have provenance: https://api.github.com/repos/flaport/klujax/releases/202155502","Warn: release artifact 0.3.1 does not have provenance: https://api.github.com/repos/flaport/klujax/releases/185019697"],"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 19 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"}}]},"last_synced_at":"2025-08-18T20:24:38.574Z","repository_id":60174895,"created_at":"2025-08-18T20:24:38.574Z","updated_at":"2025-08-18T20:24:38.574Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28604712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T12:01:53.233Z","status":"ssl_error","status_checked_at":"2026-01-20T12:01:46.545Z","response_time":117,"last_error":"SSL_read: 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":["autograd","jax","klu","klu-algorithm","python","solve","solver","sparse-linear-solver","sparse-linear-systems","sparse-matrices","sparse-matrix","suitesparse"],"created_at":"2024-11-06T15:15:38.324Z","updated_at":"2026-01-20T14:02:59.684Z","avatar_url":"https://github.com/flaport.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# KLUJAX\n\n\u003e version: 0.4.6\n\nA sparse linear solver for JAX based on the efficient [KLU algorithm](https://ufdcimages.uflib.ufl.edu/UF/E0/01/17/21/00001/palamadai_e.pdf).\n\n## CPU \u0026 float64\n\nThis library is a wrapper around the [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse) KLU\nalgorithms. This means the algorithm is only implemented for\nC-arrays and hence is **only available for CPU\narrays with double precision**, i.e. float64 or complex128.\n\nNote that `float32`/`complex64` arrays will be cast to `float64`/`complex128`!\n\n## Usage\n\nThe `klujax` library provides a single function `solve(Ai, Aj, Ax, b)`, which solves for `x` in\nthe sparse linear system `Ax=b`, where `A` is explicitly given in COO-format (`Ai`, `Aj`, `Ax`).\n\n\u003e NOTE: the sparse matrix represented by (`Ai`, `Aj`, `Ax`) needs to be [coalesced](https://pytorch.org/docs/stable/sparse.html#uncoalesced-sparse-coo-tensors)!\n\u003e KLUJAX provides a `coalesce` function (which unfortunately is not jax-jittable).\n\nSupported shapes (`?` suffix means optional):\n\n- `Ai`: `(n_nz,)`\n- `Aj`: `(n_nz,)`\n- `Ax`: `(n_lhs?, n_nz)`\n- `b`: `(n_lhs?, n_col, n_rhs?)`\n- `A` (represented by (`Ai`, `Aj`, `Ax`)): (`n_lhs?`, `n_col`, `n_col`)\n\nKLUJAX will automatically select a sensible way to act on underdefined dimensions of Ax\nand b:\n\n| dim(Ax) | dim(b) | assumed shape(Ax) | assumed shape(b)      |\n| ------- | ------ | ----------------- | --------------------- |\n| 1D      | 1D     | n_nz              | n_col                 |\n| 1D      | 2D     | n_nz              | n_col x n_rhs         |\n| 1D      | 3D     | n_nz              | n_lhs x n_col x n_rhs |\n| 2D      | 1D     | n_lhs x n_nz      | n_col                 |\n| 2D      | 2D     | n_lhs x n_nz      | n_lhs x n_col         |\n| 2D      | 3D     | n_lhs x n_nz      | n_lhs x n_col x n_rhs |\n\nWhere the `A` is always acting on the `n_col` dimension of `b`. The `n_lhs` dim is a\nshared batch dimension between `A` and `b`.\n\nAdditional dimensions can be added with `jax.vmap` (alternatively any higher dimensional\nproblem can be reduced to the one above by properly transposing and reshaping `Ax` and `b`).\n\n\u003e NOTE: JAX now has an experimental sparse library (`jax.experimental.sparse`). Using\n\u003e this natively in KLUJAX is not yet supported (but converting from `BCOO` or `COO` to\n\u003e `Ai`, `Aj`, `Ax` is trivial).\n\n## Basic Example\n\nScript:\n\n```python\nimport klujax\nimport jax.numpy as jnp\n\nb = jnp.array([8, 45, -3, 3, 19])\nA_dense = jnp.array(\n    [\n        [2, 3, 0, 0, 0],\n        [3, 0, 4, 0, 6],\n        [0, -1, -3, 2, 0],\n        [0, 0, 1, 0, 0],\n        [0, 4, 2, 0, 1],\n    ]\n)\nAi, Aj = jnp.where(jnp.abs(A_dense) \u003e 0)\nAx = A_dense[Ai, Aj]\n\nresult_ref = jnp.linalg.inv(A_dense) @ b\nresult = klujax.solve(Ai, Aj, Ax, b)\n\nprint(jnp.abs(result - result_ref) \u003c 1e-12)\nprint(result)\n```\n\nOutput:\n\n```\n[ True True True True True]\n[1. 2. 3. 4. 5.]\n```\n\n## Installation\n\nThe library is statically linked to the SuiteSparse C++ library. It can be installed on\nmost platforms as follows:\n\n```bash\npip install klujax\n```\n\n**There exist pre-built wheels for Linux and Windows (python 3.8+).** If no compatible\nwheel is found, however, pip will attempt to install the library from source... make\nsure you have the necessary build dependencies installed (see [Installing from Source](#installing-from-source))\n\n## Installing from Source\n\n\u003e NOTE: Installing from source should only be necessary when developing the library. If\n\u003e you as the user experience an install from source please create an issue.\n\nBefore installing, clone the build dependencies:\n\n```sh\ngit clone --depth 1 --branch v7.2.0 https://github.com/DrTimothyAldenDavis/SuiteSparse suitesparse\ngit clone --depth 1 --branch main https://github.com/openxla/xla xla\ngit clone --depth 1 --branch stable https://github.com/pybind/pybind11 pybind11\n```\n\n### Linux\n\nOn linux, you'll need `gcc` and `g++`, then inside the repo:\n\n```sh\npip install .\n```\n\n### MacOs\n\nOn MacOS, you'll need `clang`, then inside the repo:\n\n```sh\npip install .\n```\n\n### Windows\n\nOn Windows, installing from source is a bit more involved as typically the build\ndependencies are not installed. To install those, download Visual Studio Community 2017\nfrom [here](https://my.visualstudio.com/Downloads?q=visual%20studio%202017\u0026wt.mc_id=o~msft~vscom~older-downloads). During installation, go to Workloads and select the following workloads:\n\n- Desktop development with C++\n- Python development\n\nThen go to Individual Components and select the following additional items:\n\n- C++/CLI support\n- VC++ 2015.3 v14.00 (v140) toolset for desktop\n\nThen, download and install Microsoft Visual C++ Redistributable from [here](https://aka.ms/vs/16/release/vc_redist.x64.exe).\n\nAfter these installation steps, run the following commands inside a x64 Native Tools\nCommand Prompt for VS 2017:\n\n```cmd\nset DISTUTILS_USE_SDK=1\npip install .\n```\n\n## License \u0026 Credits\n\n© Floris Laporte 2022, LGPL-2.1\n\nThis library was partly based on:\n\n- [torch_sparse_solve](https://github.com/flaport/torch_sparse_solve), LGPL-2.1\n- [SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse), LGPL-2.1\n- [kagami-c/PyKLU](https://github.com/kagami-c/PyKLU), LGPL-2.1\n- [scipy.sparse](https://github.com/scipy/scipy/tree/master/scipy/sparse), BSD-3\n\nThis library vendors an unmodified version of the\n[SuiteSparse](https://github.com/DrTimothyAldenDavis/SuiteSparse) libraries in its source\n(.tar.gz) distribution to allow for static linking.\nThis is in accordance with their\n[LGPL licence](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaport%2Fklujax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaport%2Fklujax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaport%2Fklujax/lists"}