invrs-gym


Nameinvrs-gym JSON
Version 1.4.3 PyPI version JSON
download
home_pageNone
SummaryA collection of inverse design challenges
upload_time2024-10-14 21:31:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2023 The INVRS-IO authors. 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 topology optimization jax inverse design
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # invrs-gym
`v1.4.3`

## Overview
The `invrs_gym` package is an open-source gym containing a diverse set of photonic design challenges, which are relevant for a wide range of applications such as AR/VR, optical networking, LIDAR, and others.

Each of the challenges consists of a high-dimensional problem in which a physical structure (the photonic device) is optimized. The structure includes typically >10,000 degrees of freedom (DoF), generally including one or more arrays representing the structure or patterning of a layer, and may also include scalar variables representing e.g. layer thickness. In general, the DoF must satisfy certain constraints to be physical: thicknesses must be positive, and layer patterns must be _manufacturable_---they must not include features that are too small, or too closely spaced.

In general, we seek optimization techniques that _reliably_ produce manufacturable, high-quality solutions and require reasonable compute resources. Among the techniques that could be applied are topology optimization, inverse design, and AI-guided design.

`invrs_gym` is intended to facilitate research on such methods within the jax ecosystem. It includes several challenges that have been used in previous works, so that researchers may directly compare their results to those of the literature. While some challenges are test problems (e.g. where the structure is two-dimensional, which is unphysical but allows fast simulation), others are actual problems that are relevant e.g. for quantum computing or 3D sensing.

## Key concepts
The key types of the challenge are the `Challenge` and `Component` objects.

The `Component` represents the physical structure to be optimized, and has some intended excitation or operating condition (e.g. illumination with a particular wavelength from a particular direction). The `Component` includes methods to obtain initial parameters, and to compute the _response_ of a component to the excitation.

Each `Challenge` has a `Component` as an attribute, and also has a target that can be used to determine whether particular parameters "solve" the challenge. The `Challenge` also provides functions to compute a scalar loss for use with gradient-based optimization, and additional metrics.

## Example
```python
# Select the challenge.
challenge = invrs_gym.challenges.ceviche_lightweight_waveguide_bend()

# Define loss function, which also returns auxilliary quantities.
def loss_fn(params):
    response, aux = challenge.component.response(params)
    loss = challenge.loss(response)
    eval_metric = challenge.eval_metric(response)
    metrics = challenge.metrics(response, params, aux)
    return loss, (response, eval_metric, metrics, aux)

value_and_grad_fn = jax.value_and_grad(loss_fn, has_aux=True)

# Select an optimizer.
opt = invrs_opt.density_lbfgsb(beta=4)

# Generate initial parameters, and use these to initialize the optimizer state.
params = challenge.component.init(jax.random.PRNGKey(0))
state = opt.init(params)

# Carry out the optimization.
for i in range(steps):
    params = opt.params(state)
    (value, (response, eval_metric, metrics, aux)), grad = value_and_grad_fn(params)
    state = opt.update(grad=grad, value=value, params=params, state=state)
```
With some plotting, this code will produce the following waveguide bend:

![Animated evolution of waveguide bend design](https://github.com/invrs-io/gym/blob/main/docs/img/waveguide_bend.gif?raw=true)

## Challenges
The current list of challenges is below. Check out the notebooks for ready-to-go examples of each.

- The **bayer sorter** chhallenge involves the design of metasurface that replaces the color filter in an image sensor, and is based on "[Pixel-level Bayer-type colour router based on metasurfaces](https://www.nature.com/articles/s41467-022-31019-7)" by Zou et al.
- The **diffractive splitter** challenge involves designing a non-paraxial diffractive beamsplitter useful for 3D sensing, as discussed in [LightTrans documentation](https://www.lighttrans.com/use-cases/application/design-and-rigorous-analysis-of-non-paraxial-diffractive-beam-splitter.html).
- The **ceviche** challenges are jax-wrapped versions of the [Ceviche Challenges](https://github.com/google/ceviche-challenges) open-sourced by Google, with defaults matching "[Inverse Design of Photonic Devices with Strict Foundry Fabrication Constraints](https://pubs.acs.org/doi/10.1021/acsphotonics.2c00313)" by Schubert et al. These were also studied by Ferber et al. in "[SurCo: Learning Linear SURrogates for COmbinatorial Nonlinear Optimization Problems](https://proceedings.mlr.press/v202/ferber23a/ferber23a.pdf)" by Ferber et al.
- The **meta-atom library** challenge is baed on "[Dispersion-engineered metasurfaces reaching broadband 90% relative diffraction efficiency](https://www.nature.com/articles/s41467-023-38185-2)" by Chen et al., and involves the design of 8 meta-atoms for
- The **metagrating** challenge is a re-implementation of the [Metagrating3D](https://github.com/NanoComp/photonics-opt-testbed/tree/main/Metagrating3D) problem using the [fmmax](https://github.com/facebookresearch/fmmax) simulator.
- The **metalens** challenge is a re-implemenation of the [RGB Metalens](https://github.com/NanoComp/photonics-opt-testbed/tree/main/RGB_metalens) problem using the [fmmax](https://github.com/facebookresearch/fmmax) simulator.
constructing a broadband, polarization-insensitive grating.
- The **photon extractor** challenge is based on "[Inverse-designed photon extractors for optically addressable defect qubits](https://opg.optica.org/optica/fulltext.cfm?uri=optica-7-12-1805)" by Chakravarthi et al., and aims to create structures that increase photon extraction efficiency for quantum applications.


## Install
```
pip install invrs_gym
```

## Testing
Some tests are marked as slow and are skipped by default. To run these manually, use
```
pytest --runslow
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "invrs-gym",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "\"Martin F. Schubert\" <mfschubert@gmail.com>",
    "keywords": "topology, optimization, jax, inverse design",
    "author": null,
    "author_email": "\"Martin F. Schubert\" <mfschubert@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/08/7a/cb848d02ed943bc47a005c35a66b3aee31b71f77f487b66733eafbe6f613/invrs_gym-1.4.3.tar.gz",
    "platform": null,
    "description": "# invrs-gym\n`v1.4.3`\n\n## Overview\nThe `invrs_gym` package is an open-source gym containing a diverse set of photonic design challenges, which are relevant for a wide range of applications such as AR/VR, optical networking, LIDAR, and others.\n\nEach of the challenges consists of a high-dimensional problem in which a physical structure (the photonic device) is optimized. The structure includes typically >10,000 degrees of freedom (DoF), generally including one or more arrays representing the structure or patterning of a layer, and may also include scalar variables representing e.g. layer thickness. In general, the DoF must satisfy certain constraints to be physical: thicknesses must be positive, and layer patterns must be _manufacturable_---they must not include features that are too small, or too closely spaced.\n\nIn general, we seek optimization techniques that _reliably_ produce manufacturable, high-quality solutions and require reasonable compute resources. Among the techniques that could be applied are topology optimization, inverse design, and AI-guided design.\n\n`invrs_gym` is intended to facilitate research on such methods within the jax ecosystem. It includes several challenges that have been used in previous works, so that researchers may directly compare their results to those of the literature. While some challenges are test problems (e.g. where the structure is two-dimensional, which is unphysical but allows fast simulation), others are actual problems that are relevant e.g. for quantum computing or 3D sensing.\n\n## Key concepts\nThe key types of the challenge are the `Challenge` and `Component` objects.\n\nThe `Component` represents the physical structure to be optimized, and has some intended excitation or operating condition (e.g.\u00a0illumination with a particular wavelength from a particular direction). The `Component` includes methods to obtain initial parameters, and to compute the _response_ of a component to the excitation.\n\nEach `Challenge` has a `Component` as an attribute, and also has a target that can be used to determine whether particular parameters \"solve\" the challenge. The `Challenge` also provides functions to compute a scalar loss for use with gradient-based optimization, and additional metrics.\n\n## Example\n```python\n# Select the challenge.\nchallenge = invrs_gym.challenges.ceviche_lightweight_waveguide_bend()\n\n# Define loss function, which also returns auxilliary quantities.\ndef loss_fn(params):\n    response, aux = challenge.component.response(params)\n    loss = challenge.loss(response)\n    eval_metric = challenge.eval_metric(response)\n    metrics = challenge.metrics(response, params, aux)\n    return loss, (response, eval_metric, metrics, aux)\n\nvalue_and_grad_fn = jax.value_and_grad(loss_fn, has_aux=True)\n\n# Select an optimizer.\nopt = invrs_opt.density_lbfgsb(beta=4)\n\n# Generate initial parameters, and use these to initialize the optimizer state.\nparams = challenge.component.init(jax.random.PRNGKey(0))\nstate = opt.init(params)\n\n# Carry out the optimization.\nfor i in range(steps):\n    params = opt.params(state)\n    (value, (response, eval_metric, metrics, aux)), grad = value_and_grad_fn(params)\n    state = opt.update(grad=grad, value=value, params=params, state=state)\n```\nWith some plotting, this code will produce the following waveguide bend:\n\n![Animated evolution of waveguide bend design](https://github.com/invrs-io/gym/blob/main/docs/img/waveguide_bend.gif?raw=true)\n\n## Challenges\nThe current list of challenges is below. Check out the notebooks for ready-to-go examples of each.\n\n- The **bayer sorter** chhallenge involves the design of metasurface that replaces the color filter in an image sensor, and is based on \"[Pixel-level Bayer-type colour router based on metasurfaces](https://www.nature.com/articles/s41467-022-31019-7)\" by Zou et al.\n- The **diffractive splitter** challenge involves designing a non-paraxial diffractive beamsplitter useful for 3D sensing, as discussed in [LightTrans documentation](https://www.lighttrans.com/use-cases/application/design-and-rigorous-analysis-of-non-paraxial-diffractive-beam-splitter.html).\n- The **ceviche** challenges are jax-wrapped versions of the [Ceviche Challenges](https://github.com/google/ceviche-challenges) open-sourced by Google, with defaults matching \"[Inverse Design of Photonic Devices with Strict Foundry Fabrication Constraints](https://pubs.acs.org/doi/10.1021/acsphotonics.2c00313)\" by Schubert et al. These were also studied by Ferber et al. in \"[SurCo: Learning Linear SURrogates for COmbinatorial Nonlinear Optimization Problems](https://proceedings.mlr.press/v202/ferber23a/ferber23a.pdf)\" by Ferber et al.\n- The **meta-atom library** challenge is baed on \"[Dispersion-engineered metasurfaces reaching broadband 90% relative diffraction efficiency](https://www.nature.com/articles/s41467-023-38185-2)\" by Chen et al., and involves the design of 8 meta-atoms for\n- The **metagrating** challenge is a re-implementation of the [Metagrating3D](https://github.com/NanoComp/photonics-opt-testbed/tree/main/Metagrating3D) problem using the [fmmax](https://github.com/facebookresearch/fmmax) simulator.\n- The **metalens** challenge is a re-implemenation of the [RGB Metalens](https://github.com/NanoComp/photonics-opt-testbed/tree/main/RGB_metalens) problem using the [fmmax](https://github.com/facebookresearch/fmmax) simulator.\nconstructing a broadband, polarization-insensitive grating.\n- The **photon extractor** challenge is based on \"[Inverse-designed photon extractors for optically addressable defect qubits](https://opg.optica.org/optica/fulltext.cfm?uri=optica-7-12-1805)\" by Chakravarthi et al., and aims to create structures that increase photon extraction efficiency for quantum applications.\n\n\n## Install\n```\npip install invrs_gym\n```\n\n## Testing\nSome tests are marked as slow and are skipped by default. To run these manually, use\n```\npytest --runslow\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 The INVRS-IO authors.  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": "A collection of inverse design challenges",
    "version": "1.4.3",
    "project_urls": null,
    "split_keywords": [
        "topology",
        " optimization",
        " jax",
        " inverse design"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c4e2f0226d1a157140bc587a3d559080e21dc6f80777ebcb24f6cebef417bef",
                "md5": "6faf9651e3e3c70fe68984e6b9276f4f",
                "sha256": "a1fae9a1f3adf614dc45af37b55bce215f4c14094b8dd30eb068da02da6fbb48"
            },
            "downloads": -1,
            "filename": "invrs_gym-1.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6faf9651e3e3c70fe68984e6b9276f4f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 72421,
            "upload_time": "2024-10-14T21:31:50",
            "upload_time_iso_8601": "2024-10-14T21:31:50.045558Z",
            "url": "https://files.pythonhosted.org/packages/1c/4e/2f0226d1a157140bc587a3d559080e21dc6f80777ebcb24f6cebef417bef/invrs_gym-1.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "087acb848d02ed943bc47a005c35a66b3aee31b71f77f487b66733eafbe6f613",
                "md5": "7e08d307b16a6e3542d2db1e8fd5a9b4",
                "sha256": "c14133df341234448368df5f423020fc3215597f1a8c99e291db183929cae471"
            },
            "downloads": -1,
            "filename": "invrs_gym-1.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7e08d307b16a6e3542d2db1e8fd5a9b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 61184,
            "upload_time": "2024-10-14T21:31:51",
            "upload_time_iso_8601": "2024-10-14T21:31:51.779822Z",
            "url": "https://files.pythonhosted.org/packages/08/7a/cb848d02ed943bc47a005c35a66b3aee31b71f77f487b66733eafbe6f613/invrs_gym-1.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-14 21:31:51",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "invrs-gym"
}
        
Elapsed time: 0.96557s