Metadata-Version: 2.4
Name: silifoundry
Version: 0.3.0
Summary: A silicon photonic quantum architecture optimisation compiler for foundry workflows.
Author: SiliFoundry Contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/DennisWayo/silifoundry
Project-URL: Repository, https://github.com/DennisWayo/silifoundry
Keywords: photonics,quantum,compiler,silicon-photonics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: flask
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: maturin; extra == "dev"
Dynamic: license-file

# SiliFoundry

A silicon photonic quantum architecture optimisation compiler for foundry workflows

## Introduction

`silifoundry` is a practical engineering codebase for designing and analyzing
photonic quantum circuits at the architecture level, not just at the abstract
gate level. The core idea is to start from a compact DSL description of a
photonic circuit, compile it into a physically placed layout, build a
high-dimensional interaction tensor that captures intended and parasitic
effects, and then contract that tensor into a transfer matrix you can test,
compare, and optimize.

This project models the parts that usually get hand-waved in idealized
simulators: evanescent coupling, thermal crosstalk, distributed backscatter,
loss, nonlinear effects, polarization coupling, and dispersion. Those effects
are represented explicitly in interaction layers and folded into stage matrices
during contraction, so you can trace where non-ideal behavior comes from.

End-to-end workflow in this repo:

1. Parse source text into AST (`silifoundry.qwerty_parser`, `silifoundry.qwerty_ast`).
2. Transpile AST into IR with mode/basis checks (`silifoundry.transpiler`, `silifoundry.ir`).
3. Compile IR into a physical layout and components (`silifoundry.compiler`, `silifoundry.components`).
4. Build the network tensor from physics kernels (`silifoundry.tensor`, `silifoundry.kernels`).
5. Contract stage matrices into final transfer matrix `U`.
6. Validate with tests and run demos/app for inspection.

The canonical package source lives under `src/silifoundry/`.

## Layout

- `src/silifoundry/`: core package (parser, transpiler, compiler, tensor, kernels)
- `tests/`: pytest suite
- `demos/`: demo scripts
- `static/`: web frontend assets

## Quick Start

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m pip install -e ".[dev]"
```

If your shell activation is inconsistent, use `./.venv/bin/python` explicitly for all commands.

## Install Package

Install from source checkout:

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m pip install .
```

After publishing to PyPI, install from anywhere with:

```bash
python -m pip install silifoundry
```

## Run Tests

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m pytest -q
```

## Optional Rust Acceleration

The evanescent tensor layer (`α=1`) can be accelerated with the optional
`silifoundry_rust` extension in `rust-core/`. If the extension is not installed,
Python automatically falls back to the reference implementation.

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m pip install maturin
./.venv/bin/python -m maturin develop --manifest-path rust-core/Cargo.toml
```

To force the Python path even when the extension is installed:

```bash
SILIFOUNDRY_DISABLE_RUST_ACCEL=1 ./.venv/bin/python -m pytest -q
```

## Run App

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m silifoundry.app
```

If port `5000` is busy:

```bash
./.venv/bin/python -m silifoundry.app --port 8080
```

## Run Demos

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python demos/clements_mesh_4mode.py
./.venv/bin/python demos/demo_clements_injective.py
./.venv/bin/python demos/demo_reck3_injective.py
```

## Publish To PyPI

```bash
cd /Users/denniswayo/silifoundry
./.venv/bin/python -m pip install --upgrade build twine
./.venv/bin/python -m build
./.venv/bin/python -m twine check dist/*
./.venv/bin/python -m twine upload dist/*
```
