Skip to content

feat(photonics): wire codec, Quandela job helpers, batched reservoir - #73

Merged
sarseniy merged 5 commits into
mainfrom
arsenii/stt-413-photonic-wire-and-cloud-jobs
Nov 24, 2026
Merged

sarseniy merged 5 commits into
mainfrom
arsenii/stt-413-photonic-wire-and-cloud-jobs

Conversation

@sarseniy

@sarseniy sarseniy commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Three additions to the photonic ring. They let a service run eigenkit's photonic circuits on Quandela Cloud for its users, and let a photonic reservoir run as one job instead of one job per time step.

  • eigenkit.photonics.wire: photonic_spec_to_json and photonic_spec_from_json, a JSON codec for PhotonicCircuitSpec. It is the photonic counterpart of core.wire, holds only data, and encodes angles with the parameter encoding the qubit codec already uses.
  • cloud_job_body and cloud_job_counts in photonics/backends/perceval_remote.py. The first builds the request that creates a Quandela Cloud job, with one run for each row of inputs. The second reads the counts of a finished job, one dictionary per row. Neither opens a connection nor needs a token: the body is built by Perceval's own RemoteProcessor and Sampler, given a handler that answers the platform details and keeps the body instead of sending it.
  • run_photonic_reservoir calls compiled.run_batch(weights, rows) once when the executor offers it, and loops over run otherwise. run_batch is not part of the Compiled protocol, so the existing executors still satisfy it.

Why a batch is built this way

A Quandela Cloud job can carry several iterations of one circuit, each with its own parameter values. The circuit is built with one named Perceval parameter per angle, and each row carries the number of every angle, resolved with core.ir.resolve. So a batch works for any angle expression, and the per-row values are the ones the single-run path computes.

A 480-row batch of a reservoir of the size examples/photonics_reservoir.py uses (4 modes, 2 photons, depth 2), with 2000 shots per row, ran as one job on sim:slos in 21 seconds. Rows 0, 239 and 479 were within a total variation distance of 0.02 of the exact local SLOS distribution.

Concurrency

cloud_job_body can be called from several threads. Perceval dispatches some methods, with_input and the serializer among them, through state that all instances share, so unguarded concurrent builds could swap input states or corrupt an experiment. The calls into Perceval run under one lock; a build takes a few milliseconds. test_concurrent_builds_do_not_mix reproduces the problem without the lock.

Compatibility

  • No existing encoding, signature or behaviour changes. core.wire and core/blocks.py are untouched.
  • import eigenkit.photonics still loads neither Perceval nor PyTorch. eigenkit.photonics.wire joins the import-linter contract "Photonics compute layer is framework-free".
  • No new dependency.

Tests

  • tests/photonics/test_wire.py: golden encoding and decoding, a round trip of a reservoir, numpy scalars, malformed input, no Perceval import.
  • tests/photonics/test_cloud_job.py: every row binds to the same unitary as the single-run builder build_perceval_circuit, concurrent builds do not mix, a platform without sample_count is refused, one iteration per row with the resolved angles, the shot budget of every row, the photon filter, wrong shapes, no connection opened, and the counts of recorded results (a single run, a batch, a row with no surviving shot, a job without counts). The results in tests/photonics/fixtures/ were recorded on sim:slos; the platform description there is a minimal one written by hand.
  • tests/photonics/test_reservoir.py: run_batch is called once with all the rows and gives the same features as the loop; a batch of the wrong length is refused.

Docs

The photonics guide gains a section on running through the EigenOrbit Router, and its note on batching is corrected.

@sarseniy
sarseniy requested a review from a team as a code owner November 24, 2026 13:18
@github-actions

Copy link
Copy Markdown

Docs preview: https://pr-73.eigenkit-docs.pages.dev

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/eigenkit/photonics
  reservoir.py
  wire.py 35, 54
  src/eigenkit/photonics/backends
  perceval_remote.py 142
Project Total  

This report was generated by python-coverage-comment-action

Building a Quandela Cloud job goes through Perceval methods that share state between instances, so concurrent builds could swap input states or corrupt an experiment. The Perceval section now runs under a lock. A platform without the sample_count command is refused, because its results would need a conversion cloud_job_counts does not make. The codec writes NumPy scalars inside angle expressions as Python numbers.
@sarseniy
sarseniy merged commit b6d0c73 into main Nov 24, 2026
21 of 22 checks passed
@sarseniy
sarseniy deleted the arsenii/stt-413-photonic-wire-and-cloud-jobs branch November 24, 2026 14:23

This branch was successfully deployed

1 active deployment
docs-preview — 2ad0df00 Deployed Nov 24, 2026 by sarseniy via preview #96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant