Optimize loop hafnian: share powertrace computation between f_loop calls#409
Open
seba2390 wants to merge 4 commits intoXanaduAI:masterfrom
Open
Optimize loop hafnian: share powertrace computation between f_loop calls#409seba2390 wants to merge 4 commits intoXanaduAI:masterfrom
seba2390 wants to merge 4 commits intoXanaduAI:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context:
In
_calc_loop_hafnian_batch_gamma_evenand_calc_loop_hafnian_batch_gamma_odd, the functionsf_loop()andf_loop_odd()are called inside a loop over displacement vectors (k in range(n_D)). Both functions internally computepowertrace(AX), however, the matrixAXdepends only on the edge configuration (j), and not on the displacement vector (D[k]). The original code redundantly computes the same powertrace2 × n_Dtimes perjiteration.Description of the Change:
f_loopandf_loop_oddin_hafnian.pyto acceptpowtrace_arras a parameter instead of computing it internally.loop_hafnian_batch.pyand loop_hafnian_batch_gamma.py to compute powertrace once perjiteration and pass it to both functions.Benefits:
loop_hafnian_batch_gammafor typical batch sizes (10-50 displacement vectors)Possible Drawbacks:
f_loopandf_loop_odd(now requirepowtrace_arrparameter). These are internal functions not exposed in the public API.Related GitHub Issues:
None