pisantifrancesco89/Project-LightSwitch

In-Network & Photonic Neural Compute Simulator (Zero-VRAM, 1.58-bit Ternary Optical Routing Engine)

1

stars

0

commits

Python

primary language

Aug 29, 2026

updated

bitnet
green-ai
in-network-computing
llm-inference
optical-computing
p4-lang
silicon-photonics

README

Project LightSwitch: In-Network & Photonic Neural Compute Simulator

Tests Python License Architecture

"Do not send data to centralized AI data centers: embed intelligence directly into the light traveling through global networks."

๐Ÿ“– Languages: English | ๐Ÿ‡ฎ๐Ÿ‡น Leggi in Italiano (Italian Version)


Project LightSwitch is an experimental software prototype and hardware architecture for In-Network & Photonic Artificial Intelligence Compute. It simulates executing Large Language Model (LLM) inference and matrix transformations directly inside optical fibers, switching cabins, and satellite laser links while packets are in transit, eliminating the GPU Von Neumann memory bottleneck and reducing compute energy by $95% - 98%$.


๐ŸŒŸ Architectural Overview

[ CLIENT (Copper / Wi-Fi) ] 
       โ†“ (Tokenized prompt)
[ SWITCHING CABIN / EDGE PoP (P4 Switch / FPGA) ] โž” Computes Initial Model Layers (15 ns)
       โ†“ (WDM Optical Carrier Modulation @ 1550nm C-Band)
[ TERRESTRIAL & SUBMARINE OPTICAL FIBER ] โž” Photons travel at 200,000 km/s in silica
       โ†“ (Ternary Optical Phase Interference {-1, 0, 1})
[ LEO SATELLITE CONSTELLATION ] โž” Inter-satellite laser links at 300,000 km/s (Speed of light in vacuum)
       โ†“ (Downlink & Token Decapsulation)
[ DESTINATION GATEWAY ] โž” Final output token already computed upon arrival! (Zero GPU queue latency)

Key Innovations & Counter-Defenses:

  1. Zero Multiplications ($100%$ Additive Transforms): Model weights are quantized to 1.58-bit (${-1, 0, 1}$). Floating-point multiplications are replaced by optical constructive/destructive phase interference ($0\text{ FP Multiplications}$).
  2. Eliminating the Softmax Bottleneck: Integrates State-Space Models (Mamba / RWKV Linear SSMs) to compute recurrence ($h_t = Ah_{t-1} + Bx_t$) without $\mathcal{O}(N^2)$ Softmax in-flight.
  3. Physical Noise Resilience: Employs ITU-T G.709 Forward Error Correction (FEC) ensuring Post-FEC Bit Error Rate $\text{BER} < 10^{-15}$ across thousands of kilometers.
  4. Hyperscale Data Center Spine-Leaf Fabric: Applicable immediately inside private Big Tech AI Campus networks, cutting intra-datacenter optical transceiver energy by $>80%$.
  5. Sub-2 Nanosecond Hardware Packet Filter: Switches inspect incoming headers in $< 1.5\text{ ns}$, instantly distinguishing AI prompt packets from everyday Internet traffic (Netflix, Zoom, HTTPS).
  6. Commercial Off-The-Shelf (COTS) Readiness: Can be deployed immediately using accessible hardware: AMD Xilinx UltraScale+ FPGA SmartNICs (โ‚ฌ2,800) or Intel Tofino 2 P4 Switches (โ‚ฌ8,500).

๐Ÿ“‚ Repository Layout

.
โ”œโ”€โ”€ README.md                          # English Documentation & Quickstart
โ”œโ”€โ”€ README_IT.md                       # Italian Documentation & Quickstart
โ”œโ”€โ”€ requirements.txt                   # Optional dependencies (rich, numpy, matplotlib)
โ”œโ”€โ”€ config.py                          # Optical physical constants & simulation parameters
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ encoder.py                     # WDM optical wavelength modulation (C-Band 1530-1565nm)
โ”‚   โ”œโ”€โ”€ switch.py                      # In-network optical switch and in-transit compute engine
โ”‚   โ”œโ”€โ”€ decoder.py                     # Generative text un-embedder and token streaming
โ”‚   โ”œโ”€โ”€ llm_bridge.py                  # Real LLM connector (Ollama / OpenAI / Groq / Fallback)
โ”‚   โ”œโ”€โ”€ state_space_mamba.py           # 1.58-bit linear State-Space (Mamba) recurrent engine
โ”‚   โ””โ”€โ”€ matrix_sparse.py               # 1.58-bit ternary additive engine {-1, 0, 1}
โ”œโ”€โ”€ simulation/
โ”‚   โ”œโ”€โ”€ fiber_channel.py               # Single-mode silica fiber delay & attenuation model (SMF-28)
โ”‚   โ”œโ”€โ”€ pipeline.py                    # Multi-hop end-to-end execution pipeline
โ”‚   โ”œโ”€โ”€ heterogeneous_network.py       # Global WAN model (Copper, P4 Cabins, Fibers, LEO Satellites)
โ”‚   โ”œโ”€โ”€ packet_classifier.py           # Hardware packet classifier (<1.5 ns TCAM parser)
โ”‚   โ”œโ”€โ”€ noise_and_fec.py               # Optical noise model (ASE/Thermal) & ITU-T G.709 FEC
โ”‚   โ””โ”€โ”€ datacenter_spine_leaf.py       # Private AI data center campus Spine-Leaf simulator
โ”œโ”€โ”€ benchmarks/
โ”‚   โ”œโ”€โ”€ metrics.py                     # FLOPs, Latency, and Energy telemetry (picoJoules vs milliJoules)
โ”‚   โ”œโ”€โ”€ compare_gpu.py                 # Mathematical comparison vs NVIDIA H100 GPU server
โ”‚   โ””โ”€โ”€ hardware_costs.py              # 3-Year TCO financial engine (CAPEX & OPEX)
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ WHITEPAPER.md                  # Formal scientific whitepaper & mathematical models
โ”‚   โ”œโ”€โ”€ OBJECTIONS_AND_DEFENSE.md      # Technical defense against top 4 engineering objections
โ”‚   โ”œโ”€โ”€ hardware_architecture.md       # Technical hardware guide for COTS chips & optical interconnects
โ”‚   โ””โ”€โ”€ IMPACT_AND_ROADMAP.md          # Global launch manifesto, grants (EIC Pathfinder), and roadmap
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_all.py                    # Automated test suite (11 tests, 100% passing)
โ”œโ”€โ”€ app.py                             # Interactive Guided Visual Studio & Chat
โ””โ”€โ”€ main.py                            # Interactive CLI with Rich terminal visualization

๐Ÿš€ Quick Start Guide

1. Interactive Studio & Live Chat

python3 app.py

2. Run Automated Test Suite (11 Tests)

python3 -m unittest discover tests

๐Ÿ“Š 3-Year Total Cost of Ownership (TCO) Comparison

Hardware ArchitectureChip TypeCAPEX (Hardware)Power Consumption3-Year Electricity (OPEX)*3-Year Total TCOSavings vs GPU
Traditional AI Server (8x NVIDIA H100)Monolithic GPUโ‚ฌ280,00010,200 Wโ‚ฌ70,815โ‚ฌ350,815Baseline
3x FPGA SmartNIC ClusterAMD Xilinx (COTS)โ‚ฌ8,400225 Wโ‚ฌ1,562โ‚ฌ9,962-97% ๐Ÿš€
3x Programmable P4 Switch ClusterIntel Tofino 2 (COTS)โ‚ฌ25,500750 Wโ‚ฌ5,207โ‚ฌ30,707-91% ๐Ÿš€
3x Silicon Photonics CPO EngineAyar Labs (COTS)โ‚ฌ36,000105 Wโ‚ฌ729โ‚ฌ36,729-90% ๐Ÿš€

*Calculated with industrial electricity rate of โ‚ฌ0.22/kWh and cooling PUE = 1.2.


๐Ÿ“„ Scientific Documentation & Defense

  • ๐Ÿ›ก๏ธ Technical Objections & Counter-Defense: Mathematical answers to Softmax non-linearities, KV-Cache memory in-flight, optical noise, and telecom adoption.
  • ๐Ÿ“– Scientific Whitepaper: Mathematical formulations, Maxwell wave propagation, and theoretical derivation.
  • ๐Ÿ› ๏ธ Hardware Architecture Guide: Commercial chips, QSFP28 pinouts, MZI optical meshes, and distributors.
  • ๐ŸŒ Roadmap & Manifesto: Open-source strategy, European deep-tech grants (EIC Pathfinder), and telecom integration.

๐Ÿ“œ License

Released under the open-source MIT License.

pisantifrancesco89/Project-LightSwitch

In-Network & Photonic Neural Compute Simulator (Zero-VRAM, 1.58-bit Ternary Optical Routing Engine)

1

stars

0

commits

Python

primary language

Aug 29, 2026

updated

bitnet
green-ai
in-network-computing
llm-inference
optical-computing
p4-lang
silicon-photonics

README

Project LightSwitch: In-Network & Photonic Neural Compute Simulator

Tests Python License Architecture

"Do not send data to centralized AI data centers: embed intelligence directly into the light traveling through global networks."

๐Ÿ“– Languages: English | ๐Ÿ‡ฎ๐Ÿ‡น Leggi in Italiano (Italian Version)


Project LightSwitch is an experimental software prototype and hardware architecture for In-Network & Photonic Artificial Intelligence Compute. It simulates executing Large Language Model (LLM) inference and matrix transformations directly inside optical fibers, switching cabins, and satellite laser links while packets are in transit, eliminating the GPU Von Neumann memory bottleneck and reducing compute energy by $95% - 98%$.


๐ŸŒŸ Architectural Overview

[ CLIENT (Copper / Wi-Fi) ] 
       โ†“ (Tokenized prompt)
[ SWITCHING CABIN / EDGE PoP (P4 Switch / FPGA) ] โž” Computes Initial Model Layers (15 ns)
       โ†“ (WDM Optical Carrier Modulation @ 1550nm C-Band)
[ TERRESTRIAL & SUBMARINE OPTICAL FIBER ] โž” Photons travel at 200,000 km/s in silica
       โ†“ (Ternary Optical Phase Interference {-1, 0, 1})
[ LEO SATELLITE CONSTELLATION ] โž” Inter-satellite laser links at 300,000 km/s (Speed of light in vacuum)
       โ†“ (Downlink & Token Decapsulation)
[ DESTINATION GATEWAY ] โž” Final output token already computed upon arrival! (Zero GPU queue latency)

Key Innovations & Counter-Defenses:

  1. Zero Multiplications ($100%$ Additive Transforms): Model weights are quantized to 1.58-bit (${-1, 0, 1}$). Floating-point multiplications are replaced by optical constructive/destructive phase interference ($0\text{ FP Multiplications}$).
  2. Eliminating the Softmax Bottleneck: Integrates State-Space Models (Mamba / RWKV Linear SSMs) to compute recurrence ($h_t = Ah_{t-1} + Bx_t$) without $\mathcal{O}(N^2)$ Softmax in-flight.
  3. Physical Noise Resilience: Employs ITU-T G.709 Forward Error Correction (FEC) ensuring Post-FEC Bit Error Rate $\text{BER} < 10^{-15}$ across thousands of kilometers.
  4. Hyperscale Data Center Spine-Leaf Fabric: Applicable immediately inside private Big Tech AI Campus networks, cutting intra-datacenter optical transceiver energy by $>80%$.
  5. Sub-2 Nanosecond Hardware Packet Filter: Switches inspect incoming headers in $< 1.5\text{ ns}$, instantly distinguishing AI prompt packets from everyday Internet traffic (Netflix, Zoom, HTTPS).
  6. Commercial Off-The-Shelf (COTS) Readiness: Can be deployed immediately using accessible hardware: AMD Xilinx UltraScale+ FPGA SmartNICs (โ‚ฌ2,800) or Intel Tofino 2 P4 Switches (โ‚ฌ8,500).

๐Ÿ“‚ Repository Layout

.
โ”œโ”€โ”€ README.md                          # English Documentation & Quickstart
โ”œโ”€โ”€ README_IT.md                       # Italian Documentation & Quickstart
โ”œโ”€โ”€ requirements.txt                   # Optional dependencies (rich, numpy, matplotlib)
โ”œโ”€โ”€ config.py                          # Optical physical constants & simulation parameters
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ encoder.py                     # WDM optical wavelength modulation (C-Band 1530-1565nm)
โ”‚   โ”œโ”€โ”€ switch.py                      # In-network optical switch and in-transit compute engine
โ”‚   โ”œโ”€โ”€ decoder.py                     # Generative text un-embedder and token streaming
โ”‚   โ”œโ”€โ”€ llm_bridge.py                  # Real LLM connector (Ollama / OpenAI / Groq / Fallback)
โ”‚   โ”œโ”€โ”€ state_space_mamba.py           # 1.58-bit linear State-Space (Mamba) recurrent engine
โ”‚   โ””โ”€โ”€ matrix_sparse.py               # 1.58-bit ternary additive engine {-1, 0, 1}
โ”œโ”€โ”€ simulation/
โ”‚   โ”œโ”€โ”€ fiber_channel.py               # Single-mode silica fiber delay & attenuation model (SMF-28)
โ”‚   โ”œโ”€โ”€ pipeline.py                    # Multi-hop end-to-end execution pipeline
โ”‚   โ”œโ”€โ”€ heterogeneous_network.py       # Global WAN model (Copper, P4 Cabins, Fibers, LEO Satellites)
โ”‚   โ”œโ”€โ”€ packet_classifier.py           # Hardware packet classifier (<1.5 ns TCAM parser)
โ”‚   โ”œโ”€โ”€ noise_and_fec.py               # Optical noise model (ASE/Thermal) & ITU-T G.709 FEC
โ”‚   โ””โ”€โ”€ datacenter_spine_leaf.py       # Private AI data center campus Spine-Leaf simulator
โ”œโ”€โ”€ benchmarks/
โ”‚   โ”œโ”€โ”€ metrics.py                     # FLOPs, Latency, and Energy telemetry (picoJoules vs milliJoules)
โ”‚   โ”œโ”€โ”€ compare_gpu.py                 # Mathematical comparison vs NVIDIA H100 GPU server
โ”‚   โ””โ”€โ”€ hardware_costs.py              # 3-Year TCO financial engine (CAPEX & OPEX)
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ WHITEPAPER.md                  # Formal scientific whitepaper & mathematical models
โ”‚   โ”œโ”€โ”€ OBJECTIONS_AND_DEFENSE.md      # Technical defense against top 4 engineering objections
โ”‚   โ”œโ”€โ”€ hardware_architecture.md       # Technical hardware guide for COTS chips & optical interconnects
โ”‚   โ””โ”€โ”€ IMPACT_AND_ROADMAP.md          # Global launch manifesto, grants (EIC Pathfinder), and roadmap
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_all.py                    # Automated test suite (11 tests, 100% passing)
โ”œโ”€โ”€ app.py                             # Interactive Guided Visual Studio & Chat
โ””โ”€โ”€ main.py                            # Interactive CLI with Rich terminal visualization

๐Ÿš€ Quick Start Guide

1. Interactive Studio & Live Chat

python3 app.py

2. Run Automated Test Suite (11 Tests)

python3 -m unittest discover tests

๐Ÿ“Š 3-Year Total Cost of Ownership (TCO) Comparison

Hardware ArchitectureChip TypeCAPEX (Hardware)Power Consumption3-Year Electricity (OPEX)*3-Year Total TCOSavings vs GPU
Traditional AI Server (8x NVIDIA H100)Monolithic GPUโ‚ฌ280,00010,200 Wโ‚ฌ70,815โ‚ฌ350,815Baseline
3x FPGA SmartNIC ClusterAMD Xilinx (COTS)โ‚ฌ8,400225 Wโ‚ฌ1,562โ‚ฌ9,962-97% ๐Ÿš€
3x Programmable P4 Switch ClusterIntel Tofino 2 (COTS)โ‚ฌ25,500750 Wโ‚ฌ5,207โ‚ฌ30,707-91% ๐Ÿš€
3x Silicon Photonics CPO EngineAyar Labs (COTS)โ‚ฌ36,000105 Wโ‚ฌ729โ‚ฌ36,729-90% ๐Ÿš€

*Calculated with industrial electricity rate of โ‚ฌ0.22/kWh and cooling PUE = 1.2.


๐Ÿ“„ Scientific Documentation & Defense

  • ๐Ÿ›ก๏ธ Technical Objections & Counter-Defense: Mathematical answers to Softmax non-linearities, KV-Cache memory in-flight, optical noise, and telecom adoption.
  • ๐Ÿ“– Scientific Whitepaper: Mathematical formulations, Maxwell wave propagation, and theoretical derivation.
  • ๐Ÿ› ๏ธ Hardware Architecture Guide: Commercial chips, QSFP28 pinouts, MZI optical meshes, and distributors.
  • ๐ŸŒ Roadmap & Manifesto: Open-source strategy, European deep-tech grants (EIC Pathfinder), and telecom integration.

๐Ÿ“œ License

Released under the open-source MIT License.

Languages

Python

100.0%