jeig


Namejeig JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryVarious eigendecomposition implementations wrapped for jax.
upload_time2024-12-17 16:30:10
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseBSD 3-Clause License Copyright (c) 2024, Martin Schubert Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords jax eigendecomposition eig torch scipy numpy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jeig - Eigendecompositions wrapped for jax
`v0.2.1`

## Overview

This package wraps eigendecompositions as provided by jax, magma, numpy, scipy, and torch for use with jax. Depending upon your system and your versions of these packages, you may observe significant speed differences. The following were obtained using jax 0.4.37 on a system with 28-core Intel Xeon w7-3465X and NVIDIA RTX4090.

![Speed comparison](https://github.com/mfschubert/jeig/blob/main/docs/speed.png?raw=true)

## Install
jeig can be installed via pip,
```
pip install jeig
```
This will also install torch. If you only need torch for use with jeig, then the CPU-only version could be sufficient and you may wish to install manually as described in the [pytorch docs](https://pytorch.org/get-started/locally/).

## Example usage

```python
import jax
import jeig

matrix = jax.random.normal(jax.random.PRNGKey(0), (16, 1024, 1024))

%timeit jax.block_until_ready(jeig.eig(matrix, backend="jax"))

%timeit jax.block_until_ready(jeig.eig(matrix, backend="magma"))

%timeit jax.block_until_ready(jeig.eig(matrix, backend="numpy"))

%timeit jax.block_until_ready(jeig.eig(matrix, backend="scipy"))

%timeit jax.block_until_ready(jeig.eig(matrix, backend="torch"))
```
```
6.81 s ± 54.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
1min 15s ± 1.35 s per loop (mean ± std. dev. of 7 runs, 1 loop each)
28.6 s ± 341 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
14.8 s ± 396 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
1.43 s ± 77.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```

## Credit
The torch implementation of eigendecomposition is due to a [comment](https://github.com/google/jax/issues/10180#issuecomment-1092098074) by @YouJiacheng.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jeig",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Martin Schubert <mfschubert@gmail.com>",
    "keywords": "jax, eigendecomposition, eig, torch, scipy, numpy",
    "author": null,
    "author_email": "Martin Schubert <mfschubert@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b7/d6/a7d660ccf32cba568dbc65c7a0528117874176957d4e92ec26492e31f088/jeig-0.2.1.tar.gz",
    "platform": null,
    "description": "# jeig - Eigendecompositions wrapped for jax\n`v0.2.1`\n\n## Overview\n\nThis package wraps eigendecompositions as provided by jax, magma, numpy, scipy, and torch for use with jax. Depending upon your system and your versions of these packages, you may observe significant speed differences. The following were obtained using jax 0.4.37 on a system with 28-core Intel Xeon w7-3465X and NVIDIA RTX4090.\n\n![Speed comparison](https://github.com/mfschubert/jeig/blob/main/docs/speed.png?raw=true)\n\n## Install\njeig can be installed via pip,\n```\npip install jeig\n```\nThis will also install torch. If you only need torch for use with jeig, then the CPU-only version could be sufficient and you may wish to install manually as described in the [pytorch docs](https://pytorch.org/get-started/locally/).\n\n## Example usage\n\n```python\nimport jax\nimport jeig\n\nmatrix = jax.random.normal(jax.random.PRNGKey(0), (16, 1024, 1024))\n\n%timeit jax.block_until_ready(jeig.eig(matrix, backend=\"jax\"))\n\n%timeit jax.block_until_ready(jeig.eig(matrix, backend=\"magma\"))\n\n%timeit jax.block_until_ready(jeig.eig(matrix, backend=\"numpy\"))\n\n%timeit jax.block_until_ready(jeig.eig(matrix, backend=\"scipy\"))\n\n%timeit jax.block_until_ready(jeig.eig(matrix, backend=\"torch\"))\n```\n```\n6.81 s \u00b1 54.2 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n1min 15s \u00b1 1.35 s per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n28.6 s \u00b1 341 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n14.8 s \u00b1 396 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n1.43 s \u00b1 77.7 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)\n```\n\n## Credit\nThe torch implementation of eigendecomposition is due to a [comment](https://github.com/google/jax/issues/10180#issuecomment-1092098074) by @YouJiacheng.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2024, Martin Schubert  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "Various eigendecomposition implementations wrapped for jax.",
    "version": "0.2.1",
    "project_urls": null,
    "split_keywords": [
        "jax",
        " eigendecomposition",
        " eig",
        " torch",
        " scipy",
        " numpy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbef3d1f7a95f395ed2e093e1b1213da3e45e7b65075b366faacfdfcc6e438c4",
                "md5": "868ea728a31fff61a4edfdc2ffbcd0e8",
                "sha256": "5d2626969ff92a173d980599dd382aa39166a02c897be69d372bd1d3aa8433cd"
            },
            "downloads": -1,
            "filename": "jeig-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "868ea728a31fff61a4edfdc2ffbcd0e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6142,
            "upload_time": "2024-12-17T16:30:08",
            "upload_time_iso_8601": "2024-12-17T16:30:08.350544Z",
            "url": "https://files.pythonhosted.org/packages/cb/ef/3d1f7a95f395ed2e093e1b1213da3e45e7b65075b366faacfdfcc6e438c4/jeig-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7d6a7d660ccf32cba568dbc65c7a0528117874176957d4e92ec26492e31f088",
                "md5": "69adde1f2cf5a79771a0a2840865bfa4",
                "sha256": "ba5bd9c81c027887e20aec77b28af3dcd2ddbcf0262f55faff6d3166578d5557"
            },
            "downloads": -1,
            "filename": "jeig-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "69adde1f2cf5a79771a0a2840865bfa4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6239,
            "upload_time": "2024-12-17T16:30:10",
            "upload_time_iso_8601": "2024-12-17T16:30:10.594051Z",
            "url": "https://files.pythonhosted.org/packages/b7/d6/a7d660ccf32cba568dbc65c7a0528117874176957d4e92ec26492e31f088/jeig-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 16:30:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "jeig"
}
        
Elapsed time: 0.59785s