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

Simplify Product block encoding decomposition #1128

Merged
merged 6 commits into from
Jul 15, 2024

Conversation

charlesyuan314
Copy link
Contributor

This change refactors the Product block encoding, following suggestion in discussion, to perform fewer partitions of the ancilla and resource registers up front and to rely on AutoPartition to simplify the circuit diagram of each constituent block.

@mpharrigan
Copy link
Collaborator

I'm staring at the product_block_encoding_properties.decompose_bloq() diagram and I think this mostly makes sense. Why are the "ancilla" and "resource" registers still being split with different ones being fed into B[U_a] vs B[U_b]?

@charlesyuan314
Copy link
Contributor Author

charlesyuan314 commented Jul 12, 2024

With ancilla, we are doing just one split at the beginning into the flag_bits and the inner ancilla that is then fed to each of the constituents. The constituents use AutoPartition to ignore the unused bits. I have updated a comment to make it clearer that there are not separate individual ancilla registers.

With resource, there is a question of whether these bits are being returned to zero. If so, the constituents can share the resource bits in the same way as ancilla but without need for the flag bits. I have gone ahead with this assumption for now and changed the code to not split the resource register and rely only on AutoPartition. This cleans up the diagram.

It is possible that some block encodings will leave their resource state dirty and thus require flag bits separate resource registers here. I think properly supporting this behavior without using excessive bits could be done via a flag attribute in the BlockEncoding interface, analogous to the check of whether the signal_state is identity.

I can open an issue tracking the general fix above and add a code comment referencing it. Does that sound like a reasonable plan?

@mpharrigan
Copy link
Collaborator

mpharrigan commented Jul 12, 2024

Thanks for the careful thought! Issue sounds like a good plan

@charlesyuan314 charlesyuan314 enabled auto-merge (squash) July 15, 2024 17:14
@charlesyuan314 charlesyuan314 merged commit 09533d6 into quantumlib:main Jul 15, 2024
7 checks passed
@charlesyuan314 charlesyuan314 deleted the product branch July 15, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants