Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

Serialization check -- only do one level

Open mpharrigan opened this issue 1 year ago • 1 comments

The current automatic check for serialization is too slow to operate as a unit test or as part of the bloq_report_card notebook. We've been sprinkling in some skips but top-level bloqs will always be slow and always be sneaking in.

The check should just do one level of decomposition and serialization. The serializability of grand-callees of a bloq are not under the purview of the check/unit test for that bloq.

mpharrigan avatar May 13 '24 23:05 mpharrigan

Also, if all bloqs have a serialization unit test, then chances are that grand callees are also serializable and therefore we can not have them as part of the unit test for every bloq

tanujkhattar avatar May 13 '24 23:05 tanujkhattar

assert_bloq_example_serializes uses bloqs_to_proto which has a default max_depth of 1 ... but that only applies to the decomposition depth. Recursing through bloqs that are found in the attrs attributes is unbounded and presumably the source of the slowest bloq checks (QubitizationQPE)

mpharrigan avatar Apr 02 '25 00:04 mpharrigan

The bloqs_to_proto function first searches the call graph and attributes to find all possible bloq objects we may want to refer to. The references are handled by the bloq_to_id mapping. This is all fine. The problem is that the second part of the bloqs_to_proto function uses the keys in bloq_to_id as the list of bloqs that need to be serialized. Bloqs used in arguments need to be referred to, i.e. they need to have an entry in the bloq_to_id dictionary, but they should not be decomposed or have their resources counted

mpharrigan avatar Apr 02 '25 00:04 mpharrigan