Skip to content

Conversation

mpharrigan
Copy link
Collaborator

@mpharrigan mpharrigan commented Apr 4, 2025

Clarify the meaning of max_depth when serializing a library of bloqs.

This PR introduces two "types" of serialization: shallow and full. When the bloq is within max_depth decompositions of the root bloqs (ie those passed into the function), mark it for full serialization. If the bloq is only referred to by other bloqs, do a shallow serialization.

A shallow serialization includes the bloq name, signature, and attributes. A full serialization adds the decomposition and resource counts.

Bloqs encountered only via references in attributes will receive a shallow serializaiton. Bloqs referenced by decompositions but who themselves are outside max_depth receive shallow serialization.

The default value of max_depth is kept at 1, but this effectively removes one level of decomposition for the traditional decomp hierarchy and potentially infinite levels from composing-via-bloq-attributes.

This PR changes the serialization check for hubbard model (large) from > 1000 seconds to approx 7.

fixes #953
also fixes #1618

@mpharrigan mpharrigan requested a review from tanujkhattar April 5, 2025 00:22
@mpharrigan mpharrigan marked this pull request as ready for review April 5, 2025 00:24
@mpharrigan mpharrigan merged commit 4a4d7af into quantumlib:main Apr 9, 2025
8 checks passed
@mpharrigan mpharrigan deleted the 2025-04/serialization-perf branch May 8, 2025 20:32
wjhuggins pushed a commit to wjhuggins/Qualtran that referenced this pull request May 31, 2025
* strict BloqAsCirqGate and CirqGateAsBloq

* fixy

* Only serialize things that need serialization

* Warn when wrapping a bloq

* let cirq handle _unitary_ still
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.

qualtran/serialization/sympy.py is a dangerous filename Serialization check -- only do one level
2 participants