fix: To fix Python QEC conversion for empty repetition-code X matrices#660
Open
kaiqiy-nv wants to merge 2 commits into
Open
fix: To fix Python QEC conversion for empty repetition-code X matrices#660kaiqiy-nv wants to merge 2 commits into
kaiqiy-nv wants to merge 2 commits into
Conversation
Signed-off-by: Kaiqi Yan <kaiqiy@nvidia.com>
Collaborator
|
/ok to test 433541e |
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.
This PR tries to fix [B] 6428084 .
It also adds one test to expose this bug and verify the fix.
Thanks for looking this PR.
In our suggested fix, we keep the existing C++
cudaqx::tensorsemantics unchanged: an empty directional parity/observable tensor may remain rank 0.In the Python binding layer, we add a small wrapper for matrix-returning
Codemethods that detects this valid rank-0 empty sentinel and converts it to an empty 2-D NumPy matrix with the correct width, e.g.(0, code.get_num_data_qubits()).It also adds rank validation in the generic tensor-to-NumPy helpers before reading
shape[0]/shape[1]and skipsmemcpyfor zero-sized tensors, so invalid-rank conversions fail cleanly instead of causing undefined behaviour.