Save circuit as a qasm file

Aikaterini Gratsea 30 Reputation points
2024-07-11T12:27:55.5933333+00:00

I am running the chemistry.py from the tutorial here and I would like to save the circuit as a qasm file. But when I run chemistry.py with the following line included

res_circuit = qsharp.circuit(entry_expr=qsharp_string, operation=None)

I get the following error message

Traceback (most recent call last): File "c:\Users\KaterinaGratsea\qsharp\samples\estimation\df-chemistry\chemistry_ions.py", line 530, in <module> res_circuit = qsharp.circuit(entry_expr=qsharp_string, operation=None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\KaterinaGratsea\anaconda3\envs\azure_py3.11\Lib\site-packages\qsharp\_qsharp.py", line 272, in circuit return get_interpreter().circuit(entry_expr, operation) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ module.QSharpError: Error: cannot compare measurement results Call stack: at Adjoint Microsoft.Quantum.Unstable.Arithmetic.ApplyAndAssuming0Target in unstable_arithmetic_internal.qs at Microsoft.Quantum.Unstable.TableLookup.SinglyControlledSelect in unstable_table_lookup.qs at Microsoft.Quantum.Unstable.TableLookup.SinglyControlledSelect in unstable_table_lookup.qs at Microsoft.Quantum.Unstable.TableLookup.Select in unstable_table_lookup.qs at Microsoft.Quantum.Applications.Chemistry.PrepareQuantumROMState in .\src\prepare.qs at lambda in .\src\prepare.qs at Controlled(1) Microsoft.Quantum.Applications.Chemistry.OneElectronOperatorOperation in .\src\df_chemistry.qs at Controlled(1) lambda in .\src\df_chemistry.qs at Microsoft.Quantum.Applications.Chemistry.WalkStepOperation in .\src\df_chemistry.qs at lambda in .\src\df_chemistry.qs at Microsoft.Quantum.Applications.Chemistry.DoubleFactorizedChemistry in .\src\df_chemistry.qs Qsc.Eval.ResultComparisonUnsupported × runtime error ╭─[unstable_arithmetic_internal.qs:253:1] 253 │ H(target); 254 │ if M(target) == One { · ─┬─ · ╰── cannot compare to result 255 │ Reset(target); ╰──── help: comparing measurement results is not supported when performing circuit synthesis or base profile QIR generation

Any ideas what's going on here?

Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
71 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 27,251 Reputation points
    2024-07-15T07:05:18.76+00:00

    Hi @Aikaterini Gratsea

    Thank you for reaching out to the Microsoft Q&A platform.

    Azure quantum do not support generating qasm for a Q# circuit in the QDK. The qsharp.circuit API the custom is using is for generating a circuit representation that can be used to visualize the circuit.

    Please see https://zcusa.951200.xyz/en-us/azure/quantum/how-to-visualize-circuits#viewing-circuit-diagrams-for-an-entry-expression for more details and examples of usage.If you have any follow up questions, let me know in the comments.

    If I have answered your query, please click "Accept as answer" as a token of appreciation


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.