Skip to content

Conversation

david-pl
Copy link
Collaborator

@david-pl david-pl commented Aug 5, 2025

Draft for #435

Looks like this was long overdue. It fails currently because:

  • Missing noise rewrite for Depolarize2 (this also means pyqrack simulation fails)
  • Cirq emit is missing Rot (wow, that's on me) and ResetToOne.
  • There's a bug in the Squin2StimPass which causes an error.

The only thing that seems to work right now is the AddressAnalysis (kudos @johnzl-777).

@kaihsin @johnzl-777 the test for the Squin2StimPass still needs some work to properly test stuff, but I didn't want to mix commits and start fixing bugs right now, so we need to add that later.
FYI, I added a little rewrite pass just for testing that removes intentionally unsupported statements in case that's relevant for the stim tests. We should probably document these statements somewhere, but right now it's basically just atom loss that is unsupported in cirq.

Open questions:

  • Is this everything or did I miss out on something?
  • How do we test the wire dialect?

Edit: After @johnzl-777 pointed to them in #435, I also added tests for the MeasurementIDAnalysis (which works) and the NSitesAnalysis (currently chokes on PauliString).

johnzl-777 pushed a commit that referenced this pull request Aug 8, 2025
david-pl added a commit that referenced this pull request Aug 8, 2025
Another thing that came out of #436.

---------

Co-authored-by: Phillip Weinberg <[email protected]>
david-pl added a commit that referenced this pull request Aug 8, 2025
david-pl added a commit that referenced this pull request Aug 8, 2025
Another thing that came out of #436.

---------

Co-authored-by: Phillip Weinberg <[email protected]>
@david-pl
Copy link
Collaborator Author

@johnzl-777 not sure what the problem with the Squin2Stim rewrite is right now. It chokes when I try to add the auxiliary dialect (which I probably shouldn't be doing in any case). Is there a key clash somewhere?

@johnzl-777
Copy link
Contributor

Wait @david-pl I assume (especially from the comment) you still need the list of supported statements that can be translated to stim, right? Otherwise this definitely won't go through as-is 😅

@david-pl
Copy link
Collaborator Author

@johnzl-777 yes, definitely. But I'm not 100% sure how the error in the test is related.

@david-pl
Copy link
Collaborator Author

Alright, looks like the squin2stim test is the last one we need to fix, all other tests pass already.

david-pl added a commit that referenced this pull request Aug 13, 2025
One of the things that dropped out of #436
Copy link
Contributor

github-actions bot commented Aug 15, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
10396 9166 88% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 95478f1 by action🐍

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@johnzl-777
Copy link
Contributor

@david-pl I'm still not quite sure why stim.aux was causing so much trouble but I suspect it has something to do with the combination of fixpoint being called instead of the standard unsafe_run and the type inference pass.

That being said just a couple observations on my end:

  • SquinToStim CAN handle specific instances of scf.IfElse and U3 (equivalent to Clifford gates). I can modify your original kernel slightly to allow this to happen
  • There's currently no "adjoint" canonicalization that happens right now (that is, something clever where if you have nested adjoints you can collapse them) and while we do have the ability to emit things like SQRT_X_DAG it turns out there's some incorrect logic in SquinToStim I'll have to fix (I literally just realized from trying to get this unit PR to work haha)
  • is it desirable to have these tests assert against something? I understand these tests at the very least force relevant passes/analyses targeting squin to run but I feel like it should be checked against something. If it's desirable I can go ahead and just do what I've been doing with the SquinToStim tests which is assert against a .stim file.

@david-pl
Copy link
Collaborator Author

@johnzl-777 thanks for updating the test! I'm responding point-by-point here:

  • Sure! It might make sense to be testing some basic control flow stuff. That will probably break some other tests (e.g. cirq emit doesn't know how to handle control flow), but we can fix the tests then as I think we should be checking control flow in general.
  • Pending issue RFC: Smarter Adjoint Handling in SquinToStimPass (and in general) #468 I suppose.
  • Definitely, I simply got "stuck" on the error in the rewrite pass, which is why I couldn't verify any output. Please go ahead and add that assert.

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.

RFC: tracking new squin statements
2 participants