Metadata-Version: 2.4
Name: esQueranto
Version: 0.1.0
Summary: Differentiable quantum optics in ordinary and structured Fock spaces
Author: Artificial Scientist Lab
License-Expression: MIT
Project-URL: Repository, https://github.com/artificial-scientist-lab/esQueranto
Project-URL: Issues, https://github.com/artificial-scientist-lab/esQueranto/issues
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jax<0.8,>=0.7.2
Requires-Dist: numpy>=2.0
Provides-Extra: examples
Requires-Dist: ipykernel>=6.29; extra == "examples"
Requires-Dist: matplotlib>=3.8; extra == "examples"
Dynamic: license-file

# esQueranto

**Differentiable software for quantum-optical experiment simulation and design.**

`esQueranto` is a JAX-based framework for building and differentiating quantum-optical experiments in a common Fock-space description. It combines conventional photonic states and circuits with structured Laguerre–Gaussian light, noise, heralding, and photon-number measurements within the same workflow.


## Installation

Install the latest released version with

```bash
pip install esQueranto
```

The package requires Python 3.12 or newer and JAX 0.7.x. To also install the dependencies used by the example notebooks:

```bash
pip install "esQueranto[examples]"
```

To install directly from a source checkout instead, run

```bash
pip install .
```

from the repository directory.

## Quick start

A two-photon Hong–Ou–Mandel experiment can be written as:

```python
import esQueranto as eq
import jax.numpy as jnp

space = eq.space(2, cutoff=2)
initial = eq.state(space, (1, 1))

experiment = eq.circuit(
    eq.bs(0, 1, jnp.pi / 4),
)

output = eq.simulate(initial, experiment)
probabilities = eq.pnr(output)
```

The same interface can be used for coherent sources, squeezing, phase shifts, loss, dephasing, heralding, and structured-light propagation.

## Physics in a common framework

`esQueranto` supports:

- Fock states, superpositions, coherent states, and trainable state preparation;
- beam splitters, phase shifts, single- and two-mode squeezing;
- photon loss and dephasing;
- ideal, finite-resolution, and inefficient photon-number detection;
- heralded conditional states and state fidelity;
- Laguerre–Gaussian transverse modes, free-space propagation, and thin lenses;
- interference between structured beams with different beam parameters;
- differentiable circuit parameters, source amplitudes, noise parameters, and optical geometry.


## Differentiable experiments

A circuit topology can be compiled once and evaluated repeatedly while selected physical parameters remain differentiable:

```python
circuit = eq.circuit(
    eq.bs(0, 1, "theta"),
    eq.ps(0, "phi"),
)

evaluate, parameters = eq.compile(
    initial,
    circuit,
    parameters={"theta": 0.3, "phi": 0.1},
)

output = evaluate(parameters)
```

The resulting evaluator is compatible with standard JAX transformations such as `jax.jit`, `jax.grad`, `jax.value_and_grad`, and `jax.vmap`. The optical topology remains fixed while continuous experimental parameters are optimized or swept.

## Structured light

Structured states are introduced by attaching Laguerre–Gaussian profiles to optical paths:

```python
profile = eq.lg(
    p=0,
    ell=0,
    waist=1e-3,
    wavelength=810e-9,
)

initial = eq.state(
    eq.space(2, cutoff=2, truncation="mode"),
    (1, 1),
    profiles={0: profile, 1: profile},
    radial_modes=4,
)
```

The radial cutoff is independent of the photon-number cutoff and can be increased to check convergence of structured-light simulations.

## Examples

The `examples/` directory contains the simulations used to illustrate the framework in the accompanying paper:

- **Gravity-sensitive interferometer** — fiber propagation, loss, dephasing, detector inefficiency, and Fisher information.
- **Heralded radial-mode sorter** — mode-selective squeezing, heralding, structured propagation, and dephasing.
- **Structured Hong–Ou–Mandel interference** — radial-mode interference under propagation and focal-length mismatch.
- **N00N-state heralding** — an eight-photon heralding circuit with fidelity and success probability.
- **High-N00N interference** — coherent light and squeezed vacuum with photon-number-resolved output statistics.
- **Four-crystal interferometer** — interference between multiple pair-generation pathways.

Each notebook is self-contained once `esQueranto` is installed.

## Code structure

The public API is available through:

```python
import esQueranto as eq
```

## License

`esQueranto` is released under the [MIT License](LICENSE).

