I am trying to work with parametrized circuits in QISKIT. I can simply create parameterized circuits, bind value(s) to parameter(s), and execute/run all instances (after binding values for parameters) on different backends like ibmq_manhattan, ibmq_paris, etc.
To dump the resulting circuits to QASM files, I use the “qasm()” method of the QuantumCircuit objects, and I see no problem. Here is a simple (random) QASM file that I create:
OPENQASM 2.0; include "qelib1.inc"; qreg q; creg c; h q; h q; h q; barrier q,q,q; rx(beta) q;
As you can see, the last line of the QASM file specifies a parameterized RX rotation, on qubit q and the angle is (beta). As far as I am working with QuantumCircuit objects, I can deal with these parameters. However, after writing the circuit to a QASM file, I lose the functionality.
More specifically, when I try to load/read the QASM file and create a QuantumCircuit, I face the following error:
Code: circ = QuantumCircuit.from_qasm_file(filepath) Error: qiskit.qasm.exceptions.QasmError: "Argument 'beta' in expression cannot be found, line 9 file …
I also tried the following alternative (just in case): Code: circ = QuantumCircuit.from_qasm_str(qasm_str) and faced the same error. Here the “filepath” specifies the path to the QASM file, and I obtain the “qasm_str” via reading the QASM file.
I checked the source code of the “from_qasm_file()” module in QISKIT, as well as “Qasm” class; however, I did not find any additional input argument/parameter to specify these parameters to the parser.
I just need to read the (abovementioned) QASM file and re-create a QuantumCircuit object.
I would appreciate it a lot if someone can help me in this regard.