Skip to content

Add Product block encoding - #1106

Merged
tanujkhattar merged 9 commits into
quantumlib:mainfrom
charlesyuan314:product
Jul 11, 2024
Merged

tanujkhattar merged 9 commits into
quantumlib:mainfrom
charlesyuan314:product

Conversation

@charlesyuan314

Copy link
Copy Markdown
Contributor

Add an instance of BlockEncoding that implements the product of constituent block encodings.

Comment thread qualtran/bloqs/block_encoding/product.py Outdated
Comment thread qualtran/symbolics/math_funcs.py
Comment thread qualtran/bloqs/block_encoding/product.py Outdated
Comment thread qualtran/bloqs/block_encoding/product.py Outdated
Comment thread qualtran/bloqs/block_encoding/product.py
Comment thread qualtran/bloqs/block_encoding/product.py Outdated

@mpharrigan mpharrigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things to consider, but LGTM

@tanujkhattar tanujkhattar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an explanation of the decomposition to the docstring and consider doing the partitions and unpartitions once outside the for-loop

Comment thread qualtran/symbolics/math_funcs.py
Comment thread qualtran/symbolics/math_funcs.py
Comment thread qualtran/bloqs/block_encoding/product.py
Comment thread qualtran/bloqs/block_encoding/product.py
Comment thread qualtran/bloqs/block_encoding/product.py Outdated
@charlesyuan314

Copy link
Copy Markdown
Contributor Author

I will do the suggested refactor to clean up the circuit diagram in a follow-up PR.

@mpharrigan I've addressed all of the other feedback.

Comment thread qualtran/conftest.py
Comment on lines +100 to +102
'product_block_encoding',
'product_block_encoding_override',
'product_block_encoding_symb',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these not serializable ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlesyuan314 I'll merge the PR and we can continue this discussion and potentially address in a follow-up PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is because this bloq has an attribute of type Tuple[BlockEncoding, ...]. It results in the following at serialization time:

qualtran.testing.BloqCheckException: Serialization Failed:
Object arrays cannot be saved when allow_pickle=False

Are bloqs contained as attributes something that can be made serializable?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object arrays cannot be saved when allow_pickle=False

I think it's because so far we haven't had any bloq that stores a sequence of subbloqs as an attribute.

To support serialization we'll have to update

int32 subbloq = 7;
to add a new NDArray subbloqs that stores an NDArray of integers corresponding to IDs of each of the subbloqs and then update
if isinstance(val, Bloq):
to check if the argument is an ndarray of bloqs, then delegate to a different method that serializes it.

Can you please open an issue to track this?

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.

3 participants