Open jyu00 opened 2 weeks ago
A workaround is to have a mapping of the before/after parameter names using they position. For example, one can track that parameter θ[0]
is at position 0. So any parameter values that were supposed to go to θ[0]
will now go to the new position 0 parameter named _θ_0_
Thank you for submitting the issue @jyu00 ! Since it belongs to our internal repo instead of this one, I will create the issue there and close this one, ok?
I opened this issue here so other people who encounter the same issue can see the progress. For that reason, I'd prefer to leave this open until it's fixed.
Hi @jyu00 ! I've been checking and this seems to be a problem with the QASM3 importer/exporter. If I just serialize to qasm3 and deserialize again, without doing anything else in between, the same problem arises:
from qiskit.circuit.library import RealAmplitudes
circuit = RealAmplitudes(num_qubits=2, reps=1)
print(f"Before parameters: {circuit.parameters}")
circuit_q = qasm3.loads(qasm3.dumps(circuit))
print(f"After parameters: {circuit_q.parameters}")
This prints:
Before parameters: ParameterView([ParameterVectorElement(θ[0]), ParameterVectorElement(θ[1]), ParameterVectorElement(θ[2]), ParameterVectorElement(θ[3])])
After parameters: ParameterView([Parameter(_θ_0_), Parameter(_θ_1_), Parameter(_θ_2_), Parameter(_θ_3_)])
Circuit returned by the transpiler service has its parameter names altered. For example:
This prints