Simplify STIM-to-QIR snapshot tests - #3698
Conversation
| body: | ||
| br label %select_0 | ||
| select_0: | ||
| call void @__quantum__qis__m__body(ptr inttoptr (i64 0 to ptr), ptr inttoptr (i64 0 to ptr)) | ||
| call void @__quantum__qis__m__body(ptr inttoptr (i64 1 to ptr), ptr inttoptr (i64 1 to ptr)) | ||
| call void @__quantum__qis__m__body(ptr inttoptr (i64 2 to ptr), ptr inttoptr (i64 2 to ptr)) | ||
|
|
||
| declarations: | ||
| declare void @__quantum__qis__m__body(ptr, ptr) |
There was a problem hiding this comment.
I think the choice of syntax is a bit confusing, since the headers body: and declarations: look like valid QIR tags.
| call void @__quantum__qis__m__body(ptr inttoptr (i64 0 to ptr), ptr inttoptr (i64 0 to ptr)) | ||
| call void @__quantum__qis__m__body(ptr inttoptr (i64 1 to ptr), ptr inttoptr (i64 1 to ptr)) | ||
| call void @__quantum__qis__m__body(ptr inttoptr (i64 2 to ptr), ptr inttoptr (i64 2 to ptr)) |
There was a problem hiding this comment.
Looks like we are missing the *_record_output calls in the body. I don't consider that to be boilerplate, but rather something that needs validation in the tests.
There was a problem hiding this comment.
This is a nice simplification to aid visual validation. Some general thoughts on the PR:
First: whatever decision gets taken here, these tests will likely go away after the QIR -> Q# AST transition, which is the very next follow up work. With that being said:
- Just printing the body of the main function creates an asymmetry between the main definition and other function definitions.
- The
main:,declarations:anddefinitions:headers can be confused with valid QIR tags by someone who didn't design the test format. - I believe the
*_record_outputcalls and the function's return instruction are valuable information to validate in the tests' output.
(This last note is a totally optional suggestion: I think you can achieve 80% of the boilerplate simplification by just omitting the declarations, attributes, and module flags. Definitions need review, so they shouldn't be omitted).
This branch makes Stim-to-QIR snapshot tests smaller and easier to review by removing repeated QIR boilerplate from most expectations while retaining the generated instructions, helper definitions, declarations, resource counts, and noise details that distinguish each case. It also makes emitted QIR deterministic.
QIR emission
qdk_noiseattribute before module flags.Snapshot infrastructure
body,definitions, anddeclarationssections, followed by required qubit and result counts.uses_noisemarker and the effective noise configuration; compiler error expectations remain unchanged.