Skip to content

Conversation

@mateuszkupper
Copy link
Collaborator

Creates an interface with backends for diagram evaluation:

  • removes the need to double, or convert the channel diagrams manually in order to evaluate them
  • diagrams are evaluated like in the example below:
from optyx.core.backends import PercevalBackend

circuit = BS @ BS >> qmode @ MZI(0.4, 0.34) @ qmode
result = circuit.eval(PercevalBackend()) #returns an `EvalResult` object
  • we can obtain for example a probability distribution from the object: result.prob_dist() which returns a dictionary with photon number configurations and corresponding probabilities
  • the available backends are: QuimbBackend (exact and approximate using hyperoptimisers), DiscopyBackend, PercevalBackend (only for pure states)

More examples:

from optyx.core.backends import QuimbBackend
from cotengra import HyperCompressedOptimizer

d.eval(QuimbBackend(hyperoptimiser=HyperCompressedOptimizer())).prob_dist(round_digits=5)
from optyx.core.backends import PercevalBackend

circuit = BS @ BS >> qmode @ MZI(0.4, 0.34) @ qmode

result = circuit.eval(PercevalBackend())

@mateuszkupper mateuszkupper marked this pull request as ready for review August 26, 2025 13:37
@giodefelice giodefelice merged commit b8c5b66 into main Aug 28, 2025
5 of 6 checks passed
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.

3 participants