[Frontend] Ensure the order of set_basis_state_p
and set_state_p
are preserved.
#1174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: When a tape contains two state preparation operations, it will decompose one. However, the order of the decomposed operations is no longer guaranteed to come after the first state preparation. This is due to how the tracing interacts with transforms and decomposition. The only order that JAXPR cares about is the use-def chain. However, if two state preparation operations occur on a different subset of wires, then the state preparation can be placed after the one that was decomposed.
Description of the Change: We add
set_basis_state_p
andset_state_p
to theFORCED_ORDER_PRIMITIVES
set to ensure that the order is preserved as they are traced.Benefits: No logic errors.
Possible Drawbacks: More dependency on the topological sorting. I believe some time ago it was found out that topological sorting takes a long time and it takes longer the more
FORCED_ORDER_PRIMITIVES
there are.Related GitHub Issues:
TODO: