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

Parser support for halved parameters. #193

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

ScottWe
Copy link
Contributor

@ScottWe ScottWe commented Dec 20, 2024

Summary

This pull request extends the OpenQASM parser and code generator to support halved parameters.

Related Issues

This pull request should resolve issue #190.

Details

To parse gates with halved parameters, the following three changes are made to QasmParser.

  • If a halved symbolic parameter p[i] is used in a context where parameters are not halved, then the parameter is scaled by 2. Formally, it is replaced by p[i] + p[i].
  • If a standard symbolic parameter is used in a context where parameters are halved, then an error is raised.
  • If a constant parameter is used in a context where parameters are halved, then the parameter is scaled by 1/2.

To print gates with halved parameters, to_qasm_style_string now scales constant halved parameters by a factor of 2.

Evidently, these changes increase the complexity of symbolic parameter parsing. For this reason, the symbolic parameter parsing code has been factored out into its own method ParamParser::parse_symb_param. While testing these changes, it was noted that ParamParser::parse_symb_param did not support negative parameters, which is also resolved in this pull request.

Note

The current circuit generator does not support symbolic parameters. This pull request does not introduce this feature. However, an error message was added to indicate when a symbolic parameter could possibly get discarded.

Copy link
Collaborator

@xumingkuan xumingkuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@xumingkuan
Copy link
Collaborator

The current circuit generator does not support symbolic parameters.

(A note to myself: this is saying CircuitSeq::to_qasm_style_string does not support symbolic parameters currently.)

@xumingkuan xumingkuan merged commit d9001e0 into quantum-compiler:master Dec 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants