Skip to main content

AbbeFlow Diagram

AbbeFlow

PyPI version CI PyTorch Python License: MIT Prior: Neural Spline Flow

AbbeFlow is a differentiable, normalizing-flow-based learned prior over the optical glass catalog manifold. Trained on approximately 1,700 real glasses from major manufacturers (including Schott, Ohara, Hoya, and others), AbbeFlow models the distribution of physical glasses in a 4D Buchdahl dispersion coefficient space. It enables continuous, gradient-based lens optimization while ensuring that glass choices remain on or near the realizable manifold.

For details on the mathematical modeling and formulation, see the Theoretical Background documentation.


Installation

Install AbbeFlow via pip:

pip install abbeflow

Core Optimization Paradigms

AbbeFlow supports two main paradigms for continuous glass optimization:

  1. Manifold Penalty Mode: Optimize refractive index $n_d$ and Abbe number $V_d$ directly, adding a regularizing penalty based on the negative log-probability under the learned prior to the optical merit function: $$\mathcal{L} = \mathcal{L}{\text{aberration}} - \lambda{\text{glass}} \log p(n_d, V_d)$$
  2. Latent Space Optimization: Optimize directly in the unconstrained 4D latent space $\mathbf{z} \in \mathbb{R}^4$, mapping back to the physical glass manifold via the decoder $\mathbf{x} = f^{-1}(\mathbf{z})$, which guarantees physically realistic glass parameters.

Quick Start

AbbeFlow provides a pretrained GlassFlow model ready for inference:

from abbeflow import GlassFlow

# Load the pretrained model
gf = GlassFlow.pretrained()

# Compute the log-probability of a glass (manifold prior penalty)
logp = gf.log_prob(nd=1.517, vd=64.2)
print(f"Log probability: {logp.item():.4f}")

# Encode to and decode from the latent space
z = gf.encode(nd=1.517, vd=64.2)
glass = gf.decode(z)
print(f"Decoded glass: nd={glass.nd:.4f}, vd={glass.vd:.2f}")

# Snap to the nearest real catalog glasses
matches = gf.nearest_real(nd=1.517, vd=64.2, k=3)
print("\nNearest catalog glasses:")
for match in matches:
    print(f" - {match.manufacturer} {match.name} (Distance: {match.distance:.4f})")

Examples

The following examples are located in the examples/ directory and demonstrate how to integrate AbbeFlow into various workflows:


API Reference

A detailed overview of all modules, classes, and methods is available in the API Reference documentation.


License

AbbeFlow is released under the MIT License.

Metadata

Release files for abbeflow 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abbeflow 0.2.0
File Size Uploaded
abbeflow-0.2.0.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for abbeflow 0.2.0
File Interpreter ABI Platform
abbeflow-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / abbeflow-0.2.0.tar.gz

Download URL abbeflow-0.2.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
f91968072691d3b877f81732de8713ed51f6ba2f910ebcd2b28e02c9535f6aff
BLAKE2b-256 checksum
How to use checksums
b013b405d4d49d216bad4e65597514934fa0bc8c7da3580c17db6beb5e8777fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 2, 2026.

Transparency log

Release files / abbeflow-0.2.0-py3-none-any.whl

Download URL abbeflow-0.2.0-py3-none-any.whl
Size 293.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce708da2d9dc134c0a962d5f9e80d6e13642bd02a0d8d5f118b60efdd7891318
BLAKE2b-256 checksum
How to use checksums
4773386b305e7786573f51dd465cda13b9ba06fe846aa1ef7827cf94ae9f3413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page