Skip to content

fix: To fix Python QEC conversion for empty repetition-code X matrices#660

Open
kaiqiy-nv wants to merge 2 commits into
NVIDIA:mainfrom
kaiqiy-nv:kaiqiy/cope-with-empty-tensor
Open

fix: To fix Python QEC conversion for empty repetition-code X matrices#660
kaiqiy-nv wants to merge 2 commits into
NVIDIA:mainfrom
kaiqiy-nv:kaiqiy/cope-with-empty-tensor

Conversation

@kaiqiy-nv

Copy link
Copy Markdown
Collaborator

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::tensor semantics unchanged: an empty directional parity/observable tensor may remain rank 0.
In the Python binding layer, we add a small wrapper for matrix-returning Code methods 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 skips memcpy for zero-sized tensors, so invalid-rank conversions fail cleanly instead of causing undefined behaviour.

Signed-off-by: Kaiqi Yan <kaiqiy@nvidia.com>
@kaiqiy-nv kaiqiy-nv requested a review from bmhowe23 July 8, 2026 07:42
@copy-pr-bot

copy-pr-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@bmhowe23

bmhowe23 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 433541e

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.

2 participants