Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in to_tableau function for SPP gates #846

Closed
NnktYoshioka opened this issue Oct 28, 2024 · 4 comments · Fixed by #847
Closed

Bug in to_tableau function for SPP gates #846

NnktYoshioka opened this issue Oct 28, 2024 · 4 comments · Fixed by #847

Comments

@NnktYoshioka
Copy link

It seems that the stim.Circuit.to_tableau is not reflecting the presence of SPP gate now (tried in v1.13.0 and v1.14.0).
For instance when I run

print(stim.Circuit("""
H 0
SPP Z0
""").to_tableau())

# not correct
#stim.Tableau.from_conjugated_generators(
#    xs=[
#        stim.PauliString("+Z"),
#    ],
#    zs=[
#        stim.PauliString("+X"),
#    ],
#)

print(stim.Circuit("""
H 0
S 0
""").to_tableau())

# as expected
#stim.Tableau.from_conjugated_generators(
#    xs=[
#        stim.PauliString("+Z"),
#    ],
#    zs=[
#        stim.PauliString("+Y"),
#    ],
#)

The output did not change when I choose SPP X0 or SPP Y0, so I suspect that to_tableau is ignoring SPP gates.

I confirmed that SPP gates are properly working onTableauSimulator, by, e.g., running the following:

tsim = stim.TableauSimulator()
tsim.do(stim.Circuit("""
H 0
SPP Z0
"""))

print(tsim.canonical_stabilizers())

#[stim.PauliString("+Y")]
@Strilanc
Copy link
Collaborator

Good catch. It seems like this is caused by SPP not being marked as a unitary gate, so the method skips right over it (as part of the logic for optionally ignoring non-unitary gates).

Strilanc added a commit that referenced this issue Oct 28, 2024
- Fix `SPP` not being classified as a unitary gate
- Fix `SPP_DAG` not being classified as a unitary gate

Fixes #846
@Strilanc
Copy link
Collaborator

I created a fix (#847). Around a half hour after that PR is merged, you should be able to pip install stim~=1.15.dev and then stim.Circuit("SPP X0").to_tableau() should work.

@NnktYoshioka
Copy link
Author

Thanks for the superprompt fix! I pip-installed the PR and confirmed that it is working properly.

@Strilanc
Copy link
Collaborator

...what? The fix isn't pushed yet!

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 a pull request may close this issue.

2 participants