jaxtyping


Namejaxtyping JSON
Version 0.2.28 PyPI version JSON
download
home_page
SummaryType annotations and runtime checking for shape and dtype of JAX arrays, and PyTrees.
upload_time2024-03-07 17:31:29
maintainer
docs_urlNone
author
requires_python~=3.9
licenseMIT License Copyright (c) 2022 Google LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- Sections of the code were modified from https://github.com/agronholm/typeguard under the terms of the MIT license, reproduced below. --- MIT License Copyright (c) Alex Grönholm Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords deep-learning equinox jax neural-networks typing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">jaxtyping</h1>

Type annotations **and runtime type-checking** for:

1. shape and dtype of [JAX](https://github.com/google/jax) arrays; *(Now also supports PyTorch, NumPy, and TensorFlow!)*
2. [PyTrees](https://jax.readthedocs.io/en/latest/pytrees.html).


**For example:**
```python
from jaxtyping import Array, Float, PyTree

# Accepts floating-point 2D arrays with matching axes
def matrix_multiply(x: Float[Array, "dim1 dim2"],
                    y: Float[Array, "dim2 dim3"]
                  ) -> Float[Array, "dim1 dim3"]:
    ...

def accepts_pytree_of_ints(x: PyTree[int]):
    ...

def accepts_pytree_of_arrays(x: PyTree[Float[Array, "batch c1 c2"]]):
    ...
```

## Installation

```bash
pip install jaxtyping
```

Requires Python 3.9+.

JAX is an optional dependency, required for a few JAX-specific types. If JAX is not installed then these will not be available, but you may still use jaxtyping to provide shape/dtype annotations for PyTorch/NumPy/TensorFlow/etc.

The annotations provided by jaxtyping are compatible with runtime type-checking packages, so it is common to also install one of these. The two most popular are [typeguard](https://github.com/agronholm/typeguard) (which exhaustively checks every argument) and [beartype](https://github.com/beartype/beartype) (which checks random pieces of arguments).

## Documentation

Available at [https://docs.kidger.site/jaxtyping](https://docs.kidger.site/jaxtyping).

## Finally

### See also: other libraries in the JAX ecosystem

[Equinox](https://github.com/patrick-kidger/equinox): neural networks.

[Optax](https://github.com/deepmind/optax): first-order gradient (SGD, Adam, ...) optimisers.

[Diffrax](https://github.com/patrick-kidger/diffrax): numerical differential equation solvers.

[Optimistix](https://github.com/patrick-kidger/optimistix): root finding, minimisation, fixed points, and least squares.

[Lineax](https://github.com/google/lineax): linear solvers.

[BlackJAX](https://github.com/blackjax-devs/blackjax): probabilistic+Bayesian sampling.

[Orbax](https://github.com/google/orbax): checkpointing (async/multi-host/multi-device).

[sympy2jax](https://github.com/google/sympy2jax): SymPy<->JAX conversion; train symbolic expressions via gradient descent.

[Eqxvision](https://github.com/paganpasta/eqxvision): computer vision models.

[Levanter](https://github.com/stanford-crfm/levanter): scalable+reliable training of foundation models (e.g. LLMs).

[PySR](https://github.com/milesCranmer/PySR): symbolic regression. (Non-JAX honourable mention!)

### Disclaimer

This is not an official Google product.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "jaxtyping",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.9",
    "maintainer_email": "",
    "keywords": "deep-learning,equinox,jax,neural-networks,typing",
    "author": "",
    "author_email": "Patrick Kidger <contact@kidger.site>",
    "download_url": "https://files.pythonhosted.org/packages/47/fb/be2d0183f5cb48227cf32adf4aef70740b44c26c43146990261bbe9e989a/jaxtyping-0.2.28.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">jaxtyping</h1>\n\nType annotations **and runtime type-checking** for:\n\n1. shape and dtype of [JAX](https://github.com/google/jax) arrays; *(Now also supports PyTorch, NumPy, and TensorFlow!)*\n2. [PyTrees](https://jax.readthedocs.io/en/latest/pytrees.html).\n\n\n**For example:**\n```python\nfrom jaxtyping import Array, Float, PyTree\n\n# Accepts floating-point 2D arrays with matching axes\ndef matrix_multiply(x: Float[Array, \"dim1 dim2\"],\n                    y: Float[Array, \"dim2 dim3\"]\n                  ) -> Float[Array, \"dim1 dim3\"]:\n    ...\n\ndef accepts_pytree_of_ints(x: PyTree[int]):\n    ...\n\ndef accepts_pytree_of_arrays(x: PyTree[Float[Array, \"batch c1 c2\"]]):\n    ...\n```\n\n## Installation\n\n```bash\npip install jaxtyping\n```\n\nRequires Python 3.9+.\n\nJAX is an optional dependency, required for a few JAX-specific types. If JAX is not installed then these will not be available, but you may still use jaxtyping to provide shape/dtype annotations for PyTorch/NumPy/TensorFlow/etc.\n\nThe annotations provided by jaxtyping are compatible with runtime type-checking packages, so it is common to also install one of these. The two most popular are [typeguard](https://github.com/agronholm/typeguard) (which exhaustively checks every argument) and [beartype](https://github.com/beartype/beartype) (which checks random pieces of arguments).\n\n## Documentation\n\nAvailable at [https://docs.kidger.site/jaxtyping](https://docs.kidger.site/jaxtyping).\n\n## Finally\n\n### See also: other libraries in the JAX ecosystem\n\n[Equinox](https://github.com/patrick-kidger/equinox): neural networks.\n\n[Optax](https://github.com/deepmind/optax): first-order gradient (SGD, Adam, ...) optimisers.\n\n[Diffrax](https://github.com/patrick-kidger/diffrax): numerical differential equation solvers.\n\n[Optimistix](https://github.com/patrick-kidger/optimistix): root finding, minimisation, fixed points, and least squares.\n\n[Lineax](https://github.com/google/lineax): linear solvers.\n\n[BlackJAX](https://github.com/blackjax-devs/blackjax): probabilistic+Bayesian sampling.\n\n[Orbax](https://github.com/google/orbax): checkpointing (async/multi-host/multi-device).\n\n[sympy2jax](https://github.com/google/sympy2jax): SymPy<->JAX conversion; train symbolic expressions via gradient descent.\n\n[Eqxvision](https://github.com/paganpasta/eqxvision): computer vision models.\n\n[Levanter](https://github.com/stanford-crfm/levanter): scalable+reliable training of foundation models (e.g. LLMs).\n\n[PySR](https://github.com/milesCranmer/PySR): symbolic regression. (Non-JAX honourable mention!)\n\n### Disclaimer\n\nThis is not an official Google product.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Google LLC  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.     --- Sections of the code were modified from https://github.com/agronholm/typeguard under the terms of the MIT license, reproduced below. ---  MIT License  Copyright (c) Alex Gr\u00f6nholm  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Type annotations and runtime checking for shape and dtype of JAX arrays, and PyTrees.",
    "version": "0.2.28",
    "project_urls": {
        "repository": "https://github.com/google/jaxtyping"
    },
    "split_keywords": [
        "deep-learning",
        "equinox",
        "jax",
        "neural-networks",
        "typing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a0c8055b6e60e6b2795c1cee6058287c39f168466e5937d6437b58b6c7e77f7",
                "md5": "ca70bb1eb4cad11a4e574e25aef9d5f6",
                "sha256": "4a54eb964087cd46463d9a86c805b4e4f5c20cce5f22049d6f35a26d9f105bd3"
            },
            "downloads": -1,
            "filename": "jaxtyping-0.2.28-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca70bb1eb4cad11a4e574e25aef9d5f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.9",
            "size": 40707,
            "upload_time": "2024-03-07T17:31:28",
            "upload_time_iso_8601": "2024-03-07T17:31:28.010961Z",
            "url": "https://files.pythonhosted.org/packages/9a/0c/8055b6e60e6b2795c1cee6058287c39f168466e5937d6437b58b6c7e77f7/jaxtyping-0.2.28-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47fbbe2d0183f5cb48227cf32adf4aef70740b44c26c43146990261bbe9e989a",
                "md5": "faa788c95760608f6778ba2c2bd57b49",
                "sha256": "cd20bf1558a90c6d77c589354e35670ecc5b94925ef45bf1c020fde7b44fac8d"
            },
            "downloads": -1,
            "filename": "jaxtyping-0.2.28.tar.gz",
            "has_sig": false,
            "md5_digest": "faa788c95760608f6778ba2c2bd57b49",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.9",
            "size": 30439,
            "upload_time": "2024-03-07T17:31:29",
            "upload_time_iso_8601": "2024-03-07T17:31:29.671738Z",
            "url": "https://files.pythonhosted.org/packages/47/fb/be2d0183f5cb48227cf32adf4aef70740b44c26c43146990261bbe9e989a/jaxtyping-0.2.28.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-07 17:31:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "google",
    "github_project": "jaxtyping",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jaxtyping"
}
        
Elapsed time: 0.20739s