-
Notifications
You must be signed in to change notification settings - Fork 0
squin to stim rewrite #148
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Hi @Roger-luo , I believe what you see here should be a decent first pass with me trying to work with a bit of a mismatch in terms of how squin can be mapped to the existing stim dialect. Feel free to let me know what you think would be acceptable additions to either dialect based on my observations below, I can gladly spin that out as a separate PR/RFC. I haven't taken advantage of the site analysis results just yet but it should be very easy for me to implement, I just wanted to make sure the analyses and overall rewrite behavior were (mostly) correct.
|
Yeah, can you start an RFC issue for reset? I think reset needs some more thoughts. I think for the first pass, we can just skip those doesn't match well - squin is more expressive so not everything can be compiled into stim. |
xref #25 I realize we need a codegen for stim instead of a rewrite. And to make the UX better, we need a separate analysis pass to validate all possible incompatibility of stim when compiling from squin. |
I think this partly resolves the ongoing thread between myself, @ChenZhao44 and @weinbe58 over handling the friction from the fact that I know @ChenZhao44 was advocating for just throwing an exception and killing the rewrite if it detected any form of squin measurement being depended on while @weinbe58 pointed out it would be more proper to just "let it slide" and say no rewrite happened but let emission choke on it instead. @weinbe58 also suggested potentially "manipulating" the squin measurement result if it's being returned to something like "None" @Roger-luo has pointed out this easily violates the original intent of the function (and I'm sure causes even more problems downstream). I support @Roger-luo 's direction here as well as the result of @kaihsin 's and @weinbe58 's conversations that codegen seems more sensible here. |
so rewrites technically are no-raise because the rewrite rules happens only when we are sure about the equivalence. If it cannot perform the rewrite, it will not be applied to the code instead of throwing an exception. So does codegen - we want to be able to catch as many issues as we can before running any codegen or rewrite so we can have a nice error message. This is kinda true for all the possible codegen/rewrite because you rely on compile-time info to do these codegen/rewrite. I think it's always good practice to do around of validation to be certain on the entire program before mutating/generating the code that one intends to do. |
I mean we could raise within a rewrite rule, I kinda understand that is convenience to work with, but on the other hand, it will be nasty for a user because now validation is coupled with rewrite, and this would terminate rewrite process - meaning if there are multiple errors, one have to keep trying and failing until all errors are being address-ed, when all errors are technically possible to be addressed in one-go with an analysis. |
Got it 👍 I'll open up an issue to sketch out/track progress on the analysis passes to catch Stim-incompatible squin programs |
No description provided.