Skip to content

Conversation

@ziofil
Copy link
Collaborator

@ziofil ziofil commented Oct 15, 2025

Context:
The beamsplitter in the Fock representation suffers from numerical instabilities even for moderate cutoffs (~40)

Description of the Change:
This ports the stable BS implementation from MrMustard, which is just as fast as the unstable BS and offers numerical stability up to arbitrary cutoffs (or at least I ran out of memory before I could notice any).

Benefits:
BS can now be applied to high photon number inputs and outputs. It is as fast as the unstable implementation:
Screenshot 2025-10-15 at 9 33 26 AM

But stable:
Screenshot 2025-10-15 at 9 33 51 AM

Possible Drawbacks:
None

Related GitHub Issues:
None

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (12633ca) to head (5f2ad94).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #405   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           28        28           
  Lines         1922      1935   +13     
=========================================
+ Hits          1922      1935   +13     
Files with missing lines Coverage Δ
thewalrus/fock_gradients.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update deb45fd...5f2ad94. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nquesada
Copy link
Collaborator

You might aswell remove the old one, no?

@ziofil
Copy link
Collaborator Author

ziofil commented Oct 16, 2025

Do you want to keep the cutoff as an integer? the new implementation supports any shape.

@ziofil
Copy link
Collaborator Author

ziofil commented Oct 20, 2025

@nquesada regarding the cutoff argument, I preserved the old API and made it possible to pass the full shape.

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.

2 participants