Skip to content

Emit twirl from boundary in left-dressed boxes#368

Merged
joshuasn merged 5 commits into
mainfrom
change-left-twirl-location
May 27, 2026
Merged

Emit twirl from boundary in left-dressed boxes#368
joshuasn merged 5 commits into
mainfrom
change-left-twirl-location

Conversation

@joshuasn
Copy link
Copy Markdown
Collaborator

Summary

This PR moves the location of twirl emissions from the right-hand side of a left-dressed box to the boundary between easy and hard gates. Adding to allow for support of measure operations as propagators.

Details and comments

This simplifies the sorted order pretty significantly.

I also had to make a small change where the choice between SliceRegisterNode and CombineRegistersNode was made. Previously, when we had a left- then a right-dressed box, as the emits were on the edge of the box opposite the hard content, the emissions from both would be combined to always match the number of subsystems for any hard gates. This is not the case anymore for examples like the following:

with circuit.box([Twirl()]):
     circuit.cx(0, 1)

with circuit.box([Twirl()]):
     circuit.h(0)

with circuit.box([Twirl(dressing="right")]):
     circuit.cx(0, 1)

Here, the emission on qubit 1 from the right dressed box would error when encountering the CX from the first box as it selects a SliceRegisterNode that is trying to write a single register to two registers. The change in this PR looks for these cases and instead uses a CombineRegisterNode that starts with an identity on the correct number of subsystems and multiplies the virtual register on a smaller number of subsystems into it.

@joshuasn joshuasn marked this pull request as draft May 20, 2026 16:21
@joshuasn joshuasn marked this pull request as ready for review May 25, 2026 14:47
Copy link
Copy Markdown
Collaborator

@ihincks ihincks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Josh. We should include a changelog for the change here.

Comment thread changelog.d/368.changed.md Outdated
@joshuasn joshuasn requested a review from ihincks May 25, 2026 19:24
@joshuasn joshuasn merged commit b278e7e into main May 27, 2026
8 checks passed
@joshuasn joshuasn deleted the change-left-twirl-location branch May 27, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants