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

Make sure no zero-bitsize connections appear #1105

Merged
merged 7 commits into from
Jul 30, 2024

Conversation

mpharrigan
Copy link
Collaborator

This adds additional assertions to qualtran.testing to make sure none of the Connection objects have zero bitsize. The presence of such registers/connections likely breaks assumptions used by the rest of the library. cc #1102

Originally, I was going to add asserts to the QDTypes themselves, but 1) they're used in several places other than defining registers that actually appear in a composite bloq causing "false positives" in the test 2) performing those assertions at QDType instantiation makes it impossible to get around; whereas this current change will only result in a failure if you're using qlt_testing.assert_valid_bloq_decomposition or its friends (or the bloq_autotester) so this PR probably has some false negatives still remaining.

@mpharrigan
Copy link
Collaborator Author

cc @NoureldinYosri found this in reviewing #1057

@mpharrigan
Copy link
Collaborator Author

@tanujkhattar test_select_swap_qrom results in zero-sized registers for the 3rd data example of [[1],[2],[3]]. Can you fix?

selection_bitsizes = tuple((s - 1).bit_length() for s in _data[0].shape)

@mpharrigan
Copy link
Collaborator Author

StatePreparationViaRotations

return bit_length(slen(self.state_coefficients) - 1)

passed as selection bitsize to PRGAViaPhaseGradient. I don't know if this should actually be zero and the selection register needs to be omitted or if we still use a selection bit to select 1 value

@tanujkhattar can you fix

@mpharrigan
Copy link
Collaborator Author

@tanujkhattar can you approve. Looks like the failures are indeed fixed :)

@mpharrigan mpharrigan requested a review from tanujkhattar July 29, 2024 18:27
@mpharrigan mpharrigan enabled auto-merge (squash) July 30, 2024 17:23
@mpharrigan mpharrigan merged commit 92549e3 into quantumlib:main Jul 30, 2024
8 checks passed
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