Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Initial Implementation of a Limited QASM3 Exporter in Rust #13666

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

to24toro
Copy link
Contributor

@to24toro to24toro commented Jan 15, 2025

Summary

This PR introduces and integrates several key modules for a Rust-based quantum computing framework, laying the foundation for exporting circuits in QASM 3.0 format. The modules added are:
1. printer.rs:
• Implements functionality for formatted output generation of AST or other hierarchical structures.
2. symbols.rs:
• Manages a symbol table used for mapping variable names to their corresponding entities.
• Provides helper methods for creating, binding, and looking up symbols with robust error handling.
Note: This file is directly copied from Qiskit’s OpenQASM 3 parser, as this symbol table is used when loading QASM 3.0 and converting it to quantum circuits. However, this architecture might be overly complex for the current task of QASM 3.0 exporting, and its necessity should be revisited in future iterations.
3. ast.rs:
• Defines the AST structure for representing quantum programs.
• Contains data structures such as nodes, expressions, and declarations that model the core components of quantum circuit descriptions.
4. exporter.rs:
• Implements a builder for generating QASM 3.0 programs.
• Integrates with Python-based tools (via pyo3) to extract circuit data and parameters.

Current Limitations

The current implementation has limited QASM 3.0 output functionality and relies on partial Python integration. The following features are not yet supported:
• Control Flow Constructs: While QASM 3.0 supports control flow, such as loops and conditionals, these are not yet implemented.
• Classical Variables: Handling classical variables is not included in the current architecture.
• Not standard Gates: Generating QASM for not standard gates and mapping them to Qiskit’s standard gates is pending.

These tasks require further discussion to determine whether they should be included in the scope of Qiskit Issue #13145. My recommendation is to address these features after Qiskit PR #13278 is merged, potentially targeting them for the 2.1 release and beyond.

What is Pending

1. Support for:
• Control flow constructs like loops, conditionals, and subroutines.
• Advanced QASM 3.0 features, including classical variable handling and parameterized gates.
• Handling edge cases for non-standard instructions or unique circuit data.
2. Architecture Alignment:
• Finalizing the architecture based on team feedback to ensure long-term scalability.
• Deciding whether the symbol table from symbols.rs should remain part of the architecture or be replaced with a more streamlined solution.

Discussion Points

1. Scope of Qiskit Issue #13145:
• Should the above pending features (control flow, classical variables, custom gates) be addressed as part of this issue, or deferred to subsequent iterations?
• My suggestion is to revisit these features post-merge of Qiskit PR #13278, targeting them for the 2.1 release or later.
2. Testing and Architecture Validation:
• Before implementing test cases, I would like to confirm agreement on the overall architecture and the scope of tasks to ensure alignment with the team’s priorities.

@to24toro to24toro requested a review from a team as a code owner January 15, 2025 07:42
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@to24toro to24toro self-assigned this Jan 15, 2025
@to24toro to24toro added Rust This PR or issue is related to Rust code in the repository performance labels Jan 15, 2025
@to24toro to24toro modified the milestone: 2.0.0 Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants