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

Greedy topological sort of the binst graph to minimize qubit allocations / deallocations #1099

Open tanujkhattar opened 4 days ago

tanujkhattar commented 4 days ago

This PR adds a new stable greedy topological sorting method and changes the default topological sort to use this method when iterating over nodes of a bloq instance graph.

This is useful to

Fixes the issue mentioned in https://github.com/quantumlib/Qualtran/pull/963#issuecomment-2192745758, would be useful for https://github.com/quantumlib/Qualtran/issues/1097 and can be improved by addressing https://github.com/quantumlib/Qualtran/issues/1098