Angular-Multiplexed Transformer Optical Model
Transformer attention scores from optical interference — with an exact match to scaled dot-product attention.
Encode query and key as amplitudes with binary phase (0 / π). Interference then recovers the real inner product term by term:
Re(q_wave · conj(k_wave)) = q · k
so the score matrix is identical to QKᵀ / √d. That is the mechanism claim:
a physical two-level phase encoding is not an approximation to attention
scores; under that encoding it is attention scores. The identity is
unit-tested; the hybrid stack runs it on real model weights.
Architecture: optical (or optical-model) path computes scores; digital path handles softmax, values, MLP, norms, and the lm head — a deliberate hybrid split, not a half-finished pure-optical fantasy.
SmolLM2-135M-Instruct (Hugging Face safetensors, all 30 layers):
- Optical-score greedy decode matches digital-score decode on fixed and natural-language prompts
- Full-forward logits: 100% top-1 agreement on the logged short sequence
That run shows the mechanism plugged into a full transformer, not only a toy matmul.
Details: evidence · result log
| Piece | Role |
|---|---|
atom/attention.py |
Interference score algebra |
atom/hybrid_model.py |
Safetensors / GGUF hybrid generate |
atom/capacity.py |
M#-aware capacity model |
atom/refresh.py |
Readout-erase / rewrite planning stub |
atom/rack.py |
Multi-crystal placement (datacenter-style scale-out) |
fpga/ |
Digital hybrid path scaffold for measured energy/latency later |
pip install -e .
pip install torch safetensors transformers pytestDo not commit model weight files.
python examples/16_safetensors_text_eval.py \
--model /path/to/SmolLM2-135M-Instruct \
--prompt "The capital of France is" \
--max-new 4
pytest tests/test_certainty.py -qThis repo is the software and systems foundation: exact score mechanism, hybrid inference, capacity/refresh/rack planning, FPGA hooks.
A physical photorefractive write/read loop is future work — not claimed as done. Geometric storage ceilings and material defaults are models with stated assumptions; see validation audit when citing capacity or hardware numbers.