Article

Announcing Optiland v2.0 Beta

We are thrilled to announce the beta release of Optiland v2.0, completely rewritten from the ground up to utilize PyTorch for automatic differentiation.

TH
The Optiland Team
Contributor
Oct 15, 20242 min read
#release#pytorch#gpu

After months of hard work, we're incredibly proud to launch the open beta of Optiland v2.0. This release represents a monumental shift in the underlying architecture of our optical design framework.

Why the Rewrite?

Optiland 1.x was entirely built on NumPy. While stable, the optimization loops relied strictly on finite differences to calculate the Jacobian. For large systems with 50+ variables and thousands of target rays, this meant solving the system NN times per iteration, where NN was the number of variables.

Automatic Differentiation with PyTorch

With v2.0, Optiland converts all optical parameters (curvature, thickness, index) into continuous tensors and leverages PyTorch's autograd engine.

By dropping finite differences in favor of Automatic Differentiation (AD), tracking variables takes a single backwards traversal through the graph, yielding O(1)O(1) scaling relative to the number of design variables.

Our internal benchmarks show a 14x speedup on systems like the Double Gauss lens when pushed through our TorchAdamOptimizer.

Sneak Peek Code

Here's an example of the new Optimizer structure:

python
import optiland as op

# Initialize optical system
sys = op.LensSystem()
sys.add_surface(radius=50.0, thickness=5.0, material='N-BK7')
sys.add_surface(thickness=20.0)

# Set variable
sys.set_variable('radius', surface_idx=0)

# Build problem and minimize RMS spot size
problem = op.OptimizationProblem(sys)
problem.add_operand(op.RMSSpotSize())

optimizer = op.TorchAdamOptimizer(problem, lr=0.01)
optimizer.optimize(max_iters=100)

How to Get the Beta

You can install the 2.0.0b1 version directly from PyPI:

bash
pip install optiland==2.0.0b1

Let us know what you think on the forums or by joining a competition! Our next steps will involve stabilizing the GPU memory caches and releasing the rewritten ray trace GUI module.