quantumlib / Qualtran

Qᴜᴀʟᴛʀᴀɴ is a Python library for expressing and analyzing Fault Tolerant Quantum algorithms.
https://qualtran.readthedocs.io/en/latest/
Apache License 2.0
132 stars 35 forks source link

More direct bloq_counts() #1074

Closed mpharrigan closed 2 weeks ago

mpharrigan commented 3 weeks ago

Get bloq counts directly without going via the call graph. This can massively speed up qlt_testing.assert_equivalent_bloq_counts, which will necessarily call CompositeBloq.bloq_counts which will involve lots of hashing of the composite bloq xref #1073 .

This also has prompted me to finally deal with what happens if you have two of the same bloq in your list of BloqCountT, perhaps returned by build_call_graph. Indeed, bloq_counts returns a dictionary so we have to add those keys. This was also necessary to make sure that if two things get generalized to the same result, their counts get added into one entry. Dealing with this is a pre-requisite for #845