I'm learning Q#. Is there any way to see the QASM code of a Q# function I write, the same way I can see the disassembly of a C# function?
Asked
Active
Viewed 422 times
1 Answers
5
Q# is not compiled into QASM, so that would be tricky. Q# compilation and execution process is approximately as follows:
- Q# code is parsed into an internal data structure representing an abstract syntax tree. This data structure undergoes some transformations (for example, to generate adjoint and controlled versions of operations used in the code). I don't know a way to see this representation directly.
- Next, to execute the code on a simulator this data structure is used to generate C# code. This code doesn't look particularly assembly-like, since it maintains a lot of high-level language constructs. If your Q# code was stored in file
MyCode.qsin folderA, the C# result of code generation will be found inA\obj\qsharp\src\MyCode.g.cs. - C# compiler compiles this generated code into a classical executable and runs it.
Having said that, it is possible to write a separate tool that will convert a subset of Q# operations into OpenQasm; this example by Rolf Huisman shows a way to do that.
Mariia Mykhailova
- 9,285
- 1
- 13
- 40