Skip to main content

A collection of inverse design challenges

Project description

invrs-gym - A collection of inverse design challenges

v0.3.6

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

# 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)
    distance = challenge.distance_to_target(response)
    metrics = challenge.metrics(response, params, aux)
    return loss, (response, distance, 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, distance, metrics, aux)), grad = value_and_grad_fn(params)
    state = opt.update(grad=grad, value=value, params=params, state=state)

With some plotting (see the example notebook), this code will produce the following waveguide bend:

Animated evolution of waveguide bend design

Challenges

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

Install

pip install invrs_gym

Testing

Some tests are marked as slow and are skipped by default. To run these manually, use

pytest --runslow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

invrs_gym-0.3.6.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

invrs_gym-0.3.6-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file invrs_gym-0.3.6.tar.gz.

File metadata

  • Download URL: invrs_gym-0.3.6.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for invrs_gym-0.3.6.tar.gz
Algorithm Hash digest
SHA256 b2c81f1aef5343021bb000b69439d29bcb1b5c73490ec77f72fa5f357200b313
MD5 319e9fc59ddff19f44e09f4a8358b7a5
BLAKE2b-256 43028cce5aa6103240b9de33309c6141da531e6d1fa80186974db4f72cee735d

See more details on using hashes here.

File details

Details for the file invrs_gym-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: invrs_gym-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 48.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for invrs_gym-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e124ec729fa4ef09e50b3c29437974992857a1e8b77c33480114da699e3fe9a0
MD5 c99373cee638f68044e203ade58dcbb4
BLAKE2b-256 19ebe53423e75f3bf4182bb07606e2c206c6a4f41e66a7854b320e8dd3382c1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page