Fix #464: crash of Pauli-flow finding algorithm due to incorrect numba signatures.#465
Fix #464: crash of Pauli-flow finding algorithm due to incorrect numba signatures.#465matulni merged 10 commits intoTeamGraphix:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #465 +/- ##
=======================================
Coverage 88.95% 88.95%
=======================================
Files 44 44
Lines 6530 6530
=======================================
Hits 5809 5809
Misses 721 721 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
It is a bit disappointing that functions in |
|
Commit 5cf616c ensures that all numba-jitted functions called from Further, initialisation of |
thierry-martinez
left a comment
There was a problem hiding this comment.
Very nice! Just a small suggestion, but I approve already.
Co-authored-by: thierry-martinez <thierry.martinez@inria.fr>
Co-authored-by: thierry-martinez <thierry.martinez@inria.fr>
|
LGTM! Thanks! |
This commit proposes a fix to issue #464. The example triggering the crash is added to the test suit.
Detailed explanation
To improve the efficiency of just-in-time compiled functions in the
graphix._linalgmodule, we indicate the memory layout of the array parameters. In particular, we writeu8[:,::1]to indicate that we expectC_CONTIGUOUSarrays which is numpy's default. If we pass anF_CONTIGUOUSarray to these functions, numba will crash as in the reported bug.Computing the transpose of a
C_CONTIGUOUSarray withnumpy.transposeonly changes the metadata flags of the array to avoid unnecessary copying:This transformation occurred inadvertently in
:func: graphix.flow._find_gpflow._compute_correction_matrix_general_case:Why did all the tests pass ?
Very often, the kernel of the flow demand matrix is a one-row or one-column matrix. In this case, the corresponding numpy array is both
C_CONTIGUOUSandF_CONTIGUOUS, so computing the transpose does not invalidate the numba decorator signature:What is the fix?
The function
numpy.ascontiguousarrayallows to reexpress anF_CONTIGUOUSarray asC_CONTIGUOUS. Note that if the original array isC_CONTIGUOUSin the first place, callingnumpy.ascontiguousarraydoes not incur in an extra coyping: