Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

adds stable BS implementation and tests - #405

Open
ziofil wants to merge 15 commits into
masterfrom
stable_bs
Open

ziofil wants to merge 15 commits into
masterfrom
stable_bs

Conversation

@ziofil

@ziofil ziofil commented Oct 15, 2025 •

Copy link
Copy Markdown
Collaborator

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

codecov Bot commented Oct 15, 2025 •

Copy link
Copy Markdown

Codecov Report

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

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

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54b1062...94459d6. 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
Copy Markdown
Contributor

You might aswell remove the old one, no?

@ziofil

ziofil commented Oct 16, 2025 •

Copy link
Copy Markdown
Collaborator Author

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

Comment thread thewalrus/tests/test_fock_gradients.py Resolved
@ziofil

ziofil commented Oct 20, 2025

Copy link
Copy Markdown
Collaborator Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants