Optical Weight Simulator

Simulation · 4 nm length grid

Optical weights
for SmolLM2

We encode each trained weight as the length difference between two waveguides. When the light recombines, interference applies the weight to the input. A chip with fixed weights could reuse them for every token and reduce reads from memory.

Fixed optical readoutλ 1550 nm

The largest planet in our solar system is

Jupiter

41.0%next-token probability

Readout calculation

We ran both prompts through all 30 layers in PyTorch. The browser uses the saved final state to compute scores for Jupiter and Paris from two fixed rows of weights. The diagram shows one of 144 blocks. The probability uses all 49,152 token scores.

Fixed optical weights
134,479,872
Length grid spacing
4 nm
Next-token agreement
561 / 572

SmolLM2-135M · 16-bit phase model

Next-token prediction

Select a saved example or run all 30 layers on your own text. This model encodes weights as 16-bit phase values. The fixed design above rounds waveguide lengths to 4 nm steps.

First live run downloads 269 MB of phase settings.

Model output49,152 tokens

Predicted next token

…

Five most likely tokens

    Saved model run

    Append the predicted token to use it as the next input.

    Layer outputs

    Each layer has seven weight matrices. The proposed chip uses light for these matrix products. Electronics handle attention between tokens, normalization, nonlinear functions and memory. The final matrix gives one score per token.

    Hidden state across the model—
    Layer 1102030

    Each bar shows the root mean square (RMS) of 576 values at the last input position after one layer. Select a bar to inspect it.

    Four inputs · Two outputs · 1550 nm

    Optical field propagation

    Each input splits into two paths and recombines after a phase shift. The two output ports contribute to the scores of the leading tokens.

    The curves show the real part of the optical field along each path.

    Encoded weight
    —
    Phase shift θ
    —
    Equivalent arm length difference
    —
    Upper arm field
    —
    Lower arm field
    —
    Cell signal field
    —

    Token scores

    Each block combines four inputs per output. The signed contributions from 144 blocks sum to the token score.

    TokenOutput fieldContributionRunning score
    A———
    B———

    Field equations and assumptions

    For each matrix we set s = max |weight| and encode each weight as θ = arccos(weight / s) on a 16-bit phase scale. Arm phases of +θ and −θ differ by 2θ. For light at 1550 nm in a waveguide with effective index 1.45, an arm length difference of 1550 θ / (π × 1.45) nanometers gives that phase difference. The mean optical path length stays fixed to preserve the phase reference.

    We scale four components of the hidden state to unit norm and split each field equally between the two token channels. For branch input a, the second coupler yields a cos(θ) at the signal port and a sin(θ) at the unused port. A four-way combiner adds the signal fields with a factor of 1/2. Phase-referenced readout preserves the sign. We restore the input norm, matrix scale and optical gains before summing the blocks.

    The simulation assumes ideal lossless cells. The diagram enlarges and slows the carrier for visibility. Both colors represent the same wavelength.

    8-bit model · 48-token limit

    Text generation

    This chat model runs in your browser. We rebuilt it from the 16-bit phase settings and quantized its weights to 8 bits. Quantization and the chat template can change its predictions.

    The model download is 145 MB.

    ARC-Easy · 64 prompts

    Effect of weight precision

    We rounded the waveguide length differences to three grid spacings. On the first 64 ARC-Easy test prompts, each model received the same preceding tokens. We counted how often its next token matched the original model.

    4 nm design

    561 / 572

    next-token choices matched the original SmolLM2. On 54 of 64 prompts, every tested position matched.

    Agreement with the original model
    Weight encodingMatching choices
    1 nm length grid570 / 572
    16 nm length grid528 / 572
    16-bit phase control572 / 572

    Each grid uses one fixed gain per group of up to 128 weights in a row. The simulations use FP32 and ideal optical components. Chip speed, energy and cost per token still require hardware measurements.

    Compare individual answers from the 16-bit control

    Original model

    —

    Model rebuilt from phases

    —

    Proposed hardware test

    Eight-cell optical block

    We plan to apply four known inputs to a block with fixed waveguide lengths and compare its two measured outputs with the simulation.

    Register if you can fabricate or test the block, or would like the results.

    Download the bench design