Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding probability tests #368

Merged
merged 15 commits into from
Nov 4, 2023
Merged

Adding probability tests #368

merged 15 commits into from
Nov 4, 2023

Conversation

nquesada
Copy link
Collaborator

Adds non-batched internal modes calculation of probabilities.

@nquesada nquesada changed the base branch from master to internal_modes June 26, 2023 21:06
@codecov
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

❗ No coverage uploaded for pull request base (internal_modes@ece2cb4). Click here to learn what that means.
The diff coverage is n/a.

Additional details and impacted files
@@                Coverage Diff                @@
##             internal_modes     #368   +/-   ##
=================================================
  Coverage                  ?   94.07%           
=================================================
  Files                     ?       32           
  Lines                     ?     2262           
  Branches                  ?        0           
=================================================
  Hits                      ?     2128           
  Misses                    ?      134           
  Partials                  ?        0           

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 ece2cb4...07faa97. Read the comment docs.

@@ -1419,7 +1432,10 @@ def test_density_matrix(cutoff):
rho2 = density_matrix_single_mode(cov, N, cutoff=cutoff)
rho2_norm = rho2 / np.trace(rho2).real

# probs = probabilities_single_mode(cov, N, cutoff=cutoff, normalize=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidSPhillips this is a waaay too long test..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it take ages in the internal_modes branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it takes ages on my computer, that is why I decided against adding the new functions in this test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's too long? The whole test or the addition of the commented out probabilities bit? The new bit doesn't take much longer for my laptop at all (after correcting for the PNR on mode 0). The whole test takes about 2.5 minutes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test. 2.5 minutes is too long.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the test is still included so it will still take 2.5 minutes. Adding the commented out lines (but not commented out) wouldn't increase the time much.

return netsum


def probabilities_single_mode(cov, pattern, normalize=False, LO_overlap=None, cutoff=13, hbar=2):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this function supposed to be? In the docstring it says density matrix but should it say probability pattern? Also I don't really understand why there's an option to project onto LO for this, given we assume the PNRs are bucket detectors, it shouldn't affect how we split the internal modes up, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rewritten the doc string, hopefully this clarifies the meaning.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, it's essentially the pnr distribution of the 'principal mode' (or mode of our choosing). Still, I feel it might be more appropriate to call it something like dm_diag_single_mode (or something to that effect) to avoid confusion with pnr_prob, but ultimately I don't feel that strongly about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, PNR prob does something similar, but the signature of the function is different.

@DavidSPhillips
Copy link
Collaborator

After the docstring change all tests pass? It was test_pure_gkp that was failing, is it just a by chance numerical thing?

@DavidSPhillips
Copy link
Collaborator

After the docstring change all tests pass? It was test_pure_gkp that was failing, is it just a by chance numerical thing?

The tests from this branch are still failing on wsl my laptop (with numba=0.55.1), but I re-run the jobs here and it's still passing.

Copy link
Collaborator

@DavidSPhillips DavidSPhillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy for this to be merged given tests are passing.

thewalrus/internal_modes/fock_density_matrices.py Outdated Show resolved Hide resolved
from ..quantum import Qmat
from .._hafnian import find_kept_edges, nb_binom, f_from_powertrace, nb_ix
from ..quantum import Qmat, Amat
from thewalrus.symplectic import passive_transformation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a relative import like the other imports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that make a difference?

thewalrus/internal_modes/pnr_statistics.py Show resolved Hide resolved
thewalrus/internal_modes/pnr_statistics.py Outdated Show resolved Hide resolved
thewalrus/internal_modes/pnr_statistics.py Outdated Show resolved Hide resolved
thewalrus/internal_modes/pnr_statistics.py Outdated Show resolved Hide resolved
thewalrus/internal_modes/pnr_statistics.py Outdated Show resolved Hide resolved
@nquesada
Copy link
Collaborator Author

nquesada commented Nov 2, 2023

@rachelchadwick is this good to be merged?

@nquesada nquesada merged commit e6de063 into internal_modes Nov 4, 2023
3 checks passed
@nquesada nquesada deleted the adding_probability_tests branch November 4, 2023 12:32
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