Skip to main content

Photonic KAN: Bridging PyTorch, KAN, and Q.ANT photonic hardware

Project description

PhotoKAN

Photonic Kolmogorov-Arnold Networks — bridging PyTorch · KAN · Q.ANT photonic hardware.

Python PyTorch Status

Phase 1 (CPU simulation) is fully functional. Q.PAL/NPU integration ships in Phase 2.


Why PhotoKAN?

Standard MLPs use fixed activations on nodes and linear weights on edges.
KANs invert this: learnable nonlinear functions sit on the edges, summed at nodes.

Photonic hardware is physically structured around edge-level nonlinear transforms — light through a waveguide produces exactly the kind of parametric nonlinear function a KAN edge needs. This is not an analogy; it is a direct structural match.

Published benchmarks show:

  • 43% fewer parameters vs equivalent MLPs
  • 46% fewer operations vs equivalent MLPs
  • 30× energy efficiency gain on Q.ANT NPU vs CMOS

Installation

pip install photokan          # CPU simulation (no hardware required)
pip install photokan[qpal]    # + Q.ANT NPU support
pip install photokan[llm]     # + HuggingFace integration (Phase 3)
pip install photokan[dev]     # + development tools

Quick Start

import torch
import photokan as pk

# Works on CPU sim if no NPU — no code changes needed
model = pk.PhotoKAN(
    layer_sizes=[4, 16, 16, 1],
    activation='sine',   # 'sine' | 'fourier' | 'spline' | 'relu'
    backend='auto',      # auto-detects NPU, falls back to CPU
)

x = torch.randn(32, 4)
y = model(x)

# Standard PyTorch training
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
loss = torch.nn.MSELoss()(y, torch.randn(32, 1))
loss.backward()
optimizer.step()

# Check what hardware is available
print(pk.available_backends())
# → {'cpu': True, 'cuda': True, 'qpal': False}

Activation Variants

Name Formula Best for Photonic native
sine Σ w·sin(f·x + p) Periodic targets, photonic deployment
fourier a₀ + Σ [a·cos + b·sin] Multi-frequency signals
spline B-spline basis Non-periodic, high precision Via LUT
relu Σ w·ReLU(a·x + b) Edge inference, speed

Photonic Noise Simulation

Test accuracy against realistic hardware impairments before deploying to NPU:

sim = pk.PhotonicSimulator()
sim.set_hardware_profile('npu2')   # SNR=16dB, 8-bit

results = sim.sweep_snr(model, x_test, y_test,
                         snr_range=[8, 10, 12, 14, 16, 20])
sim.plot_snr_accuracy(results)

Architecture

User PyTorch model
    └── PhotoKAN / PhotoKANLayer   (nn.Module, drop-in)
            └── EdgeActivations    (sine / fourier / spline / relu)
                    └── QPALFunction (torch.autograd.Function)
                            ├── QPALBackend  → Q.ANT NPU via Q.PAL
                            └── SimBackend   → CPU physics simulation

Project Status

Phase Features Status
Phase 1 Activations, SimBackend, Layers, Utils ✅ Complete
Phase 2 Q.PAL integration, QPALBackend, gradient tests 🔜 Months 4–6
Phase 3 AOT compiler, LLM integration, arXiv paper 🔜 Months 7–12

Running Tests

pip install -e ".[dev]"
pytest                          # fast tests only
pytest -m slow                  # include convergence tests
pytest --cov=photokan           # with coverage

References

  • Liu et al. (2024) — KAN: Kolmogorov-Arnold Networks
  • Peng et al. (2024) — Photonic KAN via RAMZI (98% MNIST, 65× energy-area reduction)
  • Reinhardt et al. (2024) — SineKAN
  • Q.ANT NPU — https://qant.com/photonic-computing/

PhotoKAN v0.1 — Build the bridge. Light does the math.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

photokan-0.2.0.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

photokan-0.2.0-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file photokan-0.2.0.tar.gz.

File metadata

  • Download URL: photokan-0.2.0.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for photokan-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e9e93d3b940634d046c173c1ed0acba7a31347c5c2e478b6bf183900b01ac249
MD5 9c6fe27f7d39e41fe3128384bffe9a8d
BLAKE2b-256 ff7aafdd3affe14b901a910b909d914de4819ececb43433352deb920d518ac6a

See more details on using hashes here.

File details

Details for the file photokan-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: photokan-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for photokan-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa71a648ce72b3a009f03240d16bd993c0fdee4c81f05696df5baafe77255f80
MD5 80d83c8d4715a363ac7dbfb5df5012ee
BLAKE2b-256 559e6be51f2576cdcedaacdc82c5bd58b9fae9b157b2668cfbf340ac948f04ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page