Verified photonic computing · component 4/5
Photonic attention
The hybrid that real chips ship: linear matmuls (Q, K, V projections, output projection) on the photonic side at light speed; the nonlinear softmax on the electronic side because nonlinearities don't survive a passive photonic mesh. Same EML source describes both domains; one Lean proof covers both.
The same EML source — examples/photonics/hybrid/hybrid_layer.eml — compiles to all five backends: Python (simulation), C (firmware), Lean (proofs), SPICE (electronic control circuit), and KiCad (electronic schematic). One source, two physical domains, one proof.
The math
// Photonic Q/K/V projections (linear, fast).
// Electronic softmax (nonlinear, microseconds).
// Photonic output projection.
@verify(lean, theorem = "hybrid_layer_photonic_identity_at_calibration")
fn photonic_identity_certificate(x: Real) -> Real
ensures (result == x)
{
x
}
@verify(lean, theorem = "hybrid_layer_softmax_uniform_8_eq_one_eighth")
fn softmax_uniform_certificate() -> Real
ensures (result == 0.125) // 1/8 for an 8-token uniform input
{
0.125
}✓ photonic identity at calibration + softmax uniform = 1/n + GELU(0) + LayerNorm@uniform — all closedView source on GitHub →