Skip to content

QASM3 exporter with parameterized circuit support #146

Closed
Roll249/qiskit-cpp
#1

Description

@doichanj

What should we add?

Qiskit C++ supports building parameterized circuits, but can not run them. One reason it does not support is QASM3 exporter implemented in QuantumCircuit class
(

std::string to_qasm3(void)
)
does not support parameterized circuit.

  • Move to_qasm3 function to outside of QuantumCircuit class (to other source file)
  • implement QASM3 exporter with parameter support

Activity

  1. 1ucian0 commented on Jun 3, 2026

    @1ucian0
    Member
    ❗ From June 3rd to 17th, this issue is participating in the 6th edition of unitaryHACK more info...

    If you want to participate, please follow these guidelines:

    The winners will be announced on June 24th.

    Happy hacking!

  2. Mayank447 commented on Jun 4, 2026

    @Mayank447

    Jun Doi (@doichanj) Hi, I am working on this issue. Does qiskit have a C-API to iterate over the parameters of a Quantum Circuit? The only implemented C-API I found was for number of parameters.

    Also as a side note some operations currently supported in parameters like a**b are not valid QASM3 operations (should be pow(a,b)). There might be more such operations, is there a doc of all supported operations on parameters by qiskit or is it just Python operations?

  3. 1ucian0 commented on Jun 8, 2026

    @1ucian0
    Member

    Also as a side note some operations currently supported in parameters like a**b are not valid QASM3 operations (should be pow(a,b)). There might be more such operations, is there a doc of all supported operations on parameters by qiskit or is it just Python operations?

    If you think there is an unrelated issue, please report it as a bug with a reproduction example.

  4. 1ucian0 commented on Jun 8, 2026

    @1ucian0
    Member

    Thank you to everyone who has submitted a PR for this issue! We currently have several promising fixes under review, so please hold off on submitting new PRs until the Qiskit team posts a follow-up comment here.

    We will review the existing submissions in due course. Thank you for your patience!

  5. doichanj commented on Jun 11, 2026

    @doichanj
    CollaboratorAuthor

    I reviewed all the PRs related to this issue, and I noticed we do not have C-API to get a list of parameters used in the circuit (A list of the parameters is stored on rust side, so it is not good to have duplicate list on C++ side). So I would like to propose a stab function in QuantumCircuit class to get a list of parameters and replace the implementation of the function to C-API when it will be available.

    std::vector<std::string> QuantumCircuit::parameter_symbols(void);  // please implement this one
    
    // std::vector<Parameter> QuantumCircuit::parameters(void); // this is not required currently, it is compatible to Qiskit
    

    Then pass the list of parameter symbols to QASM3 exporter.

    Also I would like to add a limitation, we do not accept the same symbols in a circuit, because we do not have C-API to identify by UUID of Parameters, for example the following should be different parameter, but we do not accept this in Qiskit C++ at this moment.

    Parameter a0("a");
    Parameter a1("a");
    
    circ.ry(a0, 0);
    circ.ry(a1, 1);
    

    So please collect a list of parameter symbols using the original symbol name for a stab function. (The original symbol name will be also used in a list of parameter set for SamplerPub/EstimatorPub)

  6. GoiBasia commented on Jun 11, 2026

    @GoiBasia
    Contributor

    Thank you for review. I have implemented the #146 requested solution in #157.

    • Added QuantumCircuit::parameter_symbols() const
    • Updated the default QASM3 export path to use it
    • Added the temporary limitation that distinct Parameter objects with the same symbol name are rejected
    • Verified with the test suite: 100% tests passed, 0 tests failed out of 4

    The implementation keeps a clean replacement point so parameter_symbols() can later be changed to use the C API once parameter-symbol enumeration is available from the Rust-side circuit data.

  7. shiv152-arch commented on Jun 11, 2026

    @shiv152-arch

    Hi. I would like to contribute to this issue, if it's still available.

  8. spital commented on Jun 12, 2026

    @spital
    Contributor

    Hi, I opened a PR for this issue here: #159

    I tried to address the QASM3 exporter support for parameterized circuits. I would appreciate any guidance on whether this is going in the right direction.

    Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions